diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js index d594af0766..d74cce8f99 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js @@ -70,7 +70,7 @@ $(document).ready(function () { deviceListing = $("#device-listing"); currentUser = deviceListing.data("current-user"); - + groupId = getParameterByName("groupId"); /* Adding selected class for selected devices */ @@ -80,11 +80,11 @@ $(document).ready(function () { /* for device list sorting drop down */ $(".ctrl-filter-type-switcher").popover({ - html: true, - content: function () { - return $("#content-filter-types").html(); - } - }); + html: true, + content: function () { + return $("#content-filter-types").html(); + } + }); }); /* @@ -247,7 +247,7 @@ function loadDevices(searchType, searchParam) { class: 'remove-padding icon-only content-fill viewEnabledIcon', render: function (data, type, row, meta) { return '
'; + + getDeviceTypeThumb(row.deviceType) + '"/>'; } }, { @@ -325,47 +325,47 @@ function loadDevices(searchType, searchParam) { if (analyticsEnabled(row.deviceType)) { html += '' + - '' + - ''; + deviceIdentifier + '&deviceName=' + row.name + '" ' + 'data-click-event="remove-form"' + + ' class="btn padding-reduce-on-grid-view" data-placement="top" data-toggle="tooltip" data-original-title="Analytics">' + + '' + + ''; } if (!groupId && groupingEnabled(row.deviceType)) { html += - '' + - '' + - ''; + '' + + '' + + ''; } -// html += -// '' -// + '' -// + '' -// + ''; + html += + '' + + '' + + '' + + ''; var groupOwner = $('#group_owner').text(); if (groupId && groupOwner != "wso2.system.user") { html += - '' - + '' - + '' - + ''; + '' + + '' + + '' + + ''; } else { html += - '' - + '' - + '' - + ''; + '' + + '' + + '' + + ''; } } return html; @@ -417,7 +417,7 @@ function loadDevices(searchType, searchParam) { }); }; - function htmlspecialchars(text){ + function htmlspecialchars(text) { return jQuery('
').text(text).html(); } @@ -427,16 +427,16 @@ function loadDevices(searchType, searchParam) { $(data.devices).each(function (index) { objects.push( - { - model: getPropertyValue(data.devices[index].properties, "DEVICE_MODEL"), - vendor: getPropertyValue(data.devices[index].properties, "VENDOR"), - user: data.devices[index].enrolmentInfo.owner, - status: data.devices[index].enrolmentInfo.status, - ownership: data.devices[index].enrolmentInfo.ownership, - deviceType: data.devices[index].type, - deviceIdentifier: data.devices[index].deviceIdentifier, - name: data.devices[index].name - } + { + model: getPropertyValue(data.devices[index].properties, "DEVICE_MODEL"), + vendor: getPropertyValue(data.devices[index].properties, "VENDOR"), + user: data.devices[index].enrolmentInfo.owner, + status: data.devices[index].enrolmentInfo.status, + ownership: data.devices[index].enrolmentInfo.ownership, + deviceType: data.devices[index].type, + deviceIdentifier: data.devices[index].deviceIdentifier, + name: data.devices[index].name + } ); }); @@ -449,28 +449,28 @@ function loadDevices(searchType, searchParam) { }; $('#device-grid').datatables_extended_serverside_paging( - null, - serviceURL, - dataFilter, - columns, - fnCreatedRow, - function () { - $(".icon .text").res_text(0.2); - $('#device-grid').removeClass('hidden'); - $("#loading-content").remove(); - attachDeviceEvents(); - - - if($('.advance-search').length < 1){ - $(this).closest('.dataTables_wrapper').find('div[id$=_filter] input') - .after('Advance Search'); - } - - }, { - "placeholder": "Search By Device Name", - "searchKey": "name" + null, + serviceURL, + dataFilter, + columns, + fnCreatedRow, + function () { + $(".icon .text").res_text(0.2); + $('#device-grid').removeClass('hidden'); + $("#loading-content").remove(); + attachDeviceEvents(); + + + if ($('.advance-search').length < 1) { + $(this).closest('.dataTables_wrapper').find('div[id$=_filter] input') + .after('Advance Search'); } + + }, { + "placeholder": "Search By Device Name", + "searchKey": "name" + } ); $(deviceCheckbox).click(function () { @@ -507,11 +507,11 @@ $(document).ready(function () { /* for device list sorting drop down */ $(".ctrl-filter-type-switcher").popover({ - html: true, - content: function () { - return $("#content-filter-types").html(); - } - }); + html: true, + content: function () { + return $("#content-filter-types").html(); + } + }); /* for data tables*/ $('[data-toggle="tooltip"]').tooltip(); @@ -519,17 +519,17 @@ $(document).ready(function () { $("[data-toggle=popover]").popover(); $(".ctrl-filter-type-switcher").popover({ - html: true, - content: function () { - return $('#content-filter-types').html(); - } - }); + html: true, + content: function () { + return $('#content-filter-types').html(); + } + }); $('#nav').affix({ - offset: { - top: $('header').height() - } - }); + offset: { + top: $('header').height() + } + }); }); @@ -583,9 +583,9 @@ function markAlreadyAssignedGroups(deviceId, deviceType) { }; invokerUtil.get("/api/device-mgt/v1.0/groups/device?deviceId=" + deviceId + "&deviceType=" + deviceType, - successCallback, function (message) { - displayErrors(message); - }); + successCallback, function (message) { + displayErrors(message); + }); } /** @@ -604,7 +604,7 @@ function attachDeviceEvents() { var deviceType = $(this).data("devicetype"); $(modalPopupContent).html($('#group-device-modal-content').html()); $('#user-groups').html( - '
'); + '
'); $("a#group-device-update-link").hide(); showPopup(); @@ -629,9 +629,9 @@ function attachDeviceEvents() { } if (hasGroups) { html = '

Please select device group(s)


' + - '
' + - '
'; + '
' + + '
'; markAlreadyAssignedGroups(deviceId, deviceType); $("a#group-device-update-link").show(); $("a#group-add-link").hide(); @@ -642,8 +642,8 @@ function attachDeviceEvents() { } $('#user-groups').html(html); $("select.select2[multiple=multiple]").select2({ - tags: false - }); + tags: false + }); $("a#group-device-update-link").click(function () { var deviceIdentifier = {"id": deviceId, "type": deviceType}; var deviceGroupIds = $("#groups").val(); @@ -787,7 +787,7 @@ function attachDeviceEvents() { $(modalPopupContent).html($('#group-device-modal-content').html()); $('#user-groups').html( - '
'); + '
'); $("a#group-device-add-link").hide(); showPopup(); @@ -806,13 +806,13 @@ function attachDeviceEvents() { for (var i = 0; i < groups.deviceGroups.length; i++) { if (groups.deviceGroups[i].owner != "wso2.system.user") { html += ''; + groups.deviceGroups[i].name + ''; hasGroups = true; } } if (hasGroups) { html = '
'; + html + ''; $("a#group-add-link").hide(); $("a#group-device-add-link").show(); } else { @@ -898,7 +898,7 @@ function displayDeviceErrors(jqXHR) { function getParameterByName(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), - results = regex.exec(location.search); + results = regex.exec(location.search); return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } @@ -911,10 +911,10 @@ function getSelectedDevices() { thisTable.api().rows().every(function () { if ($(this.node()).hasClass('DTTT_selected')) { deviceList.push( - { - "id": $(thisTable.api().row(this).node()).data('deviceid'), - "type": $(thisTable.api().row(this).node()).data('devicetype') - } + { + "id": $(thisTable.api().row(this).node()).data('deviceid'), + "type": $(thisTable.api().row(this).node()).data('devicetype') + } ); } }); 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 befe1a7d1c..45411b407f 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 @@
-
+
-

-
+

+
@@ -87,57 +88,65 @@ - + {{#if isCloud}} +
+ + devicemgt + + {{else}}
- - -
- {{#if canViewUsers}} -
+ {{#if canViewUsers}} + -
- - -
+
+ + +
{{/if}}
+
+
+
-
-
-
- -
- + {{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 ca91072d12..77ff1d04f5 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 2cb8292af7..e070c05835 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 98749decd7..6899f98fb2 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 962a7f3cea..47e8181218 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.role.edit/edit.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/edit.hbs index e9c4527578..979b5c1450 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/edit.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/edit.hbs @@ -19,11 +19,11 @@
    -
    +

    Edit Role

    Please note that * sign represents required fields of data.

    -
    +
    +
    +
    -
    -
    -
    - -
    - -{{#zone "bottomJs"}} - {{js "js/bottomJs.js"}} -{{/zone}} + + {{#zone "bottomJs"}} + {{js "js/bottomJs.js"}} + {{/zone}} 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 9bca327597..d5c363ef1f 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 @@ -29,6 +29,7 @@ function onRequest(context) { var roleName = request.getParameter("rolename"); var response; var userStore; + context.isCloud = deviceMgtProps.isCloud; if (roleName) { if (roleName.indexOf("/") > -1) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/public/js/bottomJs.js index 7dae919969..6ae0e8016f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/public/js/bottomJs.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.edit/public/js/bottomJs.js @@ -83,18 +83,18 @@ clearInline["role-name"] = function () { */ validateInline["role-name"] = function () { var rolenameinput = $("input#rolename"); - if (inputIsValid( rolenameinput.data("regex"), rolenameinput.val())) { + if (inputIsValid(rolenameinput.data("regex"), rolenameinput.val())) { 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 = '
    ' + @@ -102,7 +102,7 @@ function formatRepo (user) { '
    ' + '
    ' + user.username + '
    '; if (user.firstname) { - markup += '
    ' + user.firstname + '
    '; + markup += '
    ' + user.firstname + '
    '; } if (user.emailAddress) { markup += '
    ' + user.emailAddress + '
    '; @@ -111,14 +111,14 @@ function formatRepo (user) { return markup; } -function formatRepoSelection (user) { +function formatRepoSelection(user) { return user.username || user.text; } $(document).ready(function () { var appContext = $("#app-context").data("app-context"); $("#users").select2({ - multiple:true, + multiple: true, tags: false, ajax: { url: appContext + "/api/invoker/execute/", @@ -148,23 +148,29 @@ $(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 }); - /** * Following click function would execute * when a user clicks on "Add Role" button * on Add Role page in WSO2 MDM Console. */ - $("button#add-role-btn").click(function() { + $("button#add-role-btn").click(function () { + var isCloud = $("#role-create-form").data("cloud"); var rolenameInput = $("input#rolename"); var roleName = rolenameInput.val(); var currentRoleName = $("input#rolename").data("currentrole"); + if (isCloud) { + + currentRoleName = "devicemgt" + currentRoleName; + } var domain = $("#domain").val(); var errorMsgWrapper = "#role-create-error-msg"; var errorMsg = "#role-create-error-msg span"; @@ -182,12 +188,17 @@ $(document).ready(function () { $(errorMsgWrapper).removeClass("hidden"); } else { var addRoleFormData = {}; - addRoleFormData.roleName = roleName; + if (isCloud) { + addRoleFormData.roleName = "devicemgt" + roleName; + } else { + addRoleFormData.roleName = roleName; + } var addRoleAPI = apiBasePath + "/roles/" + encodeURIComponent(currentRoleName); - if (domain != "PRIMARY"){ + if (domain != "PRIMARY") { addRoleFormData.roleName = domain + "/" + roleName; addRoleAPI = addRoleAPI + "?user-store=" + encodeURIComponent(domain); } + invokerUtil.put( addRoleAPI, addRoleFormData, @@ -201,6 +212,7 @@ $(document).ready(function () { $("#role-created-msg").removeClass("hidden"); } }, function (data) { + var payload = JSON.parse(data.responseText); $(errorMsg).text(payload.message); $(errorMsgWrapper).removeClass("hidden"); @@ -209,11 +221,11 @@ $(document).ready(function () { } }); - $("#rolename").focus(function() { + $("#rolename").focus(function () { clearInline["role-name"](); }); - $("#rolename").blur(function() { + $("#rolename").blur(function () { validateInline["role-name"](); }); 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 fe5ac86b97..edd143481b 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 69562888a0..c9016ccf3e 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