From e125871de0cb4216da341a16257c643d5415f427 Mon Sep 17 00:00:00 2001 From: dilanua Date: Mon, 1 Aug 2016 22:42:53 +0530 Subject: [PATCH 1/3] Adding business-controllers to UI Modules --- .../resources/jaggeryapps/devicemgt/api/device-api.jag | 4 ++-- .../resources/jaggeryapps/devicemgt/api/policy-api.jag | 2 +- .../main/resources/jaggeryapps/devicemgt/api/user-api.jag | 4 ++-- .../app/modules/{ => business-controllers}/device.js | 4 ++-- .../app/modules/{ => business-controllers}/group.js | 4 ++-- .../app/modules/{ => business-controllers}/operation.js | 2 +- .../app/modules/{ => business-controllers}/policy.js | 2 +- .../app/modules/{ => business-controllers}/user.js | 2 +- .../resources/jaggeryapps/devicemgt/app/modules/init.js | 2 +- .../app/modules/oauth/token-protected-service-invokers.js | 2 +- .../devicemgt/app/pages/cdmf.page.dashboard/dashboard.js | 8 ++++---- .../devicemgt/app/pages/cdmf.page.devices/devices.js | 6 +++--- .../app/pages/cdmf.page.group.analytics/analytics.js | 2 +- .../devicemgt/app/pages/cdmf.page.groups/groups.js | 4 ++-- .../devicemgt/app/pages/cdmf.page.policies/policies.js | 4 ++-- .../devicemgt/app/pages/cdmf.page.user.create/create.js | 2 +- .../devicemgt/app/pages/cdmf.page.user.edit/edit.js | 2 +- .../devicemgt/app/pages/cdmf.page.user.view/view.js | 4 ++-- .../app/units/cdmf.unit.device.type.view/view.js | 2 +- .../app/units/cdmf.unit.device.types.listing/listing.js | 2 +- .../devicemgt/app/units/cdmf.unit.device.view/view.js | 2 +- .../app/units/cdmf.unit.notification.listing/listing.js | 2 +- .../cdmf.unit.platform.configuration/configuration.js | 4 ++-- .../devicemgt/app/units/cdmf.unit.policy.create/create.js | 2 +- .../app/units/cdmf.unit.policy.priority/priority.js | 2 +- .../devicemgt/app/units/cdmf.unit.role.create/create.js | 2 +- .../units/cdmf.unit.role.edit.permission/permission.js | 2 +- .../devicemgt/app/units/cdmf.unit.role.edit/edit.js | 2 +- .../devicemgt/app/units/cdmf.unit.role.listing/listing.js | 2 +- .../app/units/cdmf.unit.ui.navbar.nav-menu/nav-menu.js | 2 +- 30 files changed, 43 insertions(+), 43 deletions(-) rename components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/{ => business-controllers}/device.js (98%) rename components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/{ => business-controllers}/group.js (94%) rename components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/{ => business-controllers}/operation.js (98%) rename components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/{ => business-controllers}/policy.js (99%) rename components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/{ => business-controllers}/user.js (99%) 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 937d396885e..ecb9806b5d2 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 @@ -22,10 +22,10 @@ var uriMatcher = new URIMatcher(String(uri)); var log = new Log("api/device-api.jag"); var constants = require("/app/modules/constants.js"); -var deviceModule = require("/app/modules/device.js").deviceModule; +var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var utility = require("/app/modules/utility.js").utility; var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; -var userModule = require("/app/modules/user.js").userModule; +var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; 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/api/policy-api.jag b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/policy-api.jag index d2a2630be7b..5ae93fdde79 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/policy-api.jag +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/policy-api.jag @@ -27,7 +27,7 @@ var uriMatcher = new URIMatcher(String(uri)); var log = new Log("api/policy-api.jag"); var constants = require("/modules/constants.js"); -var policyModule = require("/modules/policy.js").policyModule; +var policyModule = require("/app/modules/business-controllers/group.js")["groupModule"]; var result; if (uriMatcher.match("/{context}/api/policies/update")) { 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 3c11d19fde6..212a0875394 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 @@ -24,8 +24,8 @@ var log = new Log("api/user-api.jag"); var constants = require("/app/modules/constants.js"); var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; -var userModule = require("/app/modules/user.js").userModule; -var deviceModule = require("/app/modules/device.js").deviceModule; +var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; +var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var utility = require("/app/modules/utility.js").utility; var apiWrapperUtil = require("/app/modules/oauth/token-handlers.js")["handlers"]; var util = require("/app/modules/oauth/token-handler-utils.js")["utils"]; 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/business-controllers/device.js similarity index 98% rename from components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/device.js rename to components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js index 071154584d1..4510106bad0 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/business-controllers/device.js @@ -18,7 +18,7 @@ var deviceModule; deviceModule = function () { - var log = new Log("/app/modules/device.js"); + var log = new Log("/app/modules/business-controllers/device.js"); var utility = require('/app/modules/utility.js').utility; var constants = require('/app/modules/constants.js'); @@ -261,7 +261,7 @@ deviceModule = function () { publicMethods.getDevicesCount = function () { var carbonUser = session.get(constants.USER_SESSION_KEY); if (carbonUser) { - var userModule = require("/app/modules/user.js").userModule; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var uiPermissions = userModule.getUIPermissions(); var url; if (uiPermissions.LIST_DEVICES) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/group.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js similarity index 94% rename from components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/group.js rename to components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js index c2567cec291..02b2198b48c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/group.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js @@ -18,9 +18,9 @@ var groupModule = {}; (function (groupModule) { - var log = new Log("/app/modules/group.js"); + var log = new Log("/app/modules/business-controllers/group.js"); - var userModule = require("/app/modules/user.js").userModule; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var constants = require('/app/modules/constants.js'); var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var utility = require("/app/modules/utility.js").utility; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/operation.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js similarity index 98% rename from components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/operation.js rename to components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js index 9f75d4eb171..e96ffcdec19 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/operation.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js @@ -17,7 +17,7 @@ */ var operationModule = function () { - var log = new Log("/app/modules/operation.js"); + var log = new Log("/app/modules/business-controllers/operation.js"); var utility = require('/app/modules/utility.js').utility; var constants = require('/app/modules/constants.js'); var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/policy.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/policy.js similarity index 99% rename from components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/policy.js rename to components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/policy.js index 998e6722d1d..6cc38a9bfe5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/policy.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/policy.js @@ -21,7 +21,7 @@ */ var policyModule; policyModule = function () { - var log = new Log("/app/modules/policy.js"); + var log = new Log("/app/modules/business-controllers/policy.js"); var constants = require('/app/modules/constants.js'); var utility = require("/app/modules/utility.js")["utility"]; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/user.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js similarity index 99% rename from components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/user.js rename to components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js index 29a7de73654..720cbc46292 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/user.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js @@ -20,7 +20,7 @@ * This module contains user and roles related functionality. */ var userModule = function () { - var log = new Log("/app/modules/user.js"); + var log = new Log("/app/modules/business-controllers/user.js"); var constants = require("/app/modules/constants.js"); var utility = require("/app/modules/utility.js")["utility"]; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js index 8e86f44ab86..d9f442cdd4e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js @@ -24,7 +24,7 @@ var carbonServer = new carbonModule.server.Server({ }); application.put("carbonServer", carbonServer); -var userModule = require("/app/modules/user.js")["userModule"]; +var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var utility = require("/app/modules/utility.js")["utility"]; var permissions = { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-protected-service-invokers.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-protected-service-invokers.js index 4994e160bff..fa71ce1475f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-protected-service-invokers.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-protected-service-invokers.js @@ -37,7 +37,7 @@ var invokers = function () { var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var constants = require("/app/modules/constants.js"); - var userModule = require("/app/modules/user.js")["userModule"]; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var tokenUtil = require("/app/modules/oauth/token-handlers.js")["handlers"]; /** 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 8681882f2e2..ec98554ce10 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 @@ -19,7 +19,7 @@ function onRequest(context) { var constants = require("/app/modules/constants.js"); var user = session.get(constants.USER_SESSION_KEY); - var userModule = require("/app/modules/user.js").userModule; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var permissions = userModule.getUIPermissions(); var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; @@ -31,9 +31,9 @@ function onRequest(context) { var page = {}; page.permissions = permissions; page.enrollmentURL = devicemgtProps.enrollmentURL; - var deviceModule = require("/app/modules/device.js").deviceModule; - var groupModule = require("/app/modules/group.js").groupModule; - var policyModule = require("/app/modules/policy.js").policyModule; + 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(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js index 085f1f5a694..15c9b131f70 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js @@ -18,8 +18,8 @@ function onRequest(context) { var constants = require("/app/modules/constants.js"); - var userModule = require("/app/modules/user.js").userModule; - var deviceModule = require("/app/modules/device.js").deviceModule; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; + var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var groupName = request.getParameter("groupName"); var groupOwner = request.getParameter("groupOwner"); @@ -42,7 +42,7 @@ function onRequest(context) { page.currentUser = currentUser; var deviceCount = 0; if (groupName && groupOwner) { - var groupModule = require("/app/modules/group.js").groupModule; + var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"]; deviceCount = groupModule.getGroupDeviceCount(groupName, groupOwner); } else { deviceCount = deviceModule.getDevicesCount(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.js index 563660dadb2..fe9a550516a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.js @@ -18,7 +18,7 @@ function onRequest(context) { var utility = require("/app/modules/utility.js").utility; - var groupModule = require("/app/modules/group.js").groupModule; + var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"]; var groupName = context.uriParams.name; var groupOwner = context.uriParams.owner; var devices = groupModule.getGroupDevices(groupName, groupOwner).data; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.js index 188a8fec1ae..532ce661c7a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.js @@ -17,8 +17,8 @@ */ function onRequest(context) { - var groupModule = require("/app/modules/group.js").groupModule; - var userModule = require("/app/modules/user.js").userModule; + var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"]; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var constants = require("/app/modules/constants.js"); var currentUser = session.get(constants.USER_SESSION_KEY); var page = {}; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.js index b21d376f06a..3f60618d849 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.js @@ -28,8 +28,8 @@ function onRequest(context) { } }); var page = {}; - var policyModule = require("/app/modules/policy.js")["policyModule"]; - var userModule = require("/app/modules/user.js")["userModule"]; + var policyModule = require("/app/modules/business-controllers/group.js")["groupModule"]; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var response = policyModule.getAllPolicies(); if (response["status"] == "success") { var policyListToView = response["content"]; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js index cbd0564b15e..4cba6f75c34 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js @@ -25,7 +25,7 @@ function onRequest(context) { //var log = new Log("/app/pages/cdmf.page.user.create server-side js"); - var userModule = require("/app/modules/user.js")["userModule"]; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var page = {}; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/edit.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/edit.js index 7037721ad92..a8eab037315 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/edit.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/edit.js @@ -17,7 +17,7 @@ */ function onRequest(context) { - var userModule = require("/app/modules/user.js").userModule; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var userName = request.getParameter("username"); var user = userModule.getUser(userName)["content"]; var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.js index 8b41bc8a366..ffb86426bba 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.js @@ -17,7 +17,7 @@ */ function onRequest(context) { - var userModule = require("/app/modules/user.js").userModule; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var username = request.getParameter("username"); var user = userModule.getUser(username)["content"]; var userModule = require("/app/modules/user.js")["userModule"]; @@ -38,7 +38,7 @@ function onRequest(context) { if (response["status"] == "success") { userRoles = response["content"]; } - var deviceModule = require("/app/modules/device.js").deviceModule; + var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; devices = deviceModule.getDevices(userName); } return {"user": user, "userRoles": userRoles, "devices": devices}; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.view/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.view/view.js index f003d47581d..fa599c37a7f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.view/view.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.view/view.js @@ -27,7 +27,7 @@ function onRequest (context) { } //For QR Code - var userModule = require("/app/modules/user.js").userModule; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var constants = require("/app/modules/constants.js"); var permissions = userModule.getUIPermissions(); var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"]; 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 fecc5228077..0ae0ed8a488 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 @@ -23,7 +23,7 @@ function onRequest(context) { var DTYPE_CONF_DEVICE_TYPE_LABEL_KEY = "label"; var viewModel = {}; - var deviceModule = require("/app/modules/device.js").deviceModule; + var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var utility = require("/app/modules/utility.js").utility; var deviceTypes = deviceModule.getDeviceTypes(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.js index d544e09b588..a3a0037dcb8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.js @@ -22,7 +22,7 @@ function onRequest(context) { var deviceId = request.getParameter("id"); if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { - var deviceModule = require("/app/modules/device.js").deviceModule; + var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var device = deviceModule.viewDevice(deviceType, deviceId); if (device) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.js index 50306cbfb3b..0086ba8e3e6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.js @@ -17,7 +17,7 @@ */ function onRequest(context){ - var userModule = require("/app/modules/user.js").userModule; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var constants = require("/app/modules/constants.js"); var permissions = []; if(userModule.isAuthorized("/permission/admin/device-mgt/emm-admin/notifications/list")){ diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.js index 749ee92c154..e34720df7b0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.js @@ -17,8 +17,8 @@ */ function onRequest(context) { - var utility = require("/app/modules/device.js").utility; - var deviceModule = require("/app/modules/device.js").deviceModule; + var utility = require("/app/modules/utility.js").utility; + var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; //get all device types var data = deviceModule.getDeviceTypes(); var deviceTypesArray = []; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js index 3e09ae185dc..cf46e20def5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js @@ -21,7 +21,7 @@ function onRequest(context) { var DTYPE_CONF_DEVICE_TYPE_LABEL_KEY = "label"; var utility = require("/app/modules/utility.js").utility; - var userModule = require("/app/modules/user.js")["userModule"]; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var types = {}; types["types"] = []; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.priority/priority.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.priority/priority.js index 7630df258ba..2ba2155ac20 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.priority/priority.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.priority/priority.js @@ -27,7 +27,7 @@ function onRequest(context) { return options.fn(this); } }); - var policyModule = require("/app/modules/policy.js")["policyModule"]; + var policyModule = require("/app/modules/business-controllers/group.js")["groupModule"]; var response = policyModule.getAllPolicies(); if (response["status"] == "success") { var policyListToView = response["content"]; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/create.js index 9e00dc32aa3..a65fa31e257 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/create.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/create.js @@ -23,7 +23,7 @@ * @returns {*} A context object that returns the dynamic state of this page to be presented */ function onRequest(context) { - var userModule = require("/app/modules/user.js")["userModule"]; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var response = userModule.getRoles(); if (response["status"] == "success") { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/permission.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/permission.js index a16f9a38bbe..6829dc21e30 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/permission.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit.permission/permission.js @@ -23,7 +23,7 @@ * @returns {*} A context object that returns the dynamic state of this page to be presented */ function onRequest(context) { - var userModule = require("/app/modules/user.js")["userModule"]; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var uri = request.getRequestURI(); var uriMatcher = new URIMatcher(String(uri)); var isMatched = uriMatcher.match("/{context}/roles/edit-role-permission/{rolename}"); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/edit.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/edit.js index 01a08da69f3..cf54af034e5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/edit.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/edit.js @@ -23,7 +23,7 @@ * @returns {*} A context object that returns the dynamic state of this page to be presented */ function onRequest(context) { - var userModule = require("/app/modules/user.js")["userModule"]; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var uri = request.getRequestURI(); var uriMatcher = new URIMatcher(String(uri)); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/listing.js index c5c67d10292..d908da5d2d3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/listing.js @@ -17,7 +17,7 @@ */ function onRequest(context) { - var userModule = require("/app/modules/user.js")["userModule"]; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var response = userModule.getUsers(); var users = {}; context["permissions"] = userModule.getUIPermissions(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/nav-menu.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/nav-menu.js index 3f4ede1774b..363d9688e64 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/nav-menu.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/nav-menu.js @@ -27,7 +27,7 @@ function onRequest(context) { return options.fn(this); } }); - var userModule = require("/app/modules/user.js")["userModule"]; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; var constants = require("/app/modules/constants.js"); var uiPermissions = userModule.getUIPermissions(); From c7f4bba8bf5bd22b1dc8eae30895967ca39720bb Mon Sep 17 00:00:00 2001 From: dilanua Date: Mon, 1 Aug 2016 22:45:30 +0530 Subject: [PATCH 2/3] Deprecating operation.js module from UI --- .../modules/business-controllers/operation.js | 234 +++++++++--------- 1 file changed, 119 insertions(+), 115 deletions(-) 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 e96ffcdec19..1e479286a90 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 @@ -16,119 +16,123 @@ * under the License. */ -var operationModule = function () { - var log = new Log("/app/modules/business-controllers/operation.js"); - var utility = require('/app/modules/utility.js').utility; - var constants = require('/app/modules/constants.js'); - var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; - var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; - - var publicMethods = {}; - var privateMethods = {}; - - /** - * This method reads the token from the Token client and return the access token. - * If the token pair s not set in the session this will send a redirect to the login page. - */ - function getAccessToken(deviceType, owner, deviceId) { - var TokenClient = Packages.org.wso2.carbon.device.mgt.iot.apimgt.TokenClient; - var accessTokenClient = new TokenClient(deviceType); - var accessTokenInfo = accessTokenClient.getAccessToken(owner, deviceId); - return accessTokenInfo.getAccess_token(); - } - - privateMethods.getOperationsFromFeatures = function (deviceType, operationType) { - var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/features/" + deviceType; - var featuresList = serviceInvokers.XMLHttp.get(url, function (responsePayload) { - var features = responsePayload; - var featureList = []; - var feature; - for (var i = 0; i < features.length; i++) { - feature = {}; - var analyticStreams = utility.getDeviceTypeConfig(deviceType)["analyticStreams"]; - if (analyticStreams) { - for (var stream in analyticStreams) { - if (analyticStreams[stream].name == features[i].name) { - feature.ui_unit = analyticStreams[stream].ui_unit; - break; - } - } - } - - feature["operation"] = features[i].code; - feature["name"] = features[i].name; - feature["description"] = features[i].description; - feature["deviceType"] = deviceType; - feature["params"] = []; - var metaData = features[i].metadataEntries; - if (metaData) { - for (var j = 0; j < metaData.length; j++) { - feature["params"].push(metaData[j].value); - } - featureList.push(feature); - } - } - return featureList; - }, function (responsePayload) { - var response = {}; - response["status"] = "error"; - return response; - } - ); - return featuresList; - }; - - publicMethods.getControlOperations = function (deviceType) { - var operations = privateMethods.getOperationsFromFeatures(deviceType, "operation"); - for (var op in operations) { - var iconPath = utility.getOperationIcon(deviceType, operations[op].operation); - if (iconPath) { - operations[op]["icon"] = iconPath; - } - } - return operations; - }; - - publicMethods.getMonitorOperations = function (deviceType) { - return privateMethods.getOperationsFromFeatures(deviceType, "monitor"); - }; - - publicMethods.handlePOSTOperation = function (deviceType, operation, deviceId, params) { - var user = session.get(constants.USER_SESSION_KEY); - var endPoint = devicemgtProps["httpsURL"] + '/' + deviceType + "/controller/" + operation; - var header = '{"owner":"' + user.username + '","deviceId":"' + deviceId + - '","protocol":"mqtt", "sessionId":"' + session.getId() + '", "' + - constants.AUTHORIZATION_HEADER + '":"' + constants.BEARER_PREFIX + - getAccessToken(deviceType, user.username, deviceId) + '"}'; - return post(endPoint, params, JSON.parse(header), "json"); - }; - - publicMethods.handleGETOperation = function (deviceType, operation, operationName, deviceId) { - var user = session.get(constants.USER_SESSION_KEY); - var endPoint = devicemgtProps["httpsURL"] + '/' + deviceType + "/controller/" + operation; - var header = '{"owner":"' + user.username + '","deviceId":"' + deviceId + - '","protocol":"mqtt", "' + constants.AUTHORIZATION_HEADER + '":"' + - constants.BEARER_PREFIX + getAccessToken(deviceType, user.username, deviceId) + - '"}'; - var result = get(endPoint, {}, JSON.parse(header), "json"); - if (result.data) { - var values = result.data.sensorValue.split(','); - if (operationName == 'gps') { - result.data.map = { - lat: parseFloat(values[0]), - lng: parseFloat(values[1]) - } - } else { - var sqSum = 0; - for (var v in values) { - sqSum += Math.pow(values[v], 2); - } - result.data[operationName] = Math.sqrt(sqSum); - } - delete result.data['sensorValue']; - } - return result; - }; +/* + @Deprecated New + */ - return publicMethods; -}(); \ No newline at end of file +//var operationModule = function () { +// var log = new Log("/app/modules/business-controllers/operation.js"); +// var utility = require('/app/modules/utility.js').utility; +// var constants = require('/app/modules/constants.js'); +// var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; +// var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; +// +// var publicMethods = {}; +// var privateMethods = {}; +// +// /** +// * This method reads the token from the Token client and return the access token. +// * If the token pair s not set in the session this will send a redirect to the login page. +// */ +// function getAccessToken(deviceType, owner, deviceId) { +// var TokenClient = Packages.org.wso2.carbon.device.mgt.iot.apimgt.TokenClient; +// var accessTokenClient = new TokenClient(deviceType); +// var accessTokenInfo = accessTokenClient.getAccessToken(owner, deviceId); +// return accessTokenInfo.getAccess_token(); +// } +// +// privateMethods.getOperationsFromFeatures = function (deviceType, operationType) { +// var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/features/" + deviceType; +// var featuresList = serviceInvokers.XMLHttp.get(url, function (responsePayload) { +// var features = responsePayload; +// var featureList = []; +// var feature; +// for (var i = 0; i < features.length; i++) { +// feature = {}; +// var analyticStreams = utility.getDeviceTypeConfig(deviceType)["analyticStreams"]; +// if (analyticStreams) { +// for (var stream in analyticStreams) { +// if (analyticStreams[stream].name == features[i].name) { +// feature.ui_unit = analyticStreams[stream].ui_unit; +// break; +// } +// } +// } +// +// feature["operation"] = features[i].code; +// feature["name"] = features[i].name; +// feature["description"] = features[i].description; +// feature["deviceType"] = deviceType; +// feature["params"] = []; +// var metaData = features[i].metadataEntries; +// if (metaData) { +// for (var j = 0; j < metaData.length; j++) { +// feature["params"].push(metaData[j].value); +// } +// featureList.push(feature); +// } +// } +// return featureList; +// }, function (responsePayload) { +// var response = {}; +// response["status"] = "error"; +// return response; +// } +// ); +// return featuresList; +// }; +// +// publicMethods.getControlOperations = function (deviceType) { +// var operations = privateMethods.getOperationsFromFeatures(deviceType, "operation"); +// for (var op in operations) { +// var iconPath = utility.getOperationIcon(deviceType, operations[op].operation); +// if (iconPath) { +// operations[op]["icon"] = iconPath; +// } +// } +// return operations; +// }; +// +// publicMethods.getMonitorOperations = function (deviceType) { +// return privateMethods.getOperationsFromFeatures(deviceType, "monitor"); +// }; +// +// publicMethods.handlePOSTOperation = function (deviceType, operation, deviceId, params) { +// var user = session.get(constants.USER_SESSION_KEY); +// var endPoint = devicemgtProps["httpsURL"] + '/' + deviceType + "/controller/" + operation; +// var header = '{"owner":"' + user.username + '","deviceId":"' + deviceId + +// '","protocol":"mqtt", "sessionId":"' + session.getId() + '", "' + +// constants.AUTHORIZATION_HEADER + '":"' + constants.BEARER_PREFIX + +// getAccessToken(deviceType, user.username, deviceId) + '"}'; +// return post(endPoint, params, JSON.parse(header), "json"); +// }; +// +// publicMethods.handleGETOperation = function (deviceType, operation, operationName, deviceId) { +// var user = session.get(constants.USER_SESSION_KEY); +// var endPoint = devicemgtProps["httpsURL"] + '/' + deviceType + "/controller/" + operation; +// var header = '{"owner":"' + user.username + '","deviceId":"' + deviceId + +// '","protocol":"mqtt", "' + constants.AUTHORIZATION_HEADER + '":"' + +// constants.BEARER_PREFIX + getAccessToken(deviceType, user.username, deviceId) + +// '"}'; +// var result = get(endPoint, {}, JSON.parse(header), "json"); +// if (result.data) { +// var values = result.data.sensorValue.split(','); +// if (operationName == 'gps') { +// result.data.map = { +// lat: parseFloat(values[0]), +// lng: parseFloat(values[1]) +// } +// } else { +// var sqSum = 0; +// for (var v in values) { +// sqSum += Math.pow(values[v], 2); +// } +// result.data[operationName] = Math.sqrt(sqSum); +// } +// delete result.data['sensorValue']; +// } +// return result; +// }; +// +// return publicMethods; +//}(); \ No newline at end of file From 9510554f67e26e88a75cbffc6353def7c78b205d Mon Sep 17 00:00:00 2001 From: kamidu Date: Tue, 2 Aug 2016 00:05:23 +0530 Subject: [PATCH 3/3] Fix the notification view internal server error issue --- .../public/js/notification-listing.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 ba6f47c6140..52fd96af333 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 @@ -46,7 +46,7 @@ $(document).ready(function () { $("#ast-container").on("click", ".new-notification", function(e){ var notificationId = $(this).data("id"); var redirectUrl = $(this).data("url"); - var getNotificationsAPI = "/devicemgt_admin/notifications/"+notificationId+"/CHECKED"; + var getNotificationsAPI = "/api/device-mgt/v1.0/notifications/"+notificationId+"/CHECKED"; var errorMsgWrapper = "#error-msg"; var errorMsg = "#error-msg span"; invokerUtil.put( @@ -87,7 +87,7 @@ function loadNotifications(){ var deviceListingSrc = deviceListing.attr("src"); var currentUser = deviceListing.data("currentUser"); $.template("notification-listing", deviceListingSrc, function (template) { - var serviceURL = "/devicemgt_admin/notifications"; + var serviceURL = "/api/device-mgt/v1.0/notifications"; var successCallback = function (data) { var viewModel = {}; data = JSON.parse(data);