diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/device-api.jag b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/device-api.jag index f566e62beb..2d19fd0256 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/device-api.jag +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/device-api.jag @@ -82,20 +82,17 @@ if (!user) { {deviceName} - from request **/ - var deviceManagerService = devicemgtProps["httpsURL"] + "/" + deviceType + "_mgt" + "/manager"; - var sketchDownloadEndPoint = deviceManagerService + "/device/" + sketchType + "/download"; + var sketchDownloadEndPoint = devicemgtProps["httpsURL"] + "/" + deviceType + "/devices/download"; deviceTypeConfig = utility.getDeviceTypeConfig(deviceType); if (deviceTypeConfig && deviceTypeConfig.deviceType.downloadAgentUri) { - sketchDownloadEndPoint = devicemgtProps["httpsURL"] + "/" + deviceType + "_mgt" + - "/" + deviceTypeConfig.deviceType.downloadAgentUri; + sketchDownloadEndPoint = deviceTypeConfig.deviceType.downloadAgentUri; } var tokenPair = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER); if (tokenPair) { - response.addHeader(constants.AUTHORIZATION_HEADER, constants.BEARER_PREFIX + - tokenPair.accessToken); - response.sendRedirect(sketchDownloadEndPoint + "?owner=" + user.username + "&deviceName=" + - deviceName); + response.addHeader(constants.AUTHORIZATION_HEADER, constants.BEARER_PREFIX + tokenPair.accessToken); + response.sendRedirect(sketchDownloadEndPoint + "?sketchType=" + sketchType + "&deviceName=" + + deviceName); } else { response.sendRedirect(devicemgtProps["httpsURL"] + "/devicemgt/login"); exit(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/device.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/device.js index bd7ca11999..b06a2e436a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/device.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/device.js @@ -33,8 +33,6 @@ deviceModule = function () { var ConfigOperation = Packages.org.wso2.carbon.device.mgt.core.operation.mgt.ConfigOperation; var CommandOperation = Packages.org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; - var deviceManagementService = utility.getDeviceManagementService(); - var publicMethods = {}; var privateMethods = {}; @@ -314,6 +312,54 @@ deviceModule = function () { } }; + // Refactored methods + publicMethods.getOwnDevicesCount = function () { + var carbonUser = session.get(constants.USER_SESSION_KEY); + var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/user/" + carbonUser.username + + "/count"; + return serviceInvokers.XMLHttp.get( + url, function (responsePayload) { + return responsePayload; + } + , + function (responsePayload) { + log.error(responsePayload); + return -1; + } + ); + }; + + publicMethods.getAllDevicesCount = function () { + var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/count"; + return serviceInvokers.XMLHttp.get( + url, function (responsePayload) { + return responsePayload; + } + , + function (responsePayload) { + log.error(responsePayload); + return -1; + } + ); + }; + + + publicMethods.getDeviceTypes = function () { + var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/types"; + return serviceInvokers.XMLHttp.get( + url, function (responsePayload) { + return responsePayload; + } + , + function (responsePayload) { + log.error(responsePayload); + return -1; + } + ); + }; + + //Old methods + //TODO: make sure these methods are updated /* @Updated */ @@ -348,36 +394,6 @@ deviceModule = function () { return result; }; - publicMethods.getOwnDevicesCount = function () { - var carbonUser = session.get(constants.USER_SESSION_KEY); - var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/user/" + carbonUser.username - + "/count"; - return serviceInvokers.XMLHttp.get( - url, function (responsePayload) { - return responsePayload; - } - , - function (responsePayload) { - log.error(responsePayload); - return -1; - } - ); - }; - - publicMethods.getAllDevicesCount = function () { - var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/count"; - return serviceInvokers.XMLHttp.get( - url, function (responsePayload) { - return responsePayload; - } - , - function (responsePayload) { - log.error(responsePayload); - return -1; - } - ); - }; - publicMethods.getAllPermittedDevices = function () { var groupModule = require("/app/modules/group.js").groupModule; @@ -405,11 +421,6 @@ deviceModule = function () { return result; }; - publicMethods.getDeviceTypes = function () { - var deviceTypesEndPoint = deviceCloudService + "/device/type/all"; - return get(deviceTypesEndPoint, {}, "json"); - }; - publicMethods.removeDevice = function (deviceType, deviceId) { var carbonUser = session.get(constants.USER_SESSION_KEY); if (!carbonUser) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js index 5cbc70cc2d..6ba12ac2bd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js @@ -25,10 +25,9 @@ function onRequest(context) { var viewModel = {}; var deviceModule = require("/app/modules/device.js").deviceModule; var utility = require("/app/modules/utility.js").utility; - var data = deviceModule.getDeviceTypes(); + var deviceTypes = deviceModule.getDeviceTypes(); - if (data.data) { - var deviceTypes = data.data; + if (deviceTypes) { var deviceTypesList = [], virtualDeviceTypesList = []; for (var i = 0; i < deviceTypes.length; i++) { @@ -43,13 +42,6 @@ function onRequest(context) { deviceTypeLabel = configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY]; } } - //deviceTypesList.push({ - // "hasCustTemplate": false, - // "deviceTypeLabel": deviceTypeLabel, - // "deviceTypeName": deviceTypes[i].name, - // "deviceCategory": deviceCategory, - // "deviceTypeId": deviceTypes[i].id - //}); if (deviceCategory == 'virtual'){ virtualDeviceTypesList.push({ "hasCustTemplate": false, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js index 41c1bf60d4..ba6f47c614 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js @@ -54,7 +54,7 @@ $(document).ready(function () { null, function (data) { data = JSON.parse(data); - if (data.statusCode == responseCodes["ACCEPTED"]) { + if (data.status == responseCodes["ACCEPTED"]) { $("#config-save-form").addClass("hidden"); location.href = redirectUrl; } else if (data == 500) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/public/js/bottomJs.js index 921cd3ea6e..aab53ca9ec 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/public/js/bottomJs.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/public/js/bottomJs.js @@ -150,7 +150,7 @@ $(document).ready(function () { updateRolePermissionAPI, updateRolePermissionData, function (jqXHR) { - if (JSON.parse(jqXHR).statusCode == 200 || jqXHR.status == 200) { + if (JSON.parse(jqXHR).status == 200 || jqXHR.status == 200) { // Refreshing with success message $("#role-create-form").addClass("hidden"); $("#role-created-msg").removeClass("hidden"); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/public/js/bottomJs.js index 8954dcc4f5..f8c42854cf 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/public/js/bottomJs.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/public/js/bottomJs.js @@ -109,7 +109,7 @@ function formatRepo (user) { } function formatRepoSelection (user) { - return user.username || user.text;; + return user.username || user.text; } $(document).ready(function () { @@ -188,7 +188,7 @@ $(document).ready(function () { addRoleAPI, addRoleFormData, function (jqXHR) { - if (JSON.parse(jqXHR).statusCode == 200 || jqXHR.status == 200) { + if (JSON.parse(jqXHR).status == 200 || jqXHR.status == 200) { // Clearing user input fields. $("input#rolename").val(""); $("#domain").val(""); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.create/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.create/public/js/bottomJs.js index 30f721274a..32c7106125 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.create/public/js/bottomJs.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.create/public/js/bottomJs.js @@ -175,9 +175,9 @@ $( "#userStore" ) if (data.errorMessage) { $(errorMsg).text("Selected user store prompted an error : " + data.errorMessage); $(errorMsgWrapper).removeClass("hidden"); - } else if (data["statusCode"] == 200) { + } else if (data["status"] == 200) { $("#roles").empty(); - for(i=0;i'+data.responseContent[i]+''); $('#roles').append(newOption); } @@ -254,7 +254,7 @@ $(document).ready(function () { if (data.errorMessage) { $(errorMsg).text("Selected user store prompted an error : " + data.errorMessage); $(errorMsgWrapper).removeClass("hidden"); - } else if (data["statusCode"] == 201) { + } else if (data["status"] == 201) { // Clearing user input fields. $("input#username").val(""); $("input#firstname").val(""); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.edit/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.edit/public/js/bottomJs.js index e45d626349..a8a2641eb8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.edit/public/js/bottomJs.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.edit/public/js/bottomJs.js @@ -232,7 +232,7 @@ $(document).ready(function () { addUserFormData, function (data) { data = JSON.parse(data); - if (data["statusCode"] == 201) { + if (data["status"] == 201) { // Clearing user input fields. $("input#username").val(""); $("input#firstname").val(""); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/public/js/listing.js index 513b1d04ac..90368be5b3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/public/js/listing.js @@ -198,14 +198,14 @@ function resetPassword(uname) { resetPasswordFormData, function (data) { // The success callback data = JSON.parse(data); - if (data.statusCode == 201) { + if (data.status == 201) { $(modalPopupContent).html($('#reset-password-success-content').html()); $("a#reset-password-success-link").click(function () { hidePopup(); }); } }, function (data) { // The error callback - if (data.statusCode == 400) { + if (data.status == 400) { $(errorMsg).text("Old password does not match with the provided value."); $(errorMsgWrapper).removeClass("hidden"); } else { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/public/templates/listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/public/templates/listing.hbs index fbdb929a90..6414e6de93 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/public/templates/listing.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/public/templates/listing.hbs @@ -33,7 +33,7 @@ {{#unequal adminUser username }} {{#if canRemove}} @@ -47,16 +47,11 @@ {{#unequal adminUser username }} {{#if canResetPassword}} - - - - -