From fd9c49163732163ae492a263411225ed035d7ff9 Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Thu, 22 Sep 2016 18:10:27 +0530 Subject: [PATCH 01/13] Fixing virtual firealarm device download modal issue --- .../public/js/download.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/js/download.js b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/js/download.js index 9e5978774..991796825 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/js/download.js +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/js/download.js @@ -16,9 +16,9 @@ * under the License. */ -var modalPopup = ".wr-modalpopup"; -var modalPopupContainer = modalPopup + " .modalpopup-container"; -var modalPopupContent = modalPopup + " .modalpopup-content"; +var modalPopup = ".modal"; +var modalPopupContainer = modalPopup + " .modal-content"; +var modalPopupContent = modalPopup + " .modal-content"; var body = "body"; /* From 9cef6f0d8cbc19532e3409452736973e9a8104ca Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Mon, 26 Sep 2016 11:18:22 +0530 Subject: [PATCH 02/13] Few Fixes to the virtual firealarm analytics view. --- .../analytics-view.js | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.js b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.js index e4b0e14b0..64d5a078c 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.js +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.js @@ -18,27 +18,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["wssURL"].replace("https", "wss"); - var jwtService = carbon.server.osgiService('org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService'); + var jwtService = carbonServer.osgiService( + 'org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService'); var jwtClient = jwtService.getJWTClient(); - var encodedClientKeys = session.get(constants.ENCODED_CLIENT_KEYS_IDENTIFIER); + var encodedClientKeys = session.get(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"]); if (encodedClientKeys) { - var tokenUtil = require("/app/modules/util.js").util; - var resp = tokenUtil.decode(encodedClientKeys).split(","); - var user = session.get(constants.USER_SESSION_KEY); - var deviceParam = "{\"scope\":\"stats\",\"deviceIdentifiers\":[{\"id\":\""+device.deviceIdentifier+" \", \"type\":\""+device.type+"\"}]}"; + var tokenUtil = require("/app/modules/oauth/token-handler-utils.js")["utils"]; + var resp = tokenUtil.decode(encodedClientKeys).split(":"); + log.error(resp); + var deviceParam = "{\"scope\":\"stats\",\"deviceIdentifiers\":[{\"id\":\"" + device.deviceIdentifier + + " \", \"type\":\"" + device.type + "\"}]}"; var encodedScope = tokenUtil.encode(deviceParam); - var tokenPair = jwtClient.getAccessToken(resp[0], resp[1], user.username, null, - "{\"device\": \"" +encodedScope+"\"}"); + var tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username, + "{\"device\": \"" + encodedScope + "\"}"); var token = ""; if (tokenPair) { token = tokenPair.accessToken; } websocketEndpoint = websocketEndpoint + "/secured-outputui/org.wso2.iot.devices.temperature/1.0.0?" + - "token=" + token + "&deviceId=" + device.deviceIdentifier + "&deviceType=" + device.type; + "token=" + token + "&deviceId=" + device.deviceIdentifier + "&deviceType=" + device.type; } - return {"device": device, "websocketEndpoint" : websocketEndpoint}; + return {"device": device, "websocketEndpoint": websocketEndpoint}; } \ No newline at end of file From 52dfcecb629958de4c50d4395a0818cff7369e20 Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Mon, 26 Sep 2016 15:58:00 +0530 Subject: [PATCH 03/13] Updating devicemgt_admin into /api/device-mgt/v1.0. --- .../public/js/platform-configuration.js | 8 +- .../public/js/platform-configuration.js | 6 +- .../public/js/policy-edit.js | 10 +- .../public/js/policy-view.js | 2 +- .../public/js/policy-create.js | 10 +- .../public/js/platform-configuration.js | 6 +- .../public/js/platform-configuration.js | 6 +- .../public/js/device-detail.js | 268 +++++++++++++-- .../public/js/policy-create.js | 8 +- .../emm-web-agent/app/modules/constants.js | 2 +- .../public/js/device-detail.js | 318 +++++++++++------- 11 files changed, 470 insertions(+), 174 deletions(-) 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.platform.configuration/public/js/platform-configuration.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.platform.configuration/public/js/platform-configuration.js index fba0c0d83..950b6c500 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.platform.configuration/public/js/platform-configuration.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.platform.configuration/public/js/platform-configuration.js @@ -18,7 +18,7 @@ $(document).ready(function () { invokerUtil.get( - "/devicemgt_admin/configuration", + "/api/device-mgt/android_sense/v1.0/configuration", function (data) { data = JSON.parse(data); if (data && data.configuration) { @@ -52,7 +52,7 @@ var addConfiguration = function () { var errorMsgWrapper = "#android_sense-config-error-msg"; var errorMsg = "#android_sense-config-error-msg span"; var addConfigFormData = {}; - var configList = new Array(); + var configList = []; var mqttEp = $("input#mqtt-endpoint").val(); var mqttConfig = { "name": "ANDROID_SENSE_MQTT_EP", @@ -61,10 +61,10 @@ var addConfiguration = function () { }; configList.push(mqttConfig); - addConfigFormData.type = "android_sense" + addConfigFormData.type = "android_sense"; addConfigFormData.configuration = configList; - var addConfigAPI = "/devicemgt_admin/configuration"; + var addConfigAPI = "/api/device-mgt/android_sense/v1.0/configuration"; invokerUtil.post( addConfigAPI, addConfigFormData, diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.platform.configuration/public/js/platform-configuration.js b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.platform.configuration/public/js/platform-configuration.js index 202eefaa3..b2f6a8fd5 100644 --- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.platform.configuration/public/js/platform-configuration.js +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.platform.configuration/public/js/platform-configuration.js @@ -18,7 +18,7 @@ $(document).ready(function () { invokerUtil.get( - "/devicemgt_admin/configuration", + "/api/device-mgt/arduino/v1.0/configuration", function (data) { data = JSON.parse(data); if (data && data.configuration) { @@ -69,10 +69,10 @@ var addConfiguration = function () { configList.push(httpConfig); configList.push(httpsConfig); - addConfigFormData.type = "arduino" + addConfigFormData.type = "arduino"; addConfigFormData.configuration = configList; - var addConfigAPI = "/devicemgt_admin/configuration"; + var addConfigAPI = "/api/device-mgt/arduino/v1.0/configuration"; invokerUtil.post( addConfigAPI, addConfigFormData, diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/public/js/policy-edit.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/public/js/policy-edit.js index d42dd0109..edea5b06d 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/public/js/policy-edit.js +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/public/js/policy-edit.js @@ -248,7 +248,7 @@ var updatePolicy = function (policy, state) { payload["roles"] = []; } - var serviceURL = "/devicemgt_admin/policies/" + getParameterByName("id"); + var serviceURL = "/api/device-mgt/v1.0/policies/" + getParameterByName("id"); invokerUtil.put( serviceURL, payload, @@ -257,7 +257,7 @@ var updatePolicy = function (policy, state) { if (state == "save"){ var policyList = []; policyList.push(getParameterByName("id")); - serviceURL = "/devicemgt_admin/policies/inactivate"; + serviceURL = "/api/device-mgt/v1.0/policies/inactivate"; invokerUtil.put( serviceURL, policyList, @@ -274,7 +274,7 @@ var updatePolicy = function (policy, state) { }else if(state == "publish"){ var policyList = []; policyList.push(getParameterByName("id")); - serviceURL = "/devicemgt_admin/policies/activate"; + serviceURL = "/api/device-mgt/v1.0/policies/activate"; invokerUtil.put( serviceURL, policyList, @@ -451,7 +451,7 @@ $(document).ready(function () { data: function (params) { var postData = {}; postData.actionMethod = "GET"; - postData.actionUrl = "/devicemgt_admin/users?q=ad"; + postData.actionUrl = "/api/device-mgt/v1.0/users?q=ad"; postData.actionPayload = JSON.stringify({ q: params.term, // search term page: params.page @@ -479,7 +479,7 @@ $(document).ready(function () { var policyPayloadObj; invokerUtil.get( - "/devicemgt_admin/policies/" + getParameterByName("id"), + "/api/device-mgt/v1.0/policies/" + getParameterByName("id"), // on success function (data) { data = JSON.parse(data); diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/public/js/policy-view.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/public/js/policy-view.js index 67e2c7f8a..ad5b87a5e 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/public/js/policy-view.js +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/public/js/policy-view.js @@ -111,7 +111,7 @@ $(document).ready(function () { var policyPayloadObj; invokerUtil.get( - "/devicemgt_admin/policies/" + getParameterByName("id"), + "/api/device-mgt/v1.0/policies/" + getParameterByName("id"), // on success function (data) { // console.log("success: " + JSON.stringify(data)); diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/public/js/policy-create.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/public/js/policy-create.js index 4c838a1c4..45e73a71e 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/public/js/policy-create.js +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/public/js/policy-create.js @@ -241,9 +241,9 @@ var savePolicy = function (policy, state) { var serviceURL; if (state == "save") { - serviceURL = "/devicemgt_admin/policies/inactive-policy" + serviceURL = "/api/device-mgt/v1.0/policies/inactive-policy" } else if (state == "publish") { - serviceURL = "/devicemgt_admin/policies/active-policy" + serviceURL = "/api/device-mgt/v1.0/policies/active-policy" } invokerUtil.post( serviceURL, @@ -414,7 +414,7 @@ $(document).ready(function () { data: function (params) { var postData = {}; postData.actionMethod = "GET"; - postData.actionUrl = "/devicemgt_admin/users"; + postData.actionUrl = "/api/device-mgt/v1.0/users"; postData.actionPayload = JSON.stringify({ q: params.term, // search term page: params.page @@ -442,7 +442,7 @@ $(document).ready(function () { templateSelection: formatRepoSelection // omitted for brevity, see the source of this page }); - $("#groups-input").select2({ + $("#groups-input").select2({ multiple: true, tags: true, ajax: { @@ -457,7 +457,7 @@ $(document).ready(function () { var postData = {}; postData.actionMethod = "GET"; var username = $("#platform").data("username"); - postData.actionUrl = "/devicemgt_admin/groups/user/" + username + + postData.actionUrl = "/api/device-mgt/v1.0/groups/user/" + username + "/search?groupName=" + params.term; return JSON.stringify(postData); }, diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.platform.configuration/public/js/platform-configuration.js b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.platform.configuration/public/js/platform-configuration.js index ca2136dbb..c82bba71b 100644 --- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.platform.configuration/public/js/platform-configuration.js +++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.platform.configuration/public/js/platform-configuration.js @@ -18,7 +18,7 @@ $(document).ready(function () { invokerUtil.get( - "/devicemgt_admin/configuration", + "/api/device-mgt/raspberrypi/v1.0/configuration", function (data) { data = JSON.parse(data); if (data && data.configuration) { @@ -79,10 +79,10 @@ var addConfiguration = function () { configList.push(httpConfig); configList.push(httpsConfig); configList.push(mqttConfig); - addConfigFormData.type = "raspberrypi" + addConfigFormData.type = "raspberrypi"; addConfigFormData.configuration = configList; - var addConfigAPI = "/devicemgt_admin/configuration"; + var addConfigAPI = "/api/device-mgt/raspberrypi/v1.0/configuration"; invokerUtil.post( addConfigAPI, addConfigFormData, diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.platform.configuration/public/js/platform-configuration.js b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.platform.configuration/public/js/platform-configuration.js index 57013c1a3..19f1c9ff3 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.platform.configuration/public/js/platform-configuration.js +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.platform.configuration/public/js/platform-configuration.js @@ -18,7 +18,7 @@ $(document).ready(function () { invokerUtil.get( - "/devicemgt_admin/configuration", + "/api/device-mgt/virtual_firealarm/v1.0/configuration", function (data) { data = JSON.parse(data); if (data && data.configuration) { @@ -69,10 +69,10 @@ var addConfiguration = function () { configList.push(httpConfig); configList.push(httpsConfig); configList.push(mqttConfig); - addConfigFormData.type = "virtual_firealarm" + addConfigFormData.type = "virtual_firealarm"; addConfigFormData.configuration = configList; - var addConfigAPI = "/devicemgt_admin/configuration"; + var addConfigAPI = "/api/device-mgt/virtual_firealarm/v1.0/configuration"; invokerUtil.post( addConfigAPI, addConfigFormData, diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/public/js/device-detail.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/public/js/device-detail.js index 49c3512b9..20cf3c165 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/public/js/device-detail.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/public/js/device-detail.js @@ -21,57 +21,265 @@ var deviceIdentifier = deviceId.data("deviceid"); var deviceType = deviceId.data("type"); var payload = [deviceIdentifier]; - var serviceUrl = "/mdm-android-agent/operation/device-info"; - invokerUtil.post(serviceUrl, payload, - function (message) { - console.log(message); - }, function (message) { - console.log(message); - }); + var operationTable; + if (deviceType == "ios") { + serviceUrl = "/ios/operation/deviceinfo"; + } else if (deviceType == "android") { + //var serviceUrl = "/mdm-android-agent/operation/device-info"; + serviceUrl = "/api/device-mgt/android/v1.0/admin/devices/info"; + } + if (serviceUrl) { + invokerUtil.post(serviceUrl, payload, + function (message) { + console.log(message); + }, function (message) { + console.log(message); + }); + } $(document).ready(function () { $(".panel-body").removeClass("hidden"); $("#loading-content").remove(); + + loadOperationsLog(); loadApplicationsList(); + loadPolicyCompliance(); + + $("#refresh-policy").click(function () { + $('#policy-spinner').removeClass('hidden'); + loadPolicyCompliance(); + }); $("#refresh-apps").click(function () { $('#apps-spinner').removeClass('hidden'); loadApplicationsList(); }); + + $("#refresh-operations").click(function () { + $('#operations-spinner').removeClass('hidden'); + loadOperationsLog(true); + }); loadOperationBar(deviceType); }); + function loadOperationsLog(update) { + var operationsLogTable = "#operations-log-table"; + if (update) { + operationTable = $(operationsLogTable).DataTable(); + operationTable.ajax.reload(false); + return; + } + operationTable = $(operationsLogTable) + .datatables_extended({ + serverSide: true, + processing: false, + searching: false, + ordering: false, + pageLength: 10, + order: [], + ajax: { + url: context + "/api/operation/paginate", + data: { + deviceId: deviceIdentifier, + deviceType: deviceType + }, + dataSrc: function (json) { + $("#operations-spinner").addClass( + "hidden"); + $("#operations-log-container").empty(); + return json.data; + } + }, + columnDefs: [ + {targets: 0, data: "code"}, + { + targets: 1, + data: "status", + render: function (status) { + var html; + switch (status) { + case "COMPLETED" : + html = + " Completed"; + break; + case "PENDING" : + html = + " Pending"; + break; + case "ERROR" : + html = + " Error"; + break; + case "IN_PROGRESS" : + html = + " In Progress"; + break; + case "REPEATED" : + html = + " Repeated"; + break; + } + return html; + } + }, + { + targets: 2, + data: "createdTimeStamp", + render: function (date) { + var value = String(date); + return value.slice(0, 16); + } + } + ], + "createdRow": function (row, data) { + $(row).attr("data-type", "selectable"); + $(row).attr("data-id", data["id"]); + $.each($("td", row), + function (colIndex) { + switch (colIndex) { + case 1: + $(this).attr( + "data-grid-label", + "Code"); + $(this).attr( + "data-display", + data["code"]); + break; + case 2: + $(this).attr( + "data-grid-label", + "Status"); + $(this).attr( + "data-display", + data["status"]); + break; + case 3: + $(this).attr( + "data-grid-label", + "Created Timestamp"); + $(this).attr( + "data-display", + data["createdTimeStamp"]); + break; + } + } + ); + } + }); + } + function loadApplicationsList() { var applicationsList = $("#applications-list"); - var deviceListingSrc = applicationsList.attr("src"); + var applicationListingTemplate = applicationsList.attr("src"); var deviceId = applicationsList.data("device-id"); var deviceType = applicationsList.data("device-type"); - $.template("application-list", deviceListingSrc, function (template) { - var serviceURL = "/devicemgt_admin/operations/" + deviceType + "/" + deviceId + "/apps"; + $.template("application-list", applicationListingTemplate, function (template) { + var serviceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/applications"; + invokerUtil.get( + serviceURL, + // success-callback + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200 && data) { + data = JSON.parse(data); + $("#apps-spinner").addClass("hidden"); + if (data.length > 0) { + for (var i = 0; i < data.length; i++) { + data[i]["name"] = decodeURIComponent(data[i]["name"]); + data[i]["platform"] = deviceType; + } - var successCallback = function (data) { - data = JSON.parse(data); - $('#apps-spinner').addClass('hidden'); - var viewModel = {}; - if (data != null && data.length > 0) { - for (var i = 0; i < data.length; i++) { - data[i].name = data[i].name.replace(/[^\w\s]/gi, ' '); - data[i].name = data[i].name.replace(/[0-9]/g, ' '); + var viewModel = {}; + viewModel["applications"] = data; + viewModel["deviceType"] = deviceType; + var content = template(viewModel); + $("#applications-list-container").html(content); + } else { + $("#applications-list-container"). + html("

No applications found.

" + + "

Please try refreshing the list in a while.

"); + } } - } - viewModel.applications = data; - viewModel.deviceType = deviceType; - if (data.length > 0) { - var content = template(viewModel); - $("#applications-list-container").html(content); - } - - }; - invokerUtil.get(serviceURL, - successCallback, function (message) { - console.log(message); + }, + // error-callback + function () { + $("#applications-list-container"). + html("

 Loading application list " + + "was not successful. please try refreshing the list in a while.

"); }); }); } + function loadPolicyCompliance() { + var policyCompliance = $("#policy-view"); + var policyComplianceTemplate = policyCompliance.attr("src"); + var deviceId = policyCompliance.data("device-id"); + var deviceType = policyCompliance.data("device-type"); + var activePolicy = null; + + $.template( + "policy-view", + policyComplianceTemplate, + function (template) { + var getEffectivePolicyURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/effective-policy"; + var getDeviceComplianceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/compliance-data"; + + invokerUtil.get( + getEffectivePolicyURL, + // success-callback + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200 && data) { + data = JSON.parse(data); + $("#policy-spinner").addClass("hidden"); + if (data["active"] == true) { + activePolicy = data; + invokerUtil.get( + getDeviceComplianceURL, + // success-callback + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200 && data) { + var viewModel = {}; + viewModel["policy"] = activePolicy; + viewModel["deviceType"] = deviceType; + data = JSON.parse(data); + var content; + if (data["complianceData"]) { + if (data["complianceData"]["complianceFeatures"] && + data["complianceData"]["complianceFeatures"].length > 0) { + viewModel["compliance"] = "NON-COMPLIANT"; + viewModel["complianceFeatures"] = data["complianceData"]["complianceFeatures"]; + content = template(viewModel); + $("#policy-list-container").html(content); + } else { + viewModel["compliance"] = "COMPLIANT"; + content = template(viewModel); + $("#policy-list-container").html(content); + $("#policy-compliance-table").addClass("hidden"); + } + } else { + $("#policy-list-container"). + html("

This device " + + "has no policy applied.

"); + } + } + }, + // error-callback + function () { + $("#policy-list-container"). + html("

Loading policy compliance related data " + + "was not successful. please try refreshing data in a while.

"); + } + ); + } + } + }, + // error-callback + function () { + $("#policy-list-container"). + html("

Loading policy compliance related data " + + "was not successful. please try refreshing data in a while.

"); + } + ); + } + ); + } }()); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/public/js/policy-create.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/public/js/policy-create.js index a51ae295d..0f18bad58 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/public/js/policy-create.js +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/public/js/policy-create.js @@ -1822,13 +1822,13 @@ stepForwardFrom["policy-naming-publish"] = function () { policy["policyName"] = $("#policy-name-input").val(); policy["description"] = $("#policy-description-input").val(); //All data is collected. Policy can now be updated. - savePolicy(policy, "/devicemgt_admin/policies/active-policy"); + savePolicy(policy, "/api/device-mgt/v1.0/policies/active-policy"); }; stepForwardFrom["policy-naming"] = function () { policy["policyName"] = $("#policy-name-input").val(); policy["description"] = $("#policy-description-input").val(); //All data is collected. Policy can now be updated. - savePolicy(policy, "/devicemgt_admin/policies/inactive-policy"); + savePolicy(policy, "/api/device-mgt/v1.0/policies/inactive-policy"); }; var savePolicy = function (policy, serviceURL) { @@ -2058,9 +2058,9 @@ $(document).ready(function () { data: function (params) { var postData = {}; postData.actionMethod = "GET"; - postData.actionUrl = "/devicemgt_admin/users"; + postData.actionUrl = "/api/device-mgt/v1.0/users/search/usernames"; postData.actionPayload = JSON.stringify({ - q: params.term, // search term + filter: params.term, // search term page: params.page }); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/constants.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/constants.js index 862a66ce0..ee9c63977 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/constants.js +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/constants.js @@ -18,7 +18,7 @@ var WEB_APP_TITLE = "WSO2 CDM"; var WEB_APP_CONTEXT = "/devicemgt"; -var ADMIN_SERVICE_CONTEXT = "/devicemgt_admin"; +var ADMIN_SERVICE_CONTEXT = "/api/device-mgt/v1.0"; var USER_SESSION_KEY = "_UUF_USER"; var UNSPECIFIED = "Unspecified"; var httpURL = "httpURL"; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.device-view/public/js/device-detail.js b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.device-view/public/js/device-detail.js index aa2384fc3..5f9c788de 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.device-view/public/js/device-detail.js +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.device-view/public/js/device-detail.js @@ -23,9 +23,10 @@ var payload = [deviceIdentifier]; var operationTable; if (deviceType == "ios") { - var serviceUrl = "/ios/operation/deviceinfo"; + serviceUrl = "/ios/operation/deviceinfo"; } else if (deviceType == "android") { - var serviceUrl = "/mdm-android-agent/operation/device-info"; + //var serviceUrl = "/mdm-android-agent/operation/device-info"; + serviceUrl = "/api/device-mgt/android/v1.0/admin/devices/info"; } if (serviceUrl) { invokerUtil.post(serviceUrl, payload, @@ -61,137 +62,224 @@ }); function loadOperationsLog(update) { - var operationsLog = $("#operations-log"); - var deviceListingSrc = operationsLog.attr("src"); - var deviceId = operationsLog.data("device-id"); - var deviceType = operationsLog.data("device-type"); - - $.template("operations-log", deviceListingSrc, function (template) { - var serviceURL = "/devicemgt_admin/operations/" + deviceType + "/" + deviceId; - - var successCallback = function (data) { - data = JSON.parse(data); - $('#operations-spinner').addClass('hidden'); - var viewModel = {}; - viewModel.operations = data; - if (data.length > 0) { - var content = template(viewModel); - if (!update) { - $("#operations-log-container").html(content); - operationTable = $('#operations-log-table').datatables_extended(); - } else { - $('#operations-log-table').dataTable().fnClearTable(); - for (var i = 0; i < data.length; i++) { - var status; - if (data[i].status == "COMPLETED") { - status = " Completed"; - } else if (data[i].status == "PENDING") { - status = " Pending"; - } else if (data[i].status == "ERROR") { - status = " Error"; - } else if (data[i].status == "IN_PROGRESS") { - status = " In Progress"; - } - - $('#operations-log-table').dataTable().fnAddData([ - data[i].code, - status, - data[i].createdTimeStamp - ]); - } - } - } - - }; - invokerUtil.get(serviceURL, - successCallback, function (message) { - console.log(message); - }); - }); - + var operationsLogTable = "#operations-log-table"; + if (update) { + operationTable = $(operationsLogTable).DataTable(); + operationTable.ajax.reload(false); + return; + } + operationTable = $(operationsLogTable) + .datatables_extended({ + serverSide: true, + processing: false, + searching: false, + ordering: false, + pageLength: 10, + order: [], + ajax: { + url: context + "/api/operation/paginate", + data: { + deviceId: deviceIdentifier, + deviceType: deviceType + }, + dataSrc: function (json) { + $("#operations-spinner").addClass( + "hidden"); + $("#operations-log-container").empty(); + return json.data; + } + }, + columnDefs: [ + {targets: 0, data: "code"}, + { + targets: 1, + data: "status", + render: function (status) { + var html; + switch (status) { + case "COMPLETED" : + html = + " Completed"; + break; + case "PENDING" : + html = + " Pending"; + break; + case "ERROR" : + html = + " Error"; + break; + case "IN_PROGRESS" : + html = + " In Progress"; + break; + case "REPEATED" : + html = + " Repeated"; + break; + } + return html; + } + }, + { + targets: 2, + data: "createdTimeStamp", + render: function (date) { + var value = String(date); + return value.slice(0, 16); + } + } + ], + "createdRow": function (row, data) { + $(row).attr("data-type", "selectable"); + $(row).attr("data-id", data["id"]); + $.each($("td", row), + function (colIndex) { + switch (colIndex) { + case 1: + $(this).attr( + "data-grid-label", + "Code"); + $(this).attr( + "data-display", + data["code"]); + break; + case 2: + $(this).attr( + "data-grid-label", + "Status"); + $(this).attr( + "data-display", + data["status"]); + break; + case 3: + $(this).attr( + "data-grid-label", + "Created Timestamp"); + $(this).attr( + "data-display", + data["createdTimeStamp"]); + break; + } + } + ); + } + }); } - + function loadApplicationsList() { var applicationsList = $("#applications-list"); - var deviceListingSrc = applicationsList.attr("src"); + var applicationListingTemplate = applicationsList.attr("src"); var deviceId = applicationsList.data("device-id"); var deviceType = applicationsList.data("device-type"); - $.template("application-list", deviceListingSrc, function (template) { - var serviceURL = "/devicemgt_admin/operations/" + deviceType + "/" + deviceId + "/apps"; + $.template("application-list", applicationListingTemplate, function (template) { + var serviceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/applications"; + invokerUtil.get( + serviceURL, + // success-callback + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200 && data) { + data = JSON.parse(data); + $("#apps-spinner").addClass("hidden"); + if (data.length > 0) { + for (var i = 0; i < data.length; i++) { + data[i]["name"] = decodeURIComponent(data[i]["name"]); + data[i]["platform"] = deviceType; + } - var successCallback = function (data) { - data = JSON.parse(data); - $('#apps-spinner').addClass('hidden'); - var viewModel = {}; - if (data != null && data.length > 0) { - for (var i = 0; i < data.length; i++) { - data[i].name = data[i].name.replace(/[^\w\s]/gi, ' '); - data[i].name = data[i].name.replace(/[0-9]/g, ' '); + var viewModel = {}; + viewModel["applications"] = data; + viewModel["deviceType"] = deviceType; + var content = template(viewModel); + $("#applications-list-container").html(content); + } else { + $("#applications-list-container"). + html("

No applications found.

" + + "

Please try refreshing the list in a while.

"); + } } - } - viewModel.applications = data; - viewModel.deviceType = deviceType; - if (data.length > 0) { - var content = template(viewModel); - $("#applications-list-container").html(content); - } - - }; - invokerUtil.get(serviceURL, - successCallback, function (message) { - console.log(message); + }, + // error-callback + function () { + $("#applications-list-container"). + html("

 Loading application list " + + "was not successful. please try refreshing the list in a while.

"); }); }); } function loadPolicyCompliance() { var policyCompliance = $("#policy-view"); - var policySrc = policyCompliance.attr("src"); + var policyComplianceTemplate = policyCompliance.attr("src"); var deviceId = policyCompliance.data("device-id"); var deviceType = policyCompliance.data("device-type"); var activePolicy = null; - $.template("policy-view", policySrc, function (template) { - var serviceURLPolicy = "/devicemgt_admin/policies/" + deviceType + "/" + deviceId + "/active-policy" - var serviceURLCompliance = "/devicemgt_admin/policies/" + deviceType + "/" + deviceId; - - var successCallbackCompliance = function (data) { - var viewModel = {}; - viewModel.policy = activePolicy; - viewModel.deviceType = deviceType; - if (data != null && data.complianceFeatures != null && data.complianceFeatures != undefined && data.complianceFeatures.length > 0) { - viewModel.compliance = "NON-COMPLIANT"; - viewModel.complianceFeatures = data.complianceFeatures; - var content = template(viewModel); - $("#policy-list-container").html(content); - } else { - viewModel.compliance = "COMPLIANT"; - var content = template(viewModel); - $("#policy-list-container").html(content); - $("#policy-compliance-table").addClass("hidden"); - } - - }; - - var successCallbackPolicy = function (data) { - data = JSON.parse(data); - $('#policy-spinner').addClass('hidden'); - if (data != null && data.active == true) { - activePolicy = data; - invokerUtil.get(serviceURLCompliance, - successCallbackCompliance, function (message) { - console.log(message); - }); - } - }; - - invokerUtil.get(serviceURLPolicy, - successCallbackPolicy, function (message) { - console.log(message); - }); - }); + $.template( + "policy-view", + policyComplianceTemplate, + function (template) { + var getEffectivePolicyURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/effective-policy"; + var getDeviceComplianceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/compliance-data"; + invokerUtil.get( + getEffectivePolicyURL, + // success-callback + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200 && data) { + data = JSON.parse(data); + $("#policy-spinner").addClass("hidden"); + if (data["active"] == true) { + activePolicy = data; + invokerUtil.get( + getDeviceComplianceURL, + // success-callback + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200 && data) { + var viewModel = {}; + viewModel["policy"] = activePolicy; + viewModel["deviceType"] = deviceType; + data = JSON.parse(data); + var content; + if (data["complianceData"]) { + if (data["complianceData"]["complianceFeatures"] && + data["complianceData"]["complianceFeatures"].length > 0) { + viewModel["compliance"] = "NON-COMPLIANT"; + viewModel["complianceFeatures"] = data["complianceData"]["complianceFeatures"]; + content = template(viewModel); + $("#policy-list-container").html(content); + } else { + viewModel["compliance"] = "COMPLIANT"; + content = template(viewModel); + $("#policy-list-container").html(content); + $("#policy-compliance-table").addClass("hidden"); + } + } else { + $("#policy-list-container"). + html("

This device " + + "has no policy applied.

"); + } + } + }, + // error-callback + function () { + $("#policy-list-container"). + html("

Loading policy compliance related data " + + "was not successful. please try refreshing data in a while.

"); + } + ); + } + } + }, + // error-callback + function () { + $("#policy-list-container"). + html("

Loading policy compliance related data " + + "was not successful. please try refreshing data in a while.

"); + } + ); + } + ); } - }()); From 17dd96aa107c4683656213c4ba9e309fff1302a6 Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Mon, 26 Sep 2016 17:15:12 +0530 Subject: [PATCH 04/13] Returning correct representation of the device to template. --- .../analytics-view.js | 2 +- .../device-view.js | 2 +- .../analytics-view.js | 2 +- .../cdmf.unit.device.type.arduino.device-view/device-view.js | 2 +- .../analytics-view.js | 2 +- .../device-view.js | 2 +- .../analytics-view.js | 2 +- .../cdmf.unit.device.type.android.device-view/device-view.js | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) 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.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.analytics-view/analytics-view.js index 144acffcc..b66b910a2 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.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.analytics-view/analytics-view.js @@ -31,7 +31,7 @@ function onRequest(context) { var device = deviceModule.viewDevice(deviceType, deviceId); if (device && device.status != "error") { return { - "device": device, + "device": device.content, "backendApiUrl": devicemgtProps["httpsURL"] + "/android_sense/stats/" + deviceId + "/sensors/" }; } 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.device-view/device-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.device-view/device-view.js index 4df1abcff..fd445273c 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.device-view/device-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.device-view/device-view.js @@ -29,7 +29,7 @@ function onRequest(context) { var device = deviceModule.viewDevice(deviceType, deviceId); if (device && device.status != "error") { return { - "device": device, + "device": device.content, "backendApiUri": devicemgtProps["httpsURL"] + "/android_sense/", "autoCompleteParams": autoCompleteParams }; diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.js b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.js index ef49dbe96..af977cee5 100644 --- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.js +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.js @@ -33,7 +33,7 @@ function onRequest(context) { var device = deviceModule.viewDevice(deviceType, deviceId); if (device && device.status != "error") { return { - "device": device, + "device": device.content, "backendApiUri": devicemgtProps["httpsURL"] + "/arduino/device/stats/" + deviceId }; } else { diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.js b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.js index 3ec4bb34c..513b9a55c 100644 --- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.js +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.js @@ -28,7 +28,7 @@ function onRequest(context) { var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var device = deviceModule.viewDevice(deviceType, deviceId); if (device && device.status != "error") { - return {"device": device, "backendApiUri" : devicemgtProps["httpsURL"] + "/arduino/", "autoCompleteParams" : autoCompleteParams}; + return {"device": device.content, "backendApiUri" : devicemgtProps["httpsURL"] + "/arduino/", "autoCompleteParams" : autoCompleteParams}; } else { response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!"); exit(); diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.js b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.js index f9b7d0801..a8c012974 100644 --- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.js +++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.js @@ -33,7 +33,7 @@ function onRequest(context) { var device = deviceModule.viewDevice(deviceType, deviceId); if (device && device.status != "error") { return { - "device": device, + "device": device.content, "backendApiUri": devicemgtProps["httpsURL"] + "/raspberrypi/device/stats/" + deviceId }; } else { diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.js b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.js index 62305b58e..051344e70 100644 --- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.js +++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.js @@ -28,7 +28,7 @@ function onRequest(context) { var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var device = deviceModule.viewDevice(deviceType, deviceId); if (device && device.status != "error") { - return {"device": device, "backendApiUri" : devicemgtProps["httpsURL"] + "/raspberrypi/", "autoCompleteParams" : autoCompleteParams}; + return {"device": device.content, "backendApiUri" : devicemgtProps["httpsURL"] + "/raspberrypi/", "autoCompleteParams" : autoCompleteParams}; } else { response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!"); exit(); diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.js b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.js index 2e8285abf..b46b03385 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.js +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.js @@ -33,7 +33,7 @@ function onRequest(context) { var device = deviceModule.viewDevice(deviceType, deviceId); if (device && device.status != "error") { return { - "device": device, + "device": device.content, "backendApiUri": devicemgtProps["httpsURL"] + "/virtual_firealarm/device/stats/" + deviceId }; } else { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.js index 4407e222f..56c11ec66 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.js @@ -23,7 +23,7 @@ function onRequest(context) { if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; - var device = deviceModule.viewDevice(deviceType, deviceId); + var device = deviceModule.viewDevice(deviceType, deviceId)["content"]; if (device) { var viewModel = {}; From d8d69f3092a663ae2fca0b7d2785eb4aae9506a4 Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Mon, 26 Sep 2016 18:52:52 +0530 Subject: [PATCH 05/13] Updating modal name element --- .../public/js/download.js | 6 ++--- .../public/js/download.js | 6 ++--- .../public/js/download.js | 6 ++--- .../public/js/operation-bar.js | 22 ++++++++++--------- .../public/js/nav-menu.js | 7 +++--- 5 files changed, 25 insertions(+), 22 deletions(-) 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 78321cc26..831e47df2 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 @@ -16,9 +16,9 @@ * under the License. */ -var modalPopup = ".wr-modalpopup"; -var modalPopupContainer = modalPopup + " .modalpopup-container"; -var modalPopupContent = modalPopup + " .modalpopup-content"; +var modalPopup = ".modal"; +var modalPopupContainer = modalPopup + " .modal-content"; +var modalPopupContent = modalPopup + " .modal-content"; var body = "body"; /* diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/js/download.js b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/js/download.js index 37b7f34e3..3b104cd53 100644 --- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/js/download.js +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/js/download.js @@ -16,9 +16,9 @@ * under the License. */ -var modalPopup = ".wr-modalpopup"; -var modalPopupContainer = modalPopup + " .modalpopup-container"; -var modalPopupContent = modalPopup + " .modalpopup-content"; +var modalPopup = ".modal"; +var modalPopupContainer = modalPopup + " .modal-content"; +var modalPopupContent = modalPopup + " .modal-content"; var body = "body"; /* diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/js/download.js b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/js/download.js index afa50a3c7..f6b9f1e64 100644 --- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/js/download.js +++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/js/download.js @@ -16,9 +16,9 @@ * under the License. */ -var modalPopup = ".wr-modalpopup"; -var modalPopupContainer = modalPopup + " .modalpopup-container"; -var modalPopupContent = modalPopup + " .modalpopup-content"; +var modalPopup = ".modal"; +var modalPopupContainer = modalPopup + " .modal-content"; +var modalPopupContent = modalPopup + " .modal-content"; var body = "body"; /* diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/public/js/operation-bar.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/public/js/operation-bar.js index a3186092a..ba52347d0 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/public/js/operation-bar.js +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/public/js/operation-bar.js @@ -21,8 +21,8 @@ */ var operations = '.wr-operations', - modalPopup = '.wr-modalpopup', - modalPopupContent = modalPopup + ' .modalpopup-content', + modalPopup = '.modal', + modalPopupContent = modalPopup + ' .modal-content', navHeight = $('#nav').height(), headerHeight = $('header').height(), offset = (headerHeight + navHeight), @@ -43,9 +43,9 @@ function getSelectedDeviceIds() { var deviceId = device.data('deviceid'); var deviceType = device.data('type'); deviceIdentifierList.push({ - "id": deviceId, - "type": deviceType - }); + "id": deviceId, + "type": deviceType + }); }); if (deviceIdentifierList.length == 0) { var thisTable = $(".DTTT_selected").closest('.dataTables_wrapper').find('.dataTable').dataTable(); @@ -54,9 +54,9 @@ function getSelectedDeviceIds() { var deviceId = $(thisTable.api().row(this).node()).data('deviceid'); var deviceType = $(thisTable.api().row(this).node()).data('devicetype'); deviceIdentifierList.push({ - "id": deviceId, - "type": deviceType - }); + "id": deviceId, + "type": deviceType + }); } }); } @@ -172,14 +172,16 @@ function runOperation(operationName) { var payload, serviceEndPoint; if (list[platformTypeConstants.IOS]) { - payload = operationModule.generatePayload(platformTypeConstants.IOS, operationName, list[platformTypeConstants.IOS]); + payload = + operationModule.generatePayload(platformTypeConstants.IOS, operationName, list[platformTypeConstants.IOS]); serviceEndPoint = operationModule.getIOSServiceEndpoint(operationName); } else if (list[platformTypeConstants.ANDROID]) { payload = operationModule .generatePayload(platformTypeConstants.ANDROID, operationName, list[platformTypeConstants.ANDROID]); serviceEndPoint = operationModule.getAndroidServiceEndpoint(operationName); } else if (list[platformTypeConstants.WINDOWS]) { - payload = operationModule.generatePayload(platformTypeConstants.WINDOWS, operationName, list[platformTypeConstants.WINDOWS]); + payload = operationModule.generatePayload(platformTypeConstants.WINDOWS, operationName, + list[platformTypeConstants.WINDOWS]); serviceEndPoint = operationModule.getWindowsServiceEndpoint(operationName); } if (operationName == "NOTIFICATION") { diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.nav-menu/public/js/nav-menu.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.nav-menu/public/js/nav-menu.js index 8d76a953b..4d5a32481 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.nav-menu/public/js/nav-menu.js +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.nav-menu/public/js/nav-menu.js @@ -16,9 +16,10 @@ * under the License. */ -var modalPopup = ".wr-modalpopup", - modalPopupContainer = modalPopup + " .modalpopup-container", - modalPopupContent = modalPopup + " .modalpopup-content"; +var modalPopup = ".modal"; +var modalPopupContainer = modalPopup + " .modal-content"; +var modalPopupContent = modalPopup + " .modal-content"; +var body = "body"; var emmAdminBasePath = "/api/device-mgt/v1.0"; From 3f9bcd50ea70fbaca4ed50fa35551a3b2fed4f86 Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Mon, 26 Sep 2016 19:17:05 +0530 Subject: [PATCH 06/13] Correcting appContext=>@app.context, self.publicUri=>@unit.publicUri/@page.publicUri, currentUser.username=>@user.username --- .../devicemgt/app/pages/mdm.page.devices/devices.hbs | 2 +- .../app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.hbs | 6 +++--- .../app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.hbs | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.hbs index fa4688cda..f0199e6e0 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.hbs +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.hbs @@ -50,7 +50,7 @@ {{/if}} {{#if permissions.ADVANCED_SEARCH}}