From e5a4c0f7958ac5131bb3ab8ea5f5f192e92173f7 Mon Sep 17 00:00:00 2001 From: Ace Date: Mon, 15 Aug 2016 11:37:57 +0530 Subject: [PATCH] Adding role add/update/delete related changes --- .../units/cdmf.unit.role.create/create.hbs | 3 +- .../public/js/bottomJs.js | 24 +++++++----- .../permission.hbs | 14 +++++++ .../permission.js | 2 +- .../public/js/bottomJs.js | 31 ++++++++++------ .../app/units/cdmf.unit.role.edit/edit.hbs | 3 +- .../cdmf.unit.role.edit/public/js/bottomJs.js | 37 ++++++------------- .../public/js/role-listing.js | 6 +-- 8 files changed, 66 insertions(+), 54 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/create.hbs index b74abb7dc4..a93d3173a0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/create.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/create.hbs @@ -47,7 +47,7 @@ - +
@@ -81,6 +81,7 @@
+ 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 f8c42854cf..e038c32592 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 @@ -1,21 +1,3 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - /** * Checks if provided input is valid against RegEx input. * @@ -31,6 +13,8 @@ function inputIsValid(regExp, inputString) { var validateInline = {}; var clearInline = {}; +var apiBasePath = "/api/device-mgt/v1.0"; + var enableInlineError = function (inputField, errorMsg, errorSign) { var fieldIdentifier = "#" + inputField; var errorMsgIdentifier = "#" + inputField + " ." + errorMsg; @@ -113,12 +97,12 @@ function formatRepoSelection (user) { } $(document).ready(function () { - + var appContext = $("#app-context").data("app-context"); $("#users").select2({ multiple:true, tags: false, ajax: { - url: window.location.origin + "/devicemgt/api/invoker/execute/", + url: appContext + "/api/invoker/execute/", method: "POST", dataType: 'json', delay: 250, @@ -128,7 +112,7 @@ $(document).ready(function () { data: function (params) { var postData = {}; postData.actionMethod = "GET"; - postData.actionUrl = "/devicemgt_admin/users/view-users?username=" + params.term; + postData.actionUrl = apiBasePath + "/users/search/usernames?filter=" + params.term; postData.actionPayload = null; return JSON.stringify(postData); }, @@ -155,7 +139,7 @@ $(document).ready(function () { /** * Following click function would execute * when a user clicks on "Add Role" button - * on Add Role page in WSO2 Devicemgt Console. + * on Add Role page in WSO2 MDM Console. */ $("button#add-role-btn").click(function() { var rolenameInput = $("input#rolename"); @@ -183,12 +167,12 @@ $(document).ready(function () { addRoleFormData.roleName = domain + "/" + roleName; } - var addRoleAPI = "/devicemgt_admin/roles?rolename=" + encodeURIComponent(currentRoleName); + var addRoleAPI = apiBasePath + "/roles/" + currentRoleName; invokerUtil.put( addRoleAPI, addRoleFormData, - function (jqXHR) { - if (JSON.parse(jqXHR).status == 200 || jqXHR.status == 200) { + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200) { // Clearing user input fields. $("input#rolename").val(""); $("#domain").val(""); @@ -197,7 +181,8 @@ $(document).ready(function () { $("#role-created-msg").removeClass("hidden"); } }, function (data) { - $(errorMsg).text(JSON.parse(data.responseText).errorMessage); + var payload = JSON.parse(data.responseText); + $(errorMsg).text(payload.message); $(errorMsgWrapper).removeClass("hidden"); } ); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/public/js/role-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/public/js/role-listing.js index 1b0991cb0a..afeb0a393e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/public/js/role-listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/public/js/role-listing.js @@ -16,7 +16,7 @@ * under the License. */ var loadRoleBasedActionURL = function (action, rolename) { - var href = $("#ast-container").data("app-context") + "roles/" + action + "?rolename=" + rolename; + var href = $("#ast-container").data("app-context") + "role/" + action + "/" + rolename; $(location).attr('href', href); }; @@ -113,13 +113,13 @@ function loadRoles(searchQuery) { class: "text-right content-fill text-left-on-grid-view no-wrap", data: null, render: function ( data, type, row, meta ) { - return '' + '' + '' + '' + '' + - '' + '' + '' +