From 7bc927fbd0adb993e2833bd1f1f7a11c6182ef19 Mon Sep 17 00:00:00 2001 From: dilanua Date: Fri, 19 Aug 2016 11:52:24 +0530 Subject: [PATCH] Removing obsolete constants from constants.js - UI --- .../jaggeryapps/devicemgt/api/user-api.jag | 4 ++-- .../app/modules/business-controllers/device.js | 14 ++++++++------ .../app/modules/business-controllers/group.js | 3 ++- .../modules/business-controllers/operation.js | 2 +- .../devicemgt/app/modules/constants.js | 9 --------- .../app/pages/cdmf.page.dashboard/dashboard.js | 16 ++++++++-------- 6 files changed, 21 insertions(+), 27 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/user-api.jag b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/user-api.jag index 22d2b74fc7..465e896181 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/user-api.jag +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/user-api.jag @@ -69,9 +69,9 @@ if (uriMatcher.match("/{context}/api/user/authenticate")) { apiWrapperUtil.setupTokenPairByPasswordGrantType(username, password); var permissions = userModule.getUIPermissions(); if (permissions.VIEW_DASHBOARD) { - response.sendRedirect(constants.WEB_APP_CONTEXT); + response.sendRedirect(devicemgtProps["appContext"]); } else { - response.sendRedirect(constants.WEB_APP_CONTEXT + "/devices"); + response.sendRedirect(devicemgtProps["appContext"] + "devices"); } }, function () { response.sendRedirect(devicemgtProps.appContext + "login?#auth-failed"); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js index 21360452c1..4b205346d9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js @@ -22,7 +22,7 @@ deviceModule = function () { var utility = require('/app/modules/utility.js').utility; var constants = require('/app/modules/constants.js'); - var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; // var ArrayList = Packages.java.util.ArrayList; @@ -244,7 +244,7 @@ deviceModule = function () { try { utility.startTenantFlow(carbonUser); //var url = mdmProps["httpsURL"] + "/mdm-admin/devices/view?type=" + deviceType + "&id=" + deviceId; - var url = mdmProps["httpsURL"] + "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId; + var url = devicemgtProps["httpsURL"] + "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId; return serviceInvokers.XMLHttp.get( url, function (backendResponse) { @@ -294,10 +294,11 @@ deviceModule = function () { var uiPermissions = userModule.getUIPermissions(); var url; if (uiPermissions.LIST_DEVICES) { - url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/count"; + url = devicemgtProps["httpsURL"] + + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/devices/count"; } else if (uiPermissions.LIST_OWN_DEVICES) { - url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/user/" + carbonUser.username - + "/count"; + url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + + "/devices/user/" + carbonUser.username + "/count"; } else { log.error("Access denied for user: " + carbonUser.username); return -1; @@ -351,7 +352,8 @@ deviceModule = function () { // }; publicMethods.getDevices = function (userName) { - var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/user/" + userName; + var url = devicemgtProps["httpsURL"] + + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/devices/user/" + userName; return serviceInvokers.XMLHttp.get( url, function (responsePayload) { for (var i = 0; i < responsePayload.length; i++) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js index 02b2198b48..fcbeea8a5a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js @@ -26,7 +26,8 @@ var groupModule = {}; var utility = require("/app/modules/utility.js").utility; var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; - var groupServiceEndpoint = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/groups"; + var groupServiceEndpoint = devicemgtProps["httpsURL"] + + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/groups"; var user = session.get(constants.USER_SESSION_KEY); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js index e96ffcdec1..6be734ec27 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js @@ -38,7 +38,7 @@ var operationModule = function () { } privateMethods.getOperationsFromFeatures = function (deviceType, operationType) { - var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/features/" + deviceType; + var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/features/" + deviceType; var featuresList = serviceInvokers.XMLHttp.get(url, function (responsePayload) { var features = responsePayload; var featureList = []; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js index 79aa46e5de..5cafff394d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js @@ -16,9 +16,6 @@ * under the License. */ -var WEB_APP_TITLE = "WSO2 CDM"; -var WEB_APP_CONTEXT = "/devicemgt"; -var ADMIN_SERVICE_CONTEXT = "/api/device-mgt/v1.0"; var USER_SESSION_KEY = "_UUF_USER"; var UNSPECIFIED = "Unspecified"; var httpURL = "httpURL"; @@ -72,12 +69,6 @@ var HTTP_GET = "GET"; var HTTP_POST = "POST"; var HTTP_PUT = "PUT"; var HTTP_DELETE = "DELETE"; -var REFERER = "referer" - -var GRANT_TYPE_PASSWORD = "password"; -var GRANT_TYPE_SAML = "saml"; - -var MQTT_QUEUE_CONFIG_NAME = "MQTT"; var HTTP_CONFLICT = 409; var HTTP_CREATED = 201; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.js index ec98554ce1..06ac10ba3a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.js @@ -16,25 +16,25 @@ * under the License. */ -function onRequest(context) { +function onRequest() { var constants = require("/app/modules/constants.js"); - var user = session.get(constants.USER_SESSION_KEY); var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var permissions = userModule.getUIPermissions(); var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; + var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; + var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"]; + var policyModule = require("/app/modules/business-controllers/policy.js")["policyModule"]; + + var user = session.get(constants["USER_SESSION_KEY"]); + var permissions = userModule.getUIPermissions(); if (!permissions.VIEW_DASHBOARD) { - response.sendRedirect(constants.WEB_APP_CONTEXT + "/devices"); + response.sendRedirect(devicemgtProps["appContext"] + "devices"); return; } var page = {}; page.permissions = permissions; page.enrollmentURL = devicemgtProps.enrollmentURL; - var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; - var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"]; - var policyModule = require("/app/modules/business-controllers/policy.js")["policyModule"]; - page.device_count = deviceModule.getDevicesCount(); page.group_count = groupModule.getGroupCount(); page.user_count = userModule.getUsers()["content"].length;