Merge branch 'master' of https://github.com/wso2/product-iots into das-ext

application-manager-new
ayyoob 9 years ago
commit 4bd9fd3a56

@ -730,6 +730,13 @@
</outputDirectory>
<fileMode>755</fileMode>
</file>
<file>
<source>src/repository/jaggeryapps/portal/configs/designer.json</source>
<outputDirectory>
${pom.artifactId}-${pom.version}/repository/deployment/server/jaggeryapps/portal/configs
</outputDirectory>
<fileMode>755</fileMode>
</file>
<!-- End of "portal" app specific modifications -->
<!-- Copying synapse.properties file -->
<file>

@ -0,0 +1,66 @@
{
"store": {
"types": ["fs"]
},
"gadgetGeneration" :{
"isCreateGadgetEnable": false,
"ignoreProviders": ["rt"]
},
"authentication": {
"activeMethod": "basic",
"methods": {
"sso": {
"attributes": {
"issuer": "portal",
"identityProviderURL": "https://localhost:9443/samlsso",
"responseSigningEnabled": "false",
"acs": "https://localhost:9444/portal/acs",
"identityAlias": "wso2carbon",
"useTenantKey": false
}
},
"basic": {
"attributes": {}
}
}
},
"authorization": {
"activeMethod": "oauth",
"methods": {
"oauth": {
"attributes": {
"idPServer": "https://localhost:9443/oauth2/token",
"dynamicClientProperties": {
"callbackUrl": "https://localhost:9443/portal",
"clientName": "portal",
"owner": "admin",
"applicationType": "JaggeryApp",
"grantType": "password refresh_token urn:ietf:params:oauth:grant-type:saml2-bearer",
"saasApp": false,
"dynamicClientRegistrationEndPoint": "https://localhost:9443/dynamic-client-web/register/",
"tokenScope": "Production"
}
}
}
}
},
"designers": [
"Internal/everyone"
],
"tenantPrefix": "/t",
"shareStore": false,
"theme": "basic",
"cacheTimeoutSeconds": "5",
"cacheSizeBytes": "1073741824",
"defaultDashboardRedirect": false,
"isCreateGadgetEnable": true,
"oauth": {
"username": "admin",
"password": "admin"
},
"host": {
"hostname": "localhost",
"port": "",
"protocol": ""
}
}

@ -1,42 +0,0 @@
{
"store": {
"type": "fs"
},
"authentication": {
"activeMethod": "basic",
"methods": {
"sso": {
"attributes": {
"issuer": "portal",
"identityProviderURL": "https://localhost:9443/samlsso",
"responseSigningEnabled": "false",
"acs": "https://localhost:9444/portal/acs",
"identityAlias": "wso2carbon",
"useTenantKey": false
}
},
"basic": {
"attributes": {}
}
}
},
"designers": [
"Internal/everyone"
],
"tenantPrefix": "/t",
"shareStore": false,
"theme": "analytics",
"cacheTimeoutSeconds": "5",
"cacheSizeBytes": "1073741824",
"defaultDashboardRedirect": false,
"isCreateGadgetEnable": false,
"oauth": {
"username": "admin",
"password": "admin"
},
"host": {
"hostname": "localhost",
"port": "",
"protocol": ""
}
}

