From 2cd5a0e65947e01ccb5fc4b0908f58f4f208afc0 Mon Sep 17 00:00:00 2001 From: kamidu Date: Fri, 9 Sep 2016 11:13:37 +0530 Subject: [PATCH] Enable permission check according to the new permissions --- .../app/pages/cdmf.page.policies/policies.js | 2 +- .../cdmf.page.policy.priority/priority.hbs | 11 +- .../cdmf.page.policy.priority/priority.js | 3 + .../units/cdmf.unit.policy.create/create.hbs | 115 +++--- .../units/cdmf.unit.policy.create/create.js | 2 + .../app/units/cdmf.unit.policy.edit/edit.hbs | 377 ++++++++++-------- .../app/units/cdmf.unit.policy.edit/edit.js | 8 +- .../app/units/cdmf.unit.policy.view/view.hbs | 138 ++++--- .../app/units/cdmf.unit.policy.view/view.js | 1 + 9 files changed, 362 insertions(+), 295 deletions(-) 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 884627e70e..a41d4cc69a 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 @@ -56,7 +56,7 @@ function onRequest(context) { page["noPolicy"] = true; } - if (userModule.isAuthorized("/permission/admin/device-mgt/policies/delete")) { + if (userModule.isAuthorized("/permission/admin/device-mgt/policies/manage")) { page.managePermitted = true; } return page; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.priority/priority.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.priority/priority.hbs index 7b1a0775fe..e526b7eaf4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.priority/priority.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.priority/priority.hbs @@ -38,5 +38,14 @@ {{/zone}} {{#zone "content"}} - {{unit "cdmf.unit.policy.priority"}} + {{#if isAuthorized}} + {{unit "cdmf.unit.policy.priority"}} + {{else}} +

+ Permission Denied +

+
+ You not authorized to enter Policy Management Section. +
+ {{/if}} {{/zone}} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.priority/priority.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.priority/priority.js index ccc71cc150..76f53e8024 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.priority/priority.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policy.priority/priority.js @@ -26,4 +26,7 @@ function onRequest(context){ return options.fn(this); } }); + var viewModel = {}; + viewModel.isAuthorized = userModule.isAuthorized("/permission/admin/device-mgt/policies/manage"); + return viewModel; } \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.hbs index adfadb50ab..6ca4a63285 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.hbs @@ -16,70 +16,79 @@ under the License. }} {{#zone "content"}} -
-
-
-
-

ADD POLICY

-
-
-
-
-
1
- + {{#if isAuthorized}} +
+
+
+
+

ADD POLICY

+
+
+
+
+
1
+ +
+
-
-
-
-
-
2
- +
+
+
2
+ +
+
-
-
-
-
-
3
- +
+
+
3
+ +
+
-
-
-
-
-
4
- +
+
+
4
+ +
+
-
-
-
-
-
-

Step 1: Select a platform

-
+
+
+
+

Step 1: Select a platform

+
-
-
- +
+
+ +
+
-
-
+ {{else}} +

+ Permission Denied +

+
+ You not authorized to enter Policy Management Section. +
+ {{/if}} {{/zone}} \ No newline at end of file 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 79d41eab85..3f6da52477 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 @@ -24,6 +24,8 @@ function onRequest(context) { var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var types = {}; + + types.isAuthorized = userModule.isAuthorized("/permission/admin/device-mgt/policies/manage"); types["types"] = []; var typesListResponse = deviceModule.getDeviceTypes(); if (typesListResponse["status"] == "success") { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/edit.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/edit.hbs index fbeb8f8eb3..f053c7beea 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/edit.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/edit.hbs @@ -1,222 +1,255 @@ {{#zone "content"}} -
-
+ {{#if isAuthorized }} +
+
-