From 411641bc57704c62b26f07f59827057e631cdc7b Mon Sep 17 00:00:00 2001 From: kamidu Date: Thu, 8 Sep 2016 18:41:51 +0530 Subject: [PATCH 1/3] Enable permission check according to the new permissions --- .../cdmf.page.certificate.create/create.js | 24 ++++---- .../cdmf.page.certificates/certificates.js | 15 ++--- .../app/pages/cdmf.page.policies/policies.hbs | 8 +-- .../app/pages/cdmf.page.policies/policies.js | 9 +-- .../pages/cdmf.page.user.create/create.hbs | 9 +++ .../app/pages/cdmf.page.user.create/create.js | 3 + .../app/pages/cdmf.page.user.edit/edit.hbs | 11 +++- .../app/pages/cdmf.page.user.edit/edit.js | 4 ++ .../app/pages/cdmf.page.user.view/view.hbs | 9 +++ .../app/pages/cdmf.page.user.view/view.js | 7 ++- .../app/pages/cdmf.page.users/users.hbs | 59 +++++++++++-------- .../app/pages/cdmf.page.users/users.js | 17 ++---- .../cdmf.unit.notification.listing/listing.js | 2 +- .../configuration.hbs | 9 +++ .../configuration.js | 9 ++- 15 files changed, 120 insertions(+), 75 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.js index 4e7585163a2..6244fc1f099 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.js @@ -19,8 +19,8 @@ /** * Returns the dynamic state to be populated by add-user page. * - * @param context Object that gets updated with the dynamic state of this page to be presented - * @returns {*} A context object that returns the dynamic state of this page to be presented + * @param viewModel Object that gets updated with the dynamic state of this page to be presented + * @returns {*} A viewModel object that returns the dynamic state of this page to be presented */ function onRequest(context) { // var log = new Log("units/user-create/create.js"); @@ -29,17 +29,17 @@ function onRequest(context) { var response = userModule.getRolesByUserStore(); if (response["status"] == "success") { - context["roles"] = response["content"]; + viewModel["roles"] = response["content"]; } - context["charLimit"] = mdmProps["usernameLength"]; - context["usernameJSRegEx"] = mdmProps["userValidationConfig"]["usernameJSRegEx"]; - context["usernameHelpText"] = mdmProps["userValidationConfig"]["usernameHelpMsg"]; - context["usernameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["usernameRegExViolationErrorMsg"]; - context["firstnameJSRegEx"] = mdmProps["userValidationConfig"]["firstnameJSRegEx"]; - context["firstnameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["firstnameRegExViolationErrorMsg"]; - context["lastnameJSRegEx"] = mdmProps["userValidationConfig"]["lastnameJSRegEx"]; - context["lastnameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["lastnameRegExViolationErrorMsg"]; + viewModel["charLimit"] = mdmProps["usernameLength"]; + viewModel["usernameJSRegEx"] = mdmProps["userValidationConfig"]["usernameJSRegEx"]; + viewModel["usernameHelpText"] = mdmProps["userValidationConfig"]["usernameHelpMsg"]; + viewModel["usernameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["usernameRegExViolationErrorMsg"]; + viewModel["firstnameJSRegEx"] = mdmProps["userValidationConfig"]["firstnameJSRegEx"]; + viewModel["firstnameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["firstnameRegExViolationErrorMsg"]; + viewModel["lastnameJSRegEx"] = mdmProps["userValidationConfig"]["lastnameJSRegEx"]; + viewModel["lastnameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["lastnameRegExViolationErrorMsg"]; - return context; + 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/pages/cdmf.page.certificates/certificates.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.js index 8aeb02353e3..a4be059e947 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.js @@ -1,15 +1,16 @@ function onRequest(context) { var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; + var viewModel = {}; - context["permissions"] = userModule.getUIPermissions(); - if (userModule.isAuthorized("/permission/admin/device-mgt/emm-admin/certificate/Get")) { - context["removePermitted"] = true; + if (userModule.isAuthorized("/permission/admin/device-mgt/certificates/manage")) { + viewModel["removePermitted"] = true; } - if (userModule.isAuthorized("/permission/admin/device-mgt/emm-admin/certificate/Get")) { - context["viewPermitted"] = true; + if (userModule.isAuthorized("/permission/admin/device-mgt/certificates/view")) { + viewModel["viewPermitted"] = true; } - context["adminUser"] = mdmProps.adminUser; - return context; + + viewModel.adminUser = mdmProps.adminUser; + 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/pages/cdmf.page.policies/policies.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs index 2dcfb0122e0..9a3a1137910 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs @@ -40,7 +40,7 @@ {{/zone}} {{#zone "navbarActions"}} - {{#if permissions.ADD_ADMIN_POLICY}} + {{#if managePermitted}}
  • @@ -50,8 +50,6 @@ Add Policy
  • - {{/if}} - {{#if permissions.CHANGE_POLICY_PRIORITY}} {{#equal noPolicy false}}
  • @@ -81,7 +79,7 @@