diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.hbs index befe1a7d1c0..ce2b46759fc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.hbs @@ -39,14 +39,15 @@ {{#zone "content"}} {{#if canManage}} - -
-
- -
+ +
+
+ +

Add Role

-
+
@@ -62,10 +63,10 @@
-
+
-

-
+

+
@@ -91,7 +92,7 @@
+ data-error-msg="{{roleNameRegExViolationErrorMsg}}" class="form-control"/>
{{#if canViewUsers}} - + -
- - -
+
+ + +
{{/if}}
@@ -119,7 +120,7 @@

Role was added successfully.


Please click "Add Another Role", if you wish to add another role or click "View Role List" to complete the process and go back to the role list. -
+
@@ -136,8 +137,8 @@
-
- +
+ {{else}}

Permission Denied diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.js index ca91072d12c..77ff1d04f59 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.js @@ -18,7 +18,7 @@ /** * 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 displayData object that returns the dynamic state of this page to be presented */ @@ -38,6 +38,7 @@ function onRequest(context) { if (userModule.isAuthorized("/permission/admin/device-mgt/users/view")) { displayData.canViewUsers = true; } + displayData.isCloud = deviceMgtProps.isCloud; return displayData; } \ 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.role.create/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/public/js/bottomJs.js index 2cb8292af7b..e070c05835f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/public/js/bottomJs.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/public/js/bottomJs.js @@ -33,6 +33,8 @@ var clearInline = {}; var apiBasePath = "/api/device-mgt/v1.0"; var domain = $("#domain").val(); +var isCloud = $("#role-create-form").data("cloud"); + var enableInlineError = function (inputField, errorMsg, errorSign) { var fieldIdentifier = "#" + inputField; @@ -84,18 +86,18 @@ clearInline["role-name"] = function () { validateInline["role-name"] = function () { var roleNameInput = $("input#roleName"); var roleName = roleNameInput.val(); - if (inputIsValid( roleNameInput.data("regex"), roleName) && roleName.indexOf("@") < 0 && roleName.indexOf("/") < 0) { + if (inputIsValid(roleNameInput.data("regex"), roleName) && roleName.indexOf("@") < 0 && roleName.indexOf("/") < 0) { disableInlineError("roleNameField", "roleNameEmpty", "roleNameError"); } else { enableInlineError("roleNameField", "roleNameEmpty", "roleNameError"); } }; -function formatRepo (user) { +function formatRepo(user) { if (user.loading) { return user.text } - if (!user.username){ + if (!user.username) { return; } var markup = '
' + @@ -103,20 +105,22 @@ function formatRepo (user) { '
' + '
' + user.username + '
'; if (user.name || user.name != undefined) { - markup += '
( ' + user.name + ' )
'; + markup += '
( ' + user.name + ' )
'; } markup += '

'; return markup; } -function formatRepoSelection (user) { +function formatRepoSelection(user) { return user.username || user.text; } $(document).ready(function () { + isCloud = $("#role-create-form").data("cloud"); + var appContext = $("#app-context").data("app-context"); $("#users").select2({ - multiple:true, + multiple: true, tags: false, ajax: { url: appContext + "/api/invoker/execute/", @@ -140,7 +144,7 @@ $(document).ready(function () { var user = {}; user.id = value.username; user.username = value.username; - if(value.firstname && value.lastname) { + if (value.firstname && value.lastname) { user.name = value.firstname + " " + value.lastname; } newData.push(user); @@ -151,7 +155,9 @@ $(document).ready(function () { }, cache: true }, - escapeMarkup: function (markup) { return markup; }, // let our custom formatter work + escapeMarkup: function (markup) { + return markup; + }, // let our custom formatter work minimumInputLength: 1, templateResult: formatRepo, // omitted for brevity, see the source of this page templateSelection: formatRepoSelection // omitted for brevity, see the source of this page @@ -163,6 +169,7 @@ $(document).ready(function () { * on Add Role page in WSO2 MDM Console. */ $("button#add-role-btn").click(function () { + var domain = $("#domain").val(); var roleNameInput = $("input#roleName"); var roleName = roleNameInput.val(); @@ -185,8 +192,12 @@ $(document).ready(function () { $(errorMsgWrapper).removeClass("hidden"); } else { var addRoleFormData = {}; - addRoleFormData.roleName = roleName; - if (domain != "PRIMARY"){ + if (isCloud) { + addRoleFormData.roleName = "devicemgt" + roleName; + } else { + addRoleFormData.roleName = roleName; + } + if (domain != "PRIMARY") { addRoleFormData.roleName = domain + "/" + roleName; } if (users == null) { @@ -220,16 +231,16 @@ $(document).ready(function () { }); var roleNameInputElement = "#roleName"; - $(roleNameInputElement).focus(function() { + $(roleNameInputElement).focus(function () { clearInline["role-name"](); }); - $(roleNameInputElement).blur(function() { + $(roleNameInputElement).blur(function () { validateInline["role-name"](); }); /* When the user store domain value is changed, the users who are assigned to that role should be removed, as - user and role can be mapped only if both are in same user store + user and role can be mapped only if both are in same user store */ $("#domain").change(function () { $("#users").select2("val", ""); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js index 98749decd75..6899f98fb2b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js @@ -37,6 +37,7 @@ var modalPopupContainer = modalPopup + " .modal-content"; var modalPopupContent = modalPopup + " .modal-content"; var body = "body"; var isInit = true; +var isCloud = false; /** @@ -72,7 +73,7 @@ function showPopup() { function hidePopup() { $(modalPopupContent).html(''); $(modalPopup).modal('hide'); - $('body').removeClass('modal-open').css('padding-right','0px'); + $('body').removeClass('modal-open').css('padding-right', '0px'); $('.modal-backdrop').remove(); } @@ -86,11 +87,12 @@ function InitiateViewOption() { // $(location).attr('href', $(this).data("url")); } -function htmlspecialchars(text){ +function htmlspecialchars(text) { return jQuery('
').text(text).html(); } function loadRoles() { + isCloud = $("#role-table").data("cloud"); var loadingContent = $("#loading-content"); loadingContent.show(); @@ -98,21 +100,40 @@ function loadRoles() { data = JSON.parse(data); var objects = []; - + var count = 0; $(data.roles).each(function (index) { - objects.push( - { - name: htmlspecialchars(data.roles[index]), - DT_RowId: "role-" + htmlspecialchars(data.roles[index]) - } - ) + if (isCloud && data.roles[index].startsWith("devicemgt")) { + count++; + objects.push( + { + name: htmlspecialchars(data.roles[index]), + DT_RowId: "role-" + htmlspecialchars(data.roles[index]) + } + ) + } else if (!isCloud) { + objects.push( + { + name: htmlspecialchars(data.roles[index]), + DT_RowId: "role-" + htmlspecialchars(data.roles[index]) + } + ) + } }); - var json = { - "recordsTotal": data.count, - "recordsFiltered": data.count, - "data": objects - }; + var json = {}; + if (isCloud) { + json = { + "recordsTotal": count, + "recordsFiltered": count, + "data": objects + }; + } else { + json = { + "recordsTotal": data.count, + "recordsFiltered": data.count, + "data": objects + }; + } return JSON.stringify(json); }; @@ -143,13 +164,13 @@ function loadRoles() { data: null, render: function (data, type, row, meta) { var isCloud = false; - if ($('#is-cloud').length > 0){ + if ($('#is-cloud').length > 0) { isCloud = true; } - var innerhtml = ''; + var innerhtml = ''; - var editLink = '' + @@ -179,7 +200,7 @@ function loadRoles() { '' + ''; - var removeLink = '' + '' + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/roles.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/roles.hbs index 962a7f3cea8..47e81812183 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/roles.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/roles.hbs @@ -36,39 +36,40 @@ {{#zone "navbarActions"}} {{#unless isCloud}} -
  • - - +
  • + + - Add Role - -
  • + Add Role + + {{/unless}} {{/zone}} {{#zone "content"}}
    {{#unless isCloud}} - {{#if removePermitted}} - - {{/if}} - {{#if editPermitted}} - - {{/if}} + {{#if removePermitted}} + + {{/if}} + {{#if editPermitted}} + + {{/if}} {{/unless}} {{#if isCloud}} - + {{/if}} Loading roles . . .
    -
    - +
    +
    diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/public/js/user-menu.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/public/js/user-menu.js index fe5ac86b977..edd143481b0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/public/js/user-menu.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/public/js/user-menu.js @@ -18,11 +18,11 @@ $(document).ready(function () { $('#cloud-menu-popover i.fw-tiles').popover({ html: true, - trigger:'click', - title: function() { + trigger: 'click', + title: function () { return $("#popover-head").html(); }, - content: function() { + content: function () { return $("#popover-content").html(); } }); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.hbs index 69562888a03..c9016ccf3e7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.hbs @@ -22,7 +22,7 @@ {{#if this.dropDownVisible}} class="dropdown" data-toggle="dropdown" {{/if}} - title = " + title=" {{#if this.isDomain }} {{@user.domain}} {{else}}
    By Role Name