diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java index a1307dfa6..f1483e417 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java @@ -20,8 +20,8 @@ package org.wso2.carbon.device.mgt.iot.androidsense.service.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.analytics.dataservice.commons.SORT; import org.wso2.carbon.analytics.dataservice.commons.SortByField; +import org.wso2.carbon.analytics.dataservice.commons.SortType; import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException; @@ -194,7 +194,7 @@ public class AndroidSenseServiceImpl implements AndroidSenseService { List sensorDatas; if (!sensor.equals(AndroidSenseConstants.SENSOR_WORDCOUNT)) { List sortByFields = new ArrayList<>(); - SortByField sortByField = new SortByField("time", SORT.ASC, false); + SortByField sortByField = new SortByField("time", SortType.ASC); sortByFields.add(sortByField); sensorDatas = APIUtil.getAllEventsForDevice(sensorTableName, query, sortByFields); } else { diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.js b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.js index 8d783f1ab..9bc4c8654 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.js +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.js @@ -17,16 +17,31 @@ */ function onRequest(context) { + var log = new Log("stats.js"); + var carbonServer = require("carbon").server; var device = context.unit.params.device; var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var constants = require("/app/modules/constants.js"); - var websocketEndpoint = devicemgtProps["httpsURL"].replace("https", "wss"); - var tokenPair = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER); - var token = ""; - if (tokenPair) { - token = tokenPair.accessToken; + + var websocketEndpoint = devicemgtProps["wssURL"].replace("https", "wss"); + var jwtService = carbonServer.osgiService( + 'org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService'); + var jwtClient = jwtService.getJWTClient(); + var encodedClientKeys = session.get(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"]); + if (encodedClientKeys) { + var tokenUtil = require("/app/modules/oauth/token-handler-utils.js")["utils"]; + var resp = tokenUtil.decode(encodedClientKeys).split(":"); + var deviceParam = "{\"scope\":\"stats\",\"deviceIdentifiers\":[{\"id\":\"" + device.deviceIdentifier + + "\", \"type\":\"" + device.type + "\"}]}"; + var encodedScope = tokenUtil.encode(deviceParam); + var tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username,"default", + {"device": encodedScope}); + var token = ""; + if (tokenPair) { + token = tokenPair.accessToken; + } + websocketEndpoint = websocketEndpoint + "/secured-outputui/org.wso2.iot.android.sense/1.0.0?" + + "token="+ token +"&deviceId=" + device.deviceIdentifier + "&deviceType=" + device.type; } - websocketEndpoint = websocketEndpoint + "/secured-outputui/org.wso2.iot.android.sense/1.0.0?" + - "token="+ token +"&deviceId=" + device.deviceIdentifier + "&deviceType=" + device.type; - return {"device": device, "websocketEndpoint" : websocketEndpoint}; + return {"device": device, "websocketEndpoint": websocketEndpoint}; } \ No newline at end of file diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/js/download.js b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/js/download.js index 831e47df2..c60366ed2 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/js/download.js +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/js/download.js @@ -35,27 +35,6 @@ function setPopupMaxHeight() { function showPopup() { $(modalPopup).modal('show'); setPopupMaxHeight(); - $('#downloadForm').validate({ - rules: { - deviceName: { - minlength: 4, - required: true - } - }, - highlight: function (element) { - $(element).closest('.control-group').removeClass('success').addClass('error'); - }, - success: function (element) { - $(element).closest('.control-group').removeClass('error').addClass('success'); - $('label[for=deviceName]').remove(); - } - }); - var deviceType = ""; - $('.deviceType').each(function () { - if (this.value != "") { - deviceType = this.value; - } - }); } /* @@ -81,22 +60,13 @@ function attachEvents() { * when a user clicks on "Download" link * on Device Management page in WSO2 DC Console. */ - $("a.download-link").click(function () { - $(modalPopupContent).html($('#download-device-modal-content').html()); - showPopup(); - var deviceName; - $("a#download-device-download-link").click(function () { - $('.new-device-name').each(function () { - if (this.value != "") { - deviceName = this.value; - } - }); - $('label[for=deviceName]').remove(); - }); - - $("a#download-device-cancel-link").click(function () { - hidePopup(); - }); - + $(".download-link").click(function(){ + toggleEnrollment(); }); + + function toggleEnrollment(){ + $(modalPopupContent).html($("#qr-code-modal").html()); + generateQRCode(modalPopupContent + " .qr-code"); + showPopup(); + } } \ No newline at end of file diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs index 8fb2ff97c..fc96f1cbb 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs @@ -60,21 +60,6 @@ Enroll Device

- -