@ -1,33 +1,9 @@
<span id="connectedcup-details" data-devices="{{devices}}" data-devicename="{{device.name}}"
data-deviceid="{{device.deviceIdentifier}}"
data-appcontext="{{@app.context}}"></span>
<div id="connectedcup-div-chart" data-backend-api-url= {{backendApiUri}}>
<div class="chartWrapper" id="chartWrapper-temperature">
<span id="span-title">Temperature</span>
<div id="y_axis-temperature" class="custom_y_axis"></div>
<div class="legend_container">
<div id="smoother-temperature" title="Smoothing"></div>
<div id="legend-temperature"></div>
</div>
<div id="chart-temperature" class="custom_rickshaw_graph"></div>
<div id="x_axis-temperature" class="custom_x_axis"></div>
<div id="slider-temperature" class="custom_slider"></div>
</div>
<iframe src="{{dashboardserverURL}}/portal/gadgets/connected-cup-analytics/landing" width="100%" height="1700" frameBorder="0"></iframe>
<div class="chartWrapper" id="chartWrapper-coffeelevel">
<span id="span-title">Coffee Level</span>
<div id="y_axis-coffeelevel" class="custom_y_axis"></div>
<div class="legend_container">
<div id="smoother-coffeelevel" title="Smoothing"></div>
<div id="legend-coffeelevel"></div>
</div>
<div id="chart-coffeelevel" class="custom_rickshaw_graph"></div>
<div id="x_axis-coffeelevel" class="custom_x_axis"></div>
<div id="slider-coffeelevel" class="custom_slider"></div>
</div>
</div>
<style>
#rangeSliderWrapper{ display: none;}
</style>
{{#zone "bottomJs"}}
{{js "js/connectedcup.js"}}

@ -26,7 +26,8 @@ function onRequest(context) {
if (devices) {
return {
"devices": stringify(devices),
"backendApiUri": devicemgtProps["httpsURL"] + "/connectedcup/stats/"
"backendApiUri": devicemgtProps["httpsURL"] + "/connectedcup/stats/",
"dashboardserverURL" : devicemgtProps["dashboardserverURL"]
};
} else if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) {
var deviceModule = require("/app/modules/device.js").deviceModule;
@ -34,7 +35,8 @@ function onRequest(context) {
if (device && device.status != "error") {
return {
"device": device,
"backendApiUri": devicemgtProps["httpsURL"] + "/connectedcup/stats/" + deviceId
"backendApiUri": devicemgtProps["httpsURL"] + "/connectedcup/stats/" + deviceId,
"dashboardserverURL" : devicemgtProps["dashboardserverURL"]
};
} else {
response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!");

@ -80,5 +80,5 @@ public interface DeviceTypeService {
@GET
@Produces("application/zip")
@Permission(scope = "CONNECTEDLAP_user", permissions = {"/permission/admin/device-mgt/download"})
Response downloadSketch(@QueryParam("deviceName") String deviceName, @QueryParam("sketchType") String sketchType);
Response downloadSketch(@QueryParam("deviceName") String deviceName, @QueryParam("sketchType") String sketchType,@QueryParam("osType") String osType);
}

@ -24,7 +24,7 @@ import org.wso2.connectedlap.api.util.APIUtil;
import org.wso2.connectedlap.api.util.ZipUtil;
import org.wso2.connectedlap.plugin.constants.DeviceTypeConstants;
import org.wso2.connectedlap.api.DeviceTypeService;
import org.wso2.connectedlap.plugin.impl.uti.ConnectedLapResponse;
import org.wso2.connectedlap.plugin.impl.util.ConnectedLapResponse;
import org.wso2.connectedlap.plugin.impl.util.ConnectedLapDevice;
import org.apache.commons.io.FileUtils;
@ -265,9 +265,9 @@ public class DeviceTypeServiceImpl implements DeviceTypeService {
@GET
@Produces("application/zip")
public Response downloadSketch(@QueryParam("deviceName") String deviceName,
@QueryParam("sketchType") String sketchType) {
@QueryParam("sketchType") String sketchType, @QueryParam("osType") String osType) {
try {
ZipArchive zipFile = createDownloadFile(APIUtil.getAuthenticatedUser(), deviceName, sketchType);
ZipArchive zipFile = createDownloadFile(APIUtil.getAuthenticatedUser(), deviceName, sketchType ,osType);
Response.ResponseBuilder response = Response.ok(FileUtils.readFileToByteArray(zipFile.getZipFile()));
response.status(Response.Status.OK);
response.type("application/zip");
@ -301,7 +301,7 @@ public class DeviceTypeServiceImpl implements DeviceTypeService {
return Long.toString(l, Character.MAX_RADIX);
}
private ZipArchive createDownloadFile(String owner, String deviceName, String sketchType)
private ZipArchive createDownloadFile(String owner, String deviceName, String sketchType , String osType)
throws DeviceManagementException, JWTClientException, APIManagerException,
UserStoreException {
@ -329,7 +329,7 @@ public class DeviceTypeServiceImpl implements DeviceTypeService {
ZipUtil ziputil = new ZipUtil();
ZipArchive zipFile = ziputil.createZipFile(owner, APIUtil.getTenantDomainOftheUser(), sketchType,
deviceId, deviceName, accessToken, refreshToken);
deviceId, deviceName, accessToken, refreshToken,osType);
return zipFile;
}
@ -337,27 +337,21 @@ public class DeviceTypeServiceImpl implements DeviceTypeService {
String summeryTableName;
switch (sensorName) {
case "battery" :
summeryTableName = DeviceTypeConstants.DEVICE_BATTERY_STATS;
break;
return DeviceTypeConstants.DEVICE_BATTERY_STATS;
case "charger":
summeryTableName = DeviceTypeConstants.DEVICE_CHARGER_STATS;
break;
return DeviceTypeConstants.DEVICE_CHARGER_STATS;
case "cpu":
summeryTableName = DeviceTypeConstants.DEVICE_CPU_STATS;
break;
return DeviceTypeConstants.DEVICE_CPU_STATS;
case "network":
summeryTableName = DeviceTypeConstants.DEVICE_NETWORK_STATS;
break;
return DeviceTypeConstants.DEVICE_NETWORK_STATS;
case "memory":
summeryTableName = DeviceTypeConstants.DEVICE_MEMORY_STATS;
break;
return DeviceTypeConstants.DEVICE_MEMORY_STATS;
case "harddisc":
summeryTableName = DeviceTypeConstants.DEVICE_HARD_DISC_STATS;
break;
return DeviceTypeConstants.DEVICE_HARD_DISC_STATS;
default:
summeryTableName = "";
return null;
}
summeryTableName= summeryTableName.replaceAll("\\u200B","");
return summeryTableName;
//summeryTableName= summeryTableName.replaceAll("\\u200B","");
//return summeryTableName;
}
}

@ -44,7 +44,7 @@ public class ZipUtil {
public ZipArchive createZipFile(String owner, String tenantDomain, String deviceType,
String deviceId, String deviceName, String token,
String refreshToken) throws DeviceManagementException {
String refreshToken,String osType) throws DeviceManagementException {
String sketchFolder = "repository" + File.separator + "resources" + File.separator + "sketches";
String archivesPath = CarbonUtils.getCarbonHome() + File.separator + sketchFolder + File.separator + "archives" +
@ -75,6 +75,7 @@ public class ZipUtil {
contextParams.put("MQTT_EP", mqttEndpoint);
contextParams.put("DEVICE_TOKEN", token);
contextParams.put("DEVICE_REFRESH_TOKEN", refreshToken);
contextParams.put("OS_TYPE", osType);
ZipArchive zipFile;
zipFile = Utils.getSketchArchive(archivesPath, templateSketchPath, contextParams, deviceName);

@ -22,6 +22,7 @@ import java.io.IOException;
import org.json.JSONObject;
import org.wso2.agent.common.Common;
import org.wso2.agent.config.Configuration;
import org.wso2.agent.resourcemonitor.pojo.SystemUsage;
import com.sun.jersey.api.client.Client;
@ -36,7 +37,8 @@ public class PushSystemUsage {
try {
Client client = Client.create(Common.configureClient());
client.setConnectTimeout(50000);
WebResource webResource = client.resource("https://localhost:9443/connected-lap-agent/push_data");
String URL= String.valueOf(new Configuration().getInitProperty("https-ep"));
WebResource webResource = client.resource(URL+"/connected-lap-agent/push_data");
Form form = new Form();
form.add("deviceId", deviceid);
form.add("deviceOwner", owner);
@ -57,11 +59,11 @@ public class PushSystemUsage {
System.out.println(output);
JSONObject outputjson= new JSONObject(output);
if (response.getStatus() != 200 || outputjson ==null || !outputjson.getBoolean("success")) {
throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
// throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
}
}
catch (Exception e) {
throw e;
// throw e;
}
}
}

@ -72,12 +72,12 @@ public class JavaApp {
Configuration config = new Configuration();
try {
String token = String.valueOf(config.getInitProperty("auth-token"));
//token="9c7a1b4d6625cdd936b894cc0e7c7390";
String refreshtoken = String.valueOf(config.getInitProperty("refresh-token"));
String device_name = String.valueOf(config.getInitProperty("device-name"));
Client client = Client.create(Common.configureClient());
client.setConnectTimeout(50000);
WebResource webResource = client.resource("https://localhost:9443/CONNECTEDLAP/device/register");
String URL= String.valueOf(new Configuration().getInitProperty("https-ep"));
WebResource webResource = client.resource(URL+"/CONNECTEDLAP/device/register");
String mac = spec.getMacaddress().replaceAll("\\:", "");
deviceid = mac;
@ -100,12 +100,12 @@ public class JavaApp {
devicetoken = outputJson.getString("accessToken");
devicerefreshtoken = outputJson.getString("refreshToken");
if (response.getStatus() != 200) {
throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
// throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
}
config.SaveRegistration(spec, devicetoken, devicerefreshtoken);
} catch (Exception e) {
//e.printStackTrace();
throw e;
//throw e;
}
}

@ -63,12 +63,12 @@ public class Collector {
return spec;
}
public SystemUsage getSysUsage(String suPassword) throws NumberFormatException, Exception {
public SystemUsage getSysUsage(String suPassword) throws Exception {
SystemUsage systemUsage = new SystemUsage();
BashRunner bashRunner = new BashRunner();
systemUsage.setMacaddress(bashRunner.runScript(this.OS, 0,suPassword));
systemUsage.setProcessor_usage(Float.valueOf(bashRunner.runScript(this.OS, 10,suPassword)));
systemUsage.setMemory_usage(Float.valueOf(bashRunner.runScript(this.OS, 11,suPassword)));
//systemUsage.setMemory_usage(Float.valueOf(bashRunner.runScript(this.OS, 11,suPassword)));
systemUsage.setStorage_usage(Float.valueOf(bashRunner.runScript(this.OS, 12,suPassword)));
systemUsage.setBattery_percentage(Float.valueOf(bashRunner.runScript(this.OS, 13,suPassword)));
systemUsage.setBattery_pluggedin(Byte.valueOf(bashRunner.runScript(this.OS, 14,suPassword)));

@ -43,6 +43,7 @@ public class BashRunner {
private String[] getScript(String os, int scriptid,String suPassword) throws OperationalException {
String script[] = null;
try {
if(os.equalsIgnoreCase("LINUX")) {
if (scriptid == 0)
script = new String[]{"/bin/sh", "-c", "ifconfig -a | awk '/^[a-z]/ { iface=$1; mac=$NF; next } /inet addr:/ { print mac }' | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'" + " | tr '\n' ' '"};
if (scriptid == 1)
@ -66,6 +67,31 @@ public class BashRunner {
script = new String[]{"/bin/sh", "-c", "upower -i $(upower -e | grep BAT) | grep -E 'percentage' | awk '{ print $2 }' | tr '%' ' '" + " | tr '\n' ' '"};
if (scriptid == 14)
script = new String[]{"/bin/sh", "-c", "upower -i $(upower -e | grep BAT) | grep -E 'state' | awk '{ if($2==\"charging\"||$2==\"fully-charged\") print 1; else print 0; }'" + " | tr '\n' ' '"};
}else{
if (scriptid == 0)//mac
script = new String[]{"/bin/sh", "-c", "ifconfig en1 | awk '/ether/{print $2}'" + " | tr '\n' ' '"};
if (scriptid == 1)//processor
script = new String[]{"/bin/sh", "-c", "sysctl -n machdep.cpu.brand_string" + " | tr '\n' ' '"};
if (scriptid == 2)//cores
script = new String[]{"/bin/sh", "-c", "sysctl -n hw.ncpu" + " | tr '\n' ' '"};
if (scriptid == 3)//ram size
script = new String[]{"/bin/sh", "-c", "sysctl -n hw.memsize | awk '{print $1 / 1073741824}'" + " | tr '\n' ' '"};
if (scriptid == 4)//storage
// script = new String[]{ "/bin/sh", "-c", "echo Amilapwd1 | sudo -S hdparm -I /dev/sda |grep 'device size with M = 1000\\*1000' | awk '{print substr($0, index($0,$9))}' | awk -F'[\t(]' '{print $2}' | awk '{print substr($1,0)}'"+" | tr '\n' ' '"};
script = new String[]{"/bin/sh", "-c", "diskutil list | grep 'GUID_partition_scheme' | awk '{ print $3}' | sed 's/*//g' | awk '{s+=$0} END {print s}'" + " | tr '\n' ' '"};
if (scriptid == 5)//
script = new String[]{"/bin/sh", "-c", "echo " + suPassword + " | sudo -S hdparm -I /dev/sda |grep 'device size with M = 1000\\*1000' | awk '{print $0}' | awk -F'[\t(]' '{print $2}' | awk '{print substr($1,0)}'" + " | tr '\n' ' '"};
if (scriptid == 10)//processor usage
script = new String[]{"/bin/sh", "-c", "ps -A -o %cpu | awk '{s+=$1} END {print s}'" + " | tr '\n' ' '"};
if (scriptid == 11)//memory usage
script = new String[]{"/bin/sh", "-c", "free | grep Mem | awk '{print $3/$2 * 100.0}'" + " | tr '\n' ' '"};
if (scriptid == 12)//storage usage
script = new String[]{"/bin/sh", "-c", "df -h | grep -vE '^Filesystem' | awk '{ print $1\" \"$3\" \"$2 }' | grep \"/\" | awk 'NF{sum1+=$2} NF{sum2+=$3} END {print (sum1/sum2)*100}'" + " | tr '\n' ' '"};
if (scriptid == 13)//batttery percentage
script = new String[]{"/bin/sh", "-c", "pmset -g batt | grep \"InternalBattery\" | awk '{print $2}' | sed 's/%;//g'" + " | tr '\n' ' '"};
if (scriptid == 14)//charger plugged in
script = new String[]{"/bin/sh", "-c", "pmset -g batt | grep \"InternalBattery\" | awk '{print $3}' | sed 's/;//g' | awk '{ if($0==\"charging\"||$0==\"charged\") print 1; else print 0; }'" + " | tr '\n' ' '"};
}
} catch (Exception e) {
}

@ -16,7 +16,7 @@
* under the License.
*/
package org.wso2.connectedlap.plugin.impl.uti;
package org.wso2.connectedlap.plugin.impl.util;
public class ConnectedLapResponse {

@ -14,12 +14,25 @@
<div class="col-xs-12 col-sm-8 col-md-8 col-lg-8 padding-top">
<h3 class="uppercase">What it Does</h3>
<hr>
<p class="grey margin-top">Connect a CONNECTEDLAP to WSO2 IoT Server and manage it.</p>
<p>Add brief description what this device type does</p>
<p class="grey margin-top">Connect a computer with this application to WSO2 IoT Server and visualize usage data.</p>
<h3 class="uppercase">What You Need</h3>
<p>Add hardware requirement which will be required to make this device type </p>
<br>
<hr>
<p class="grey margin-top">You should have an Android Device to get started.</p>
<ul class="list-unstyled">
<li class="padding-top-double">
<span class="circle">STEP 01</span>
&nbsp;&nbsp;&nbsp;Go ahead and [Download] the Device.
</li>
<li class="padding-top-double">
<span class="circle">STEP 02</span>
&nbsp;&nbsp;&nbsp;Proceed to [Prepare] section.
</li>
<li class="padding-top-double">
<span class="circle">STEP 03</span>
&nbsp;&nbsp;&nbsp;Read [Try Out] section to further experiment with the device.
</li>
</ul>
<br>
<a href="/api-store/apis/info?name={{@uriParams.deviceType}}&version=1.0.0&provider=admin"
class="btn-operations"
@ -42,6 +55,11 @@
</div>
<div class="control-group">
<div class="controls">
<label for="sel1">Select OS Type</label>
<select class="form-control" name="osType" style="width:40%;margin-bottom:0.5%">
<option name="linux" value="linux">Ubuntu</option>
<option name="mac" value="mac">MacOS</option>
</select>
<input class="new-device-name" style="color:#3f3f3f;padding:5px"
type="text"
placeholder="Ex. Lobby_DigitalDisplay"
@ -151,46 +169,52 @@
<h3 class="uppercase">Prepare</h3>
<hr>
<ul class="list-unstyled">
<li class="padding-top-double"><span class="circle">01</span>&nbsp;&nbsp;&nbsp;Add how you are goining to
prepare your device
<li class="padding-top-double"><span class="circle">01</span>&nbsp;&nbsp;&nbsp;Download your Connectedlap using [Download Agent] button above.
</li>
<li class="padding-top-double"><span class="circle">02</span>&nbsp;&nbsp;&nbsp;Unzip the downloaded Agent.
</li>
<li class="padding-top-double"><span class="circle">03</span>&nbsp;&nbsp;&nbsp;Move into the unzipped Agent folder.
</li>
<li class="padding-top-double"><span class="circle">04</span>&nbsp;&nbsp;&nbsp;On terminal to run this command: [sudo sh startagent.sh].
</li>
<li class="padding-top-double"><span class="circle">05</span>&nbsp;&nbsp;&nbsp;Give the Super-Admin password.
</li>
</ul>
<br>
<br>
</div>
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 padding-double">
<h3 class="uppercase">Schematic Diagram</h3>
<hr>
<p class="grey margin-top">Click on the image to zoom</p>
<center>
<a href="{{@unit.publicUri}}/images/schematicsGuide.png" target="_blank">
<img src="{{@unit.publicUri}}/images/schematicsGuide.png" class="img-responsive">
</a>
</center>
<br/>
</div>
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 padding-double">
<h3 class="uppercase">Try Out</h3>
<hr>
<ul class="list-unstyled">
<li class="padding-top-double">
<span class="circle">01</span>
&nbsp;&nbsp;&nbsp;You can view all your connected devices at
&nbsp;&nbsp;&nbsp;You can view all your connected devices at [Device Management] page.
<a href="{{@app.context}}/devices">[Device Management]</a> page.
</li>
<li class="padding-top-double">
<span class="circle">02</span>
&nbsp;&nbsp;&nbsp;Select one of connected devices and check for available control
operations and monitor Real-Time data.
&nbsp;&nbsp;&nbsp;Select one of connected devices and monitor Real-Time data.
</li>
<li class="padding-top-double">
<span class="circle">03</span>
&nbsp;&nbsp;&nbsp;You can also view analytics of the data published to IoT-Server by
navigating to Device Analytics page.
&nbsp;&nbsp;&nbsp;You can also view analytics of the data published to IoT-Server by navigating to Device Analytics page.
</li>
</ul>
<br/>
</div>
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 padding-double">
<h3 class="uppercase"></h3>
<br>
<hr>
<p class="grey margin-top">Click on the image to zoom</p>
<center>
<a href="{{@unit.publicUri}}/images/deviceview.png" target="_blank">
<img src="{{@unit.publicUri}}/images/deviceview.png" class="img-responsive">
</a>
</center>
<br/>
</div>
{{#zone "topCss"}}
<style type="text/css">

@ -27,6 +27,7 @@ https-ep=${HTTPS_EP}
auth-method=token
auth-token=${DEVICE_TOKEN}
refresh-token=${DEVICE_REFRESH_TOKEN}
os-type=${OS_TYPE}
push-interval=15

Loading…
Cancel
Save