diff --git a/modules/distribution/src/assembly/bin.xml b/modules/distribution/src/assembly/bin.xml index 79ba06ab..4ce80ac7 100644 --- a/modules/distribution/src/assembly/bin.xml +++ b/modules/distribution/src/assembly/bin.xml @@ -730,6 +730,13 @@ 755 + + src/repository/jaggeryapps/portal/configs/designer.json + + ${pom.artifactId}-${pom.version}/repository/deployment/server/jaggeryapps/portal/configs + + 755 + diff --git a/modules/distribution/src/repository/jaggeryapps/portal/configs/designer.json b/modules/distribution/src/repository/jaggeryapps/portal/configs/designer.json new file mode 100644 index 00000000..9667a236 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/portal/configs/designer.json @@ -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": "" + } +} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/ues/configs/designer.json b/modules/distribution/src/repository/jaggeryapps/ues/configs/designer.json deleted file mode 100644 index a35c8441..00000000 --- a/modules/distribution/src/repository/jaggeryapps/ues/configs/designer.json +++ /dev/null @@ -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": "" - } -} diff --git a/modules/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.hbs b/modules/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.hbs index b20a79d8..9632b931 100644 --- a/modules/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.hbs +++ b/modules/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.hbs @@ -1,34 +1,10 @@ - -
-
- Temperature -
-
-
-
-
-
-
-
-
+ -
- Coffee Level - -
-
-
-
-
-
-
-
-
-
+ {{#zone "bottomJs"}} {{js "js/connectedcup.js"}} -{{/zone}} +{{/zone}} \ No newline at end of file diff --git a/modules/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.js b/modules/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.js index 2583a548..5263fa38 100644 --- a/modules/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.js +++ b/modules/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.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!"); diff --git a/modules/samples/connectedlap/component/api/src/main/java/org.wso2/connectedlap/api/DeviceTypeService.java b/modules/samples/connectedlap/component/api/src/main/java/org.wso2/connectedlap/api/DeviceTypeService.java index 438f4453..9f15b66c 100644 --- a/modules/samples/connectedlap/component/api/src/main/java/org.wso2/connectedlap/api/DeviceTypeService.java +++ b/modules/samples/connectedlap/component/api/src/main/java/org.wso2/connectedlap/api/DeviceTypeService.java @@ -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); } \ No newline at end of file diff --git a/modules/samples/connectedlap/component/api/src/main/java/org.wso2/connectedlap/api/DeviceTypeServiceImpl.java b/modules/samples/connectedlap/component/api/src/main/java/org.wso2/connectedlap/api/DeviceTypeServiceImpl.java index 16a743e7..1750f844 100644 --- a/modules/samples/connectedlap/component/api/src/main/java/org.wso2/connectedlap/api/DeviceTypeServiceImpl.java +++ b/modules/samples/connectedlap/component/api/src/main/java/org.wso2/connectedlap/api/DeviceTypeServiceImpl.java @@ -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; } } diff --git a/modules/samples/connectedlap/component/api/src/main/java/org.wso2/connectedlap/api/util/ZipUtil.java b/modules/samples/connectedlap/component/api/src/main/java/org.wso2/connectedlap/api/util/ZipUtil.java index 4a747fa7..c40a9d23 100644 --- a/modules/samples/connectedlap/component/api/src/main/java/org.wso2/connectedlap/api/util/ZipUtil.java +++ b/modules/samples/connectedlap/component/api/src/main/java/org.wso2/connectedlap/api/util/ZipUtil.java @@ -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); diff --git a/modules/samples/connectedlap/component/laptopagent/src/main/java/org/wso2/agent/datasense/PushSystemUsage.java b/modules/samples/connectedlap/component/laptopagent/src/main/java/org/wso2/agent/datasense/PushSystemUsage.java index df4560b4..1f135b81 100644 --- a/modules/samples/connectedlap/component/laptopagent/src/main/java/org/wso2/agent/datasense/PushSystemUsage.java +++ b/modules/samples/connectedlap/component/laptopagent/src/main/java/org/wso2/agent/datasense/PushSystemUsage.java @@ -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; } } } diff --git a/modules/samples/connectedlap/component/laptopagent/src/main/java/org/wso2/agent/main/JavaApp.java b/modules/samples/connectedlap/component/laptopagent/src/main/java/org/wso2/agent/main/JavaApp.java index f101605a..57cfd650 100644 --- a/modules/samples/connectedlap/component/laptopagent/src/main/java/org/wso2/agent/main/JavaApp.java +++ b/modules/samples/connectedlap/component/laptopagent/src/main/java/org/wso2/agent/main/JavaApp.java @@ -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; } } diff --git a/modules/samples/connectedlap/component/laptopagent/src/main/java/org/wso2/agent/resourcemonitor/infocollector/Collector.java b/modules/samples/connectedlap/component/laptopagent/src/main/java/org/wso2/agent/resourcemonitor/infocollector/Collector.java index ca798686..74a1e059 100644 --- a/modules/samples/connectedlap/component/laptopagent/src/main/java/org/wso2/agent/resourcemonitor/infocollector/Collector.java +++ b/modules/samples/connectedlap/component/laptopagent/src/main/java/org/wso2/agent/resourcemonitor/infocollector/Collector.java @@ -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))); diff --git a/modules/samples/connectedlap/component/laptopagent/src/main/java/org/wso2/agent/resourcemonitor/systembridge/BashRunner.java b/modules/samples/connectedlap/component/laptopagent/src/main/java/org/wso2/agent/resourcemonitor/systembridge/BashRunner.java index 6f70ffb1..d7eb716b 100644 --- a/modules/samples/connectedlap/component/laptopagent/src/main/java/org/wso2/agent/resourcemonitor/systembridge/BashRunner.java +++ b/modules/samples/connectedlap/component/laptopagent/src/main/java/org/wso2/agent/resourcemonitor/systembridge/BashRunner.java @@ -43,29 +43,55 @@ public class BashRunner { private String[] getScript(String os, int scriptid,String suPassword) throws OperationalException { String script[] = null; try { - 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) - script = new String[]{ "/bin/sh", "-c", "cat /proc/cpuinfo |grep 'model name' | uniq | awk '{print substr($0, index($0,$4))}'"+" | tr '\n' ' '"}; - if(scriptid==2) - script = new String[]{ "/bin/sh", "-c", "cat /proc/cpuinfo |grep 'cpu cores' | awk '{print substr($0, index($0,$4))}' | xargs | sed -e 's/\\ /+/g' | bc"+" | tr '\n' ' '"}; - if(scriptid==3) - script = new String[]{ "/bin/sh", "-c", "echo "+suPassword+" | sudo -S dmidecode -t 17 | grep 'Size.*MB' | awk '{s+=$2} END {print s / 1024}'"+" | tr '\n' ' '"}; - if(scriptid==4) + 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) + script = new String[]{"/bin/sh", "-c", "cat /proc/cpuinfo |grep 'model name' | uniq | awk '{print substr($0, index($0,$4))}'" + " | tr '\n' ' '"}; + if (scriptid == 2) + script = new String[]{"/bin/sh", "-c", "cat /proc/cpuinfo |grep 'cpu cores' | awk '{print substr($0, index($0,$4))}' | xargs | sed -e 's/\\ /+/g' | bc" + " | tr '\n' ' '"}; + if (scriptid == 3) + script = new String[]{"/bin/sh", "-c", "echo " + suPassword + " | sudo -S dmidecode -t 17 | grep 'Size.*MB' | awk '{s+=$2} END {print s / 1024}'" + " | tr '\n' ' '"}; + if (scriptid == 4) // 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", "echo "+suPassword+" | sudo -S fdisk -l | grep 'Disk /dev/sda' | awk '{print $3}'"+" | 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) - script = new String[]{ "/bin/sh", "-c", "top -b -n2 | grep 'Cpu(s)' | tail -n 1 | awk '{print $2 + $4}'"+" | tr '\n' ' '"}; - if(scriptid==11) - script = new String[]{ "/bin/sh", "-c", "free | grep Mem | awk '{print $3/$2 * 100.0}'"+" | tr '\n' ' '"}; - if(scriptid==12) - 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) - 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' ' '"}; + script = new String[]{"/bin/sh", "-c", "echo " + suPassword + " | sudo -S fdisk -l | grep 'Disk /dev/sda' | awk '{print $3}'" + " | 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) + script = new String[]{"/bin/sh", "-c", "top -b -n2 | grep 'Cpu(s)' | tail -n 1 | awk '{print $2 + $4}'" + " | tr '\n' ' '"}; + if (scriptid == 11) + script = new String[]{"/bin/sh", "-c", "free | grep Mem | awk '{print $3/$2 * 100.0}'" + " | tr '\n' ' '"}; + if (scriptid == 12) + 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) + 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) { } diff --git a/modules/samples/connectedlap/component/plugin/src/main/java/org.wso2/connectedlap/plugin/impl/util/ConnectedLapResponse.java b/modules/samples/connectedlap/component/plugin/src/main/java/org.wso2/connectedlap/plugin/impl/util/ConnectedLapResponse.java index 1a60033d..4694e6ce 100644 --- a/modules/samples/connectedlap/component/plugin/src/main/java/org.wso2/connectedlap/plugin/impl/util/ConnectedLapResponse.java +++ b/modules/samples/connectedlap/component/plugin/src/main/java/org.wso2/connectedlap/plugin/impl/util/ConnectedLapResponse.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.connectedlap.plugin.impl.uti; +package org.wso2.connectedlap.plugin.impl.util; public class ConnectedLapResponse { diff --git a/modules/samples/connectedlap/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.CONNECTEDLAP.type-view/public/images/deviceview.png b/modules/samples/connectedlap/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.CONNECTEDLAP.type-view/public/images/deviceview.png new file mode 100644 index 00000000..7554275b Binary files /dev/null and b/modules/samples/connectedlap/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.CONNECTEDLAP.type-view/public/images/deviceview.png differ diff --git a/modules/samples/connectedlap/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.CONNECTEDLAP.type-view/type-view.hbs b/modules/samples/connectedlap/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.CONNECTEDLAP.type-view/type-view.hbs index 31b5d9a6..447e1374 100644 --- a/modules/samples/connectedlap/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.CONNECTEDLAP.type-view/type-view.hbs +++ b/modules/samples/connectedlap/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.CONNECTEDLAP.type-view/type-view.hbs @@ -14,12 +14,25 @@

What it Does


-

Connect a CONNECTEDLAP to WSO2 IoT Server and manage it.

-

Add brief description what this device type does

+

Connect a computer with this application to WSO2 IoT Server and visualize usage data.

+

What You Need

-

Add hardware requirement which will be required to make this device type

-

+

You should have an Android Device to get started.

+
+ + Prepare
    -
  • 01   Add how you are goining to - prepare your device +
  • 01   Download your Connectedlap using [Download Agent] button above. +
  • +
  • 02   Unzip the downloaded Agent. +
  • +
  • 03   Move into the unzipped Agent folder. +
  • +
  • 04   On terminal to run this command: [sudo sh startagent.sh]. +
  • +
  • 05   Give the Super-Admin password.


-

Try Out


  • 01 -    You can view all your connected devices at +    You can view all your connected devices at [Device Management] page. [Device Management] page.
  • 02 -    Select one of connected devices and check for available control - operations and monitor Real-Time data. +    Select one of connected devices and monitor Real-Time data.
  • 03 -    You can also view analytics of the data published to IoT-Server by - navigating to Device Analytics page. +    You can also view analytics of the data published to IoT-Server by navigating to Device Analytics page.

+
+

+
+
+

Click on the image to zoom

+
+ + + +
+
+
{{#zone "topCss"}}