|
|
@ -83,18 +83,18 @@ clearInline["role-name"] = function () {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
validateInline["role-name"] = function () {
|
|
|
|
validateInline["role-name"] = function () {
|
|
|
|
var rolenameinput = $("input#rolename");
|
|
|
|
var rolenameinput = $("input#rolename");
|
|
|
|
if (inputIsValid( rolenameinput.data("regex"), rolenameinput.val())) {
|
|
|
|
if (inputIsValid(rolenameinput.data("regex"), rolenameinput.val())) {
|
|
|
|
disableInlineError("roleNameField", "rolenameEmpty", "rolenameError");
|
|
|
|
disableInlineError("roleNameField", "rolenameEmpty", "rolenameError");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
enableInlineError("roleNameField", "rolenameEmpty", "rolenameError");
|
|
|
|
enableInlineError("roleNameField", "rolenameEmpty", "rolenameError");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function formatRepo (user) {
|
|
|
|
function formatRepo(user) {
|
|
|
|
if (user.loading) {
|
|
|
|
if (user.loading) {
|
|
|
|
return user.text
|
|
|
|
return user.text
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!user.username){
|
|
|
|
if (!user.username) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var markup = '<div class="clearfix">' +
|
|
|
|
var markup = '<div class="clearfix">' +
|
|
|
@ -111,14 +111,14 @@ function formatRepo (user) {
|
|
|
|
return markup;
|
|
|
|
return markup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function formatRepoSelection (user) {
|
|
|
|
function formatRepoSelection(user) {
|
|
|
|
return user.username || user.text;
|
|
|
|
return user.username || user.text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
$(document).ready(function () {
|
|
|
|
var appContext = $("#app-context").data("app-context");
|
|
|
|
var appContext = $("#app-context").data("app-context");
|
|
|
|
$("#users").select2({
|
|
|
|
$("#users").select2({
|
|
|
|
multiple:true,
|
|
|
|
multiple: true,
|
|
|
|
tags: false,
|
|
|
|
tags: false,
|
|
|
|
ajax: {
|
|
|
|
ajax: {
|
|
|
|
url: appContext + "/api/invoker/execute/",
|
|
|
|
url: appContext + "/api/invoker/execute/",
|
|
|
@ -148,23 +148,29 @@ $(document).ready(function () {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
cache: true
|
|
|
|
cache: true
|
|
|
|
},
|
|
|
|
},
|
|
|
|
escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
|
|
|
|
escapeMarkup: function (markup) {
|
|
|
|
|
|
|
|
return markup;
|
|
|
|
|
|
|
|
}, // let our custom formatter work
|
|
|
|
minimumInputLength: 1,
|
|
|
|
minimumInputLength: 1,
|
|
|
|
templateResult: formatRepo, // omitted for brevity, see the source of this page
|
|
|
|
templateResult: formatRepo, // omitted for brevity, see the source of this page
|
|
|
|
templateSelection: formatRepoSelection // 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
|
|
|
|
* Following click function would execute
|
|
|
|
* when a user clicks on "Add Role" button
|
|
|
|
* when a user clicks on "Add Role" button
|
|
|
|
* on Add Role page in WSO2 MDM Console.
|
|
|
|
* 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 rolenameInput = $("input#rolename");
|
|
|
|
var roleName = rolenameInput.val();
|
|
|
|
var roleName = rolenameInput.val();
|
|
|
|
var currentRoleName = $("input#rolename").data("currentrole");
|
|
|
|
var currentRoleName = $("input#rolename").data("currentrole");
|
|
|
|
|
|
|
|
if (isCloud) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
currentRoleName = "devicemgt" + currentRoleName;
|
|
|
|
|
|
|
|
}
|
|
|
|
var domain = $("#domain").val();
|
|
|
|
var domain = $("#domain").val();
|
|
|
|
var errorMsgWrapper = "#role-create-error-msg";
|
|
|
|
var errorMsgWrapper = "#role-create-error-msg";
|
|
|
|
var errorMsg = "#role-create-error-msg span";
|
|
|
|
var errorMsg = "#role-create-error-msg span";
|
|
|
@ -182,12 +188,17 @@ $(document).ready(function () {
|
|
|
|
$(errorMsgWrapper).removeClass("hidden");
|
|
|
|
$(errorMsgWrapper).removeClass("hidden");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
var addRoleFormData = {};
|
|
|
|
var addRoleFormData = {};
|
|
|
|
|
|
|
|
if (isCloud) {
|
|
|
|
|
|
|
|
addRoleFormData.roleName = "devicemgt" + roleName;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
addRoleFormData.roleName = roleName;
|
|
|
|
addRoleFormData.roleName = roleName;
|
|
|
|
|
|
|
|
}
|
|
|
|
var addRoleAPI = apiBasePath + "/roles/" + encodeURIComponent(currentRoleName);
|
|
|
|
var addRoleAPI = apiBasePath + "/roles/" + encodeURIComponent(currentRoleName);
|
|
|
|
if (domain != "PRIMARY"){
|
|
|
|
if (domain != "PRIMARY") {
|
|
|
|
addRoleFormData.roleName = domain + "/" + roleName;
|
|
|
|
addRoleFormData.roleName = domain + "/" + roleName;
|
|
|
|
addRoleAPI = addRoleAPI + "?user-store=" + encodeURIComponent(domain);
|
|
|
|
addRoleAPI = addRoleAPI + "?user-store=" + encodeURIComponent(domain);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
invokerUtil.put(
|
|
|
|
invokerUtil.put(
|
|
|
|
addRoleAPI,
|
|
|
|
addRoleAPI,
|
|
|
|
addRoleFormData,
|
|
|
|
addRoleFormData,
|
|
|
@ -201,6 +212,7 @@ $(document).ready(function () {
|
|
|
|
$("#role-created-msg").removeClass("hidden");
|
|
|
|
$("#role-created-msg").removeClass("hidden");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, function (data) {
|
|
|
|
}, function (data) {
|
|
|
|
|
|
|
|
|
|
|
|
var payload = JSON.parse(data.responseText);
|
|
|
|
var payload = JSON.parse(data.responseText);
|
|
|
|
$(errorMsg).text(payload.message);
|
|
|
|
$(errorMsg).text(payload.message);
|
|
|
|
$(errorMsgWrapper).removeClass("hidden");
|
|
|
|
$(errorMsgWrapper).removeClass("hidden");
|
|
|
@ -209,11 +221,11 @@ $(document).ready(function () {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$("#rolename").focus(function() {
|
|
|
|
$("#rolename").focus(function () {
|
|
|
|
clearInline["role-name"]();
|
|
|
|
clearInline["role-name"]();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$("#rolename").blur(function() {
|
|
|
|
$("#rolename").blur(function () {
|
|
|
|
validateInline["role-name"]();
|
|
|
|
validateInline["role-name"]();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|