|
|
|
@ -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 () {
|
|
|
|
|
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 = {};
|
|
|
|
|
if (isCloud) {
|
|
|
|
|
addRoleFormData.roleName = "devicemgt" + roleName;
|
|
|
|
|
} else {
|
|
|
|
|
addRoleFormData.roleName = roleName;
|
|
|
|
|
}
|
|
|
|
|
var addRoleAPI = apiBasePath + "/roles/" + encodeURIComponent(currentRoleName);
|
|
|
|
|
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");
|
|
|
|
|