+ 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.
+
+
+
+
+
+
+
+
+ Add Another Role
+
+
+
+
+
+
+
+
+{{/zone}}
+{{#zone "bottomJs"}}
+ {{js "js/bottomJs.js"}}
{{/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.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
similarity index 68%
rename from components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/create.js
rename to components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.js
index a65fa31e25..909a3ee303 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.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
@@ -25,14 +25,11 @@
function onRequest(context) {
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"];
- var response = userModule.getRoles();
- if (response["status"] == "success") {
- context["roles"] = response["content"];
- }
- var userStores = userModule.getSecondaryUserStores();
- context["userStores"] = userStores;
- context["roleNameJSRegEx"] = deviceMgtProps.roleValidationConfig.rolenameJSRegEx;
- context["roleNameHelpText"] = deviceMgtProps.roleValidationConfig.rolenameHelpMsg;
- context["roleNameRegExViolationErrorMsg"] = deviceMgtProps.roleValidationConfig.rolenameRegExViolationErrorMsg;
+
+ context["userStores"] = userModule.getSecondaryUserStores();
+ context["roleNameJSRegEx"] = deviceMgtProps["roleValidationConfig"]["roleNameJSRegEx"];
+ context["roleNameHelpText"] = deviceMgtProps["roleValidationConfig"]["roleNameHelpMsg"];
+ context["roleNameRegExViolationErrorMsg"] = deviceMgtProps["roleValidationConfig"]["roleNameRegExViolationErrorMsg"];
+
return context;
}
\ 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/create.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.json
index e54dc5f2af..adab2be0f6 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.json
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.json
@@ -1,5 +1,5 @@
{
"version": "1.0.0",
- "uri": "/roles/add-role",
+ "uri": "/role/add",
"layout": "cdmf.layout.default"
}
\ 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.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
similarity index 69%
rename from components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/public/js/bottomJs.js
rename to 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 5a7d7eb304..013402bf84 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.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
@@ -73,19 +73,19 @@ var disableInlineError = function (inputField, errorMsg, errorSign) {
*clear inline validation messages.
*/
clearInline["role-name"] = function () {
- disableInlineError("roleNameField", "rolenameEmpty", "rolenameError");
+ disableInlineError("roleNameField", "roleNameEmpty", "roleNameError");
};
/**
- * Validate if provided rolename is valid against RegEx configures.
+ * Validate if provided role-name is valid against RegEx configures.
*/
validateInline["role-name"] = function () {
- var rolenameinput = $("input#rolename");
- if (inputIsValid( rolenameinput.data("regex"), rolenameinput.val())) {
- disableInlineError("roleNameField", "rolenameEmpty", "rolenameError");
+ var roleNameInput = $("input#roleName");
+ if (inputIsValid( roleNameInput.data("regex"), roleNameInput.val())) {
+ disableInlineError("roleNameField", "roleNameEmpty", "roleNameError");
} else {
- enableInlineError("roleNameField", "rolenameEmpty", "rolenameError");
+ enableInlineError("roleNameField", "roleNameEmpty", "roleNameError");
}
};
@@ -97,16 +97,16 @@ function formatRepo (user) {
return;
}
var markup = '
' +
- '
' +
+ '
' +
'
' +
- '
' + user.username + '
';
- if (user.firstname) {
- markup += '
' + user.firstname + '
';
+ '
User : ' + user.username + '
';
+ if (user.name) {
+ markup += '
' + user.name + '
';
}
if (user.emailAddress) {
- markup += '
' + user.emailAddress + '
';
+ markup += '
' + user.emailAddress + '
';
}
- markup += '
';
+ markup += '
';
return markup;
}
@@ -129,17 +129,19 @@ $(document).ready(function () {
},
data: function (params) {
var postData = {};
- postData.actionMethod = "GET";
- postData.actionUrl = apiBasePath + "/users/search/usernames?filter=" + params.term;
- postData.actionPayload = null;
+ postData.requestMethod = "GET";
+ postData.requestURL = "/api/device-mgt/v1.0/users/search/usernames?filter=" + params.term;
+ postData.requestPayload = null;
return JSON.stringify(postData);
},
- processResults: function (data, page) {
+ processResults: function (data) {
var newData = [];
$.each(data, function (index, value) {
var user = {};
- user.username = value.username;
user.id = value.username;
+ user.username = value.username;
+ user.name = value.firstname + " " + value.lastname;
+ user.emailAddress = value.emailAddress;
newData.push(user);
});
return {
@@ -159,10 +161,10 @@ $(document).ready(function () {
* when a user clicks on "Add Role" button
* on Add Role page in WSO2 MDM Console.
*/
- $("button#add-role-btn").click(function() {
- var rolenameInput = $("input#rolename");
- var roleName = rolenameInput.val();
+ $("button#add-role-btn").click(function () {
var domain = $("#domain").val();
+ var roleNameInput = $("input#roleName");
+ var roleName = roleNameInput.val();
var users = $("#users").val();
var errorMsgWrapper = "#role-create-error-msg";
@@ -170,8 +172,8 @@ $(document).ready(function () {
if (!roleName) {
$(errorMsg).text("Role name is a required field. It cannot be empty.");
$(errorMsgWrapper).removeClass("hidden");
- } else if (!inputIsValid(rolenameInput.data("regex"), roleName)) {
- $(errorMsg).text(rolenameInput.data("errormsg"));
+ } else if (!inputIsValid(roleNameInput.data("regex"), roleName)) {
+ $(errorMsg).text(roleNameInput.data("error-msg"));
$(errorMsgWrapper).removeClass("hidden");
} else if (!domain) {
$(errorMsg).text("Domain is a required field. It cannot be empty.");
@@ -181,13 +183,11 @@ $(document).ready(function () {
$(errorMsgWrapper).removeClass("hidden");
} else {
var addRoleFormData = {};
-
addRoleFormData.roleName = roleName;
-
if (domain != "PRIMARY"){
addRoleFormData.roleName = domain + "/" + roleName;
}
- if (users == null){
+ if (users == null) {
users = [];
}
addRoleFormData.users = users;
@@ -197,37 +197,31 @@ $(document).ready(function () {
invokerUtil.post(
addRoleAPI,
addRoleFormData,
- function (data) {
- data = JSON.parse(data);
- if (data.errorMessage) {
- $(errorMsg).text("Selected user store prompted an error : " + data.errorMessage);
- $(errorMsgWrapper).removeClass("hidden");
- } else {
+ function (data, textStatus, jqXHR) {
+ if (jqXHR.status == 201) {
// Clearing user input fields.
- //$("input#rolename").val("");
- //$("#domain").val("");
- //// Refreshing with success message
- //$("#role-create-form").addClass("hidden");
- //$("#role-created-msg").removeClass("hidden");
- window.location.href = appContext + '/role/edit-permission/' + roleName;
+ $("input#roleName").val("");
+ $("#domain").val("PRIMARY");
+ $("#users").val("");
+ window.location.href = appContext + "/role/edit-permission/" + roleName;
}
- }, function (data) {
- if (JSON.parse(data).errorMessage.indexOf("RoleExisting") > -1) {
- $(errorMsg).text("Role name : " + roleName + " already exists. Pick another role name.");
- } else {
- $(errorMsg).text(JSON.parse(data.responseText).errorMessage);
+ },
+ function (jqXHR) {
+ if (jqXHR.status == 500) {
+ $(errorMsg).text("Either role already exists or unexpected error.");
+ $(errorMsgWrapper).removeClass("hidden");
}
- $(errorMsgWrapper).removeClass("hidden");
}
);
}
});
- $("#rolename").focus(function() {
+ var roleNameInputElement = "#roleName";
+ $(roleNameInputElement).focus(function() {
clearInline["role-name"]();
});
- $("#rolename").blur(function() {
+ $(roleNameInputElement).blur(function() {
validateInline["role-name"]();
});
});
\ 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.edit/edit.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.edit/edit.hbs
index cdf32d9884..d1c488dbef 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.edit/edit.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.edit/edit.hbs
@@ -26,6 +26,7 @@
+
Roles
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/pages/cdmf.page.roles/public/js/role-listing.js
similarity index 97%
rename from 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
rename to 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 bfec8b339f..47a6dc90e0 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/pages/cdmf.page.roles/public/js/role-listing.js
@@ -145,7 +145,7 @@ function loadRoles(searchQuery) {
var modalPopup = ".modal";
var modalPopupContainer = modalPopup + " .modal-content";
-var modalPopupContent = modalPopup + " .modal-body";
+var modalPopupContent = modalPopup + " .modal-content";
var body = "body";
var isInit = true;
@@ -162,8 +162,8 @@ function setPopupMaxHeight() {
* show popup function.
*/
function showPopup() {
- $(modalPopup).show();
- setPopupMaxHeight();
+ $(modalPopup).modal('show');
+ //setPopupMaxHeight();
}
/*
@@ -172,6 +172,8 @@ function showPopup() {
function hidePopup() {
$(modalPopupContent).html('');
$(modalPopup).modal('hide');
+ $('body').removeClass('modal-open').css('padding-right','0px');
+ $('.modal-backdrop').remove();
}
/**
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/public/templates/role-listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/templates/role-listing.hbs
similarity index 100%
rename from components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/public/templates/role-listing.hbs
rename to components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/templates/role-listing.hbs
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 07f4c0a143..b9c4083c4e 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
@@ -15,8 +15,8 @@
specific language governing permissions and limitations
under the License.
}}
-{{unit "cdmf.unit.ui.title" pageTitle="Role Management"}}
+{{unit "cdmf.unit.ui.title" pageTitle="Role Management"}}
{{unit "cdmf.unit.data-tables-extended"}}
{{#zone "breadcrumbs"}}
@@ -26,6 +26,7 @@
-
-{{#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.create/create.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/create.json
deleted file mode 100644
index 9eecd8f5bf..0000000000
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/create.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "version": "1.0.0"
-}
\ 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.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 249e35a6e3..281f5ea350 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
@@ -31,11 +31,8 @@
-
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 cf54af034e..ac21d0b696 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
@@ -18,30 +18,38 @@
/**
* 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
*/
function onRequest(context) {
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"];
+
var uri = request.getRequestURI();
var uriMatcher = new URIMatcher(String(uri));
- var isMatched = uriMatcher.match("/{context}/role/edit/{rolename}");
+ var isMatched = uriMatcher.match("/{context}/role/edit/{roleName}");
if (isMatched) {
var matchedElements = uriMatcher.elements();
- var roleName = matchedElements.rolename;
+ var roleName = matchedElements["roleName"];
var response = userModule.getRole(roleName);
if (response["status"] == "success") {
context["role"] = response["content"];
}
- var userStores = userModule.getSecondaryUserStores();
- context["userStores"] = userStores;
+ var userStore;
+ if (roleName.indexOf("/") > -1) {
+ userStore = roleName.substring(0, roleName.indexOf("/"));
+ } else {
+ userStore = "PRIMARY";
+ }
+ context["userStore"] = userStore;
+ context["roleNameJSRegEx"] = deviceMgtProps["roleValidationConfig"]["roleNameJSRegEx"];
+ context["roleNameHelpText"] = deviceMgtProps["roleValidationConfig"]["roleNameHelpMsg"];
+ context["roleNameRegExViolationErrorMsg"] = deviceMgtProps["roleValidationConfig"]["roleNameRegExViolationErrorMsg"];
+ return context;
+ } else {
+ //TODO: handle error scenario
+ return context;
}
- //TODO: error scenario
- context["roleNameJSRegEx"] = deviceMgtProps.roleValidationConfig.rolenameJSRegEx;
- context["roleNameHelpText"] = deviceMgtProps.roleValidationConfig.rolenameHelpMsg;
- context["roleNameRegExViolationErrorMsg"] = deviceMgtProps.roleValidationConfig.rolenameRegExViolationErrorMsg;
- return context;
}
\ 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.role.listing/listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/listing.hbs
deleted file mode 100644
index acf56f7963..0000000000
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/listing.hbs
+++ /dev/null
@@ -1,129 +0,0 @@
-{{!
- 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.
-}}
-