mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Fix for EMM-1575
This commit is contained in:
parent
75df243a33
commit
0ab9db2afd
@ -103,12 +103,12 @@
|
||||
<label class=" hidden error email-invalid" for="summary">Invalid Email
|
||||
Address.</label>
|
||||
</div>
|
||||
<label class="wr-input-label"
|
||||
title="Optional field that can have 0-to-many roles for the user">
|
||||
User Roles
|
||||
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||
</label>
|
||||
{{#if canViewRoles}}
|
||||
<label class="wr-input-label"
|
||||
title="Optional field that can have 0-to-many roles for the user">
|
||||
User Roles
|
||||
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||
</label>
|
||||
<div class="wr-input-control">
|
||||
<select id="roles" class="form-control select2" multiple="multiple">
|
||||
{{#each roles}}
|
||||
|
||||
@ -86,7 +86,7 @@ validateInline["user-name"] = function () {
|
||||
validateInline["first-name"] = function () {
|
||||
var firstnameInput = $("input#firstname");
|
||||
if (firstnameInput.val()) {
|
||||
disableInlineError("firstNameField", "fnError");
|
||||
disableInlineError("firstNameField", "fnError");
|
||||
} else {
|
||||
enableInlineError("firstNameField", "fnError");
|
||||
}
|
||||
@ -179,27 +179,30 @@ $("#userStore").change(
|
||||
$("select option:selected").each(function () {
|
||||
str += $(this).text() + "";
|
||||
});
|
||||
var getRolesAPI = deviceMgtAPIsBasePath + "/roles?user-store=" + str + "&limit=100";
|
||||
if ($("#roles").length > 0) {
|
||||
var getRolesAPI = deviceMgtAPIsBasePath + "/roles?user-store=" + str + "&limit=100";
|
||||
|
||||
invokerUtil.get(
|
||||
getRolesAPI,
|
||||
function (data) {
|
||||
data = JSON.parse(data);
|
||||
if (data.errorMessage) {
|
||||
$(errorMsg).text("Selected user store prompted an error : " + data.errorMessage);
|
||||
$(errorMsgWrapper).removeClass("hidden");
|
||||
} else if (data["statusCode"] == 200) {
|
||||
$("#roles").empty();
|
||||
for (var i = 0; i < data.responseContent.length; i++) {
|
||||
var newOption = $('<option value="' + data.responseContent[i] + '">' + data.responseContent[i] + '</option>');
|
||||
$('#roles').append(newOption);
|
||||
invokerUtil.get(
|
||||
getRolesAPI,
|
||||
function (data) {
|
||||
data = JSON.parse(data);
|
||||
if (data.errorMessage) {
|
||||
$(errorMsg).text("Selected user store prompted an error : " + data.errorMessage);
|
||||
$(errorMsgWrapper).removeClass("hidden");
|
||||
} else if (data["statusCode"] == 200) {
|
||||
$("#roles").empty();
|
||||
for (var i = 0; i < data.responseContent.length; i++) {
|
||||
var newOption = $('<option value="' + data.responseContent[i] + '">' + data.responseContent[i] + '</option>');
|
||||
$('#roles').append(newOption);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
function (jqXHR) {
|
||||
},
|
||||
function (jqXHR) {
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
}).change();
|
||||
|
||||
$(document).ready(function () {
|
||||
@ -224,7 +227,10 @@ $(document).ready(function () {
|
||||
var firstname = firstnameInput.val();
|
||||
var lastname = lastnameInput.val();
|
||||
var emailAddress = $("input#emailAddress").val();
|
||||
var roles = $("select#roles").val();
|
||||
var roles ;
|
||||
if ($("#roles").length > 0) {
|
||||
roles = $("select#roles").val();
|
||||
}
|
||||
var errorMsgWrapper = "#user-create-error-msg";
|
||||
var errorMsg = "#user-create-error-msg span";
|
||||
if (!username) {
|
||||
@ -272,7 +278,9 @@ $(document).ready(function () {
|
||||
$("input#firstname").val("");
|
||||
$("input#lastname").val("");
|
||||
$("input#email").val("");
|
||||
$("select#roles").select2("val", "");
|
||||
if ($("#roles").length > 0) {
|
||||
$("select#roles").select2("val", "");
|
||||
}
|
||||
// Refreshing with success message
|
||||
$("#user-create-form").addClass("hidden");
|
||||
$("#user-created-msg").removeClass("hidden");
|
||||
|
||||
@ -36,115 +36,119 @@
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "content"}}
|
||||
{{#if canManage}}
|
||||
<!-- content/body -->
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<!-- content -->
|
||||
<div id="user-create-form" class="container col-centered wr-content">
|
||||
<div class="wr-form">
|
||||
<p class="page-sub-title">Edit User</p>
|
||||
<p>Please note that * sign represents required fields of data.</p>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<div id="user-create-error-msg" class="alert alert-danger hidden" role="alert">
|
||||
<i class="icon fw fw-error"></i><span></span>
|
||||
</div>
|
||||
<label class="wr-input-label" title="Select the domain of the user store from the drop-down given below. The domain of the default user store is PRIMARY">
|
||||
User Store Domain
|
||||
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||
</label>
|
||||
<div class="wr-input-control">
|
||||
<select id="userStore" class="form-control select" disabled>
|
||||
<option value="{{userStore}}" selected>{{userStore}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<label class="wr-input-label">
|
||||
User Name <br>
|
||||
</label>
|
||||
<div class="wr-input-control">
|
||||
<input type="text" id="username" data-regex="{{usernameJSRegEx}}"
|
||||
data-errormsg="{{usernameRegExViolationErrorMsg}}" class="form-control"
|
||||
value="{{editUser.username}}" disabled/>
|
||||
</div>
|
||||
<label class="wr-input-label">First Name *</label>
|
||||
<div id="firstNameField" class="form-group wr-input-control">
|
||||
<input type="text" id="firstname" data-regex="{{firstnameJSRegEx}}"
|
||||
data-errormsg="{{firstnameRegExViolationErrorMsg}}" class="form-control"
|
||||
value="{{editUser.firstname}}"/>
|
||||
<span class="glyphicon glyphicon-remove form-control-feedback hidden fnError"></span>
|
||||
<label class=" hidden error fnError" for="summary">This field is required.</label>
|
||||
</div>
|
||||
<label class="wr-input-label">Last Name *</label>
|
||||
<div id="lastNameField" class="form-group wr-input-control">
|
||||
<input type="text" id="lastname" data-regex="{{lastnameJSRegEx}}"
|
||||
data-errormsg="{{lastnameRegExViolationErrorMsg}}" class="form-control"
|
||||
value="{{editUser.lastname}}"/>
|
||||
<span class="glyphicon glyphicon-remove form-control-feedback hidden lnError"></span>
|
||||
<label class=" hidden error lnError" for="summary">This field is required.</label>
|
||||
</div>
|
||||
<label class="wr-input-label">
|
||||
Email Address * <br>
|
||||
( ex: sam@gmail.com )
|
||||
</label>
|
||||
<div id="emailField" class=" form-group wr-input-control">
|
||||
<input type="email" id="emailAddress" class="form-control"
|
||||
value="{{editUser.emailAddress}}"/>
|
||||
<span class="glyphicon glyphicon-remove form-control-feedback hidden emailError"></span>
|
||||
<label class=" hidden error email-required" for="summary">This field is
|
||||
required.</label>
|
||||
<label class=" hidden error email-invalid" for="summary">Invalid Email Address.</label>
|
||||
</div>
|
||||
<label class="wr-input-label"
|
||||
title="Optional field that can have 0-to-many roles for the user">
|
||||
User Roles
|
||||
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||
</label>
|
||||
<div class="wr-input-control">
|
||||
<select id="roles" class="form-control select2" multiple="multiple"
|
||||
selectedVals="{{#each rolesByUsername}} {{this}}, {{/each}}">
|
||||
{{#each rolesByUserStore}}
|
||||
<option>{{this}}</option>
|
||||
{{/each}}
|
||||
</select>
|
||||
{{#if canManage}}
|
||||
<!-- content/body -->
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<!-- content -->
|
||||
<div id="user-create-form" class="container col-centered wr-content">
|
||||
<div class="wr-form">
|
||||
<p class="page-sub-title">Edit User</p>
|
||||
<p>Please note that * sign represents required fields of data.</p>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<div id="user-create-error-msg" class="alert alert-danger hidden" role="alert">
|
||||
<i class="icon fw fw-error"></i><span></span>
|
||||
</div>
|
||||
<label class="wr-input-label"
|
||||
title="Select the domain of the user store from the drop-down given below. The domain of the default user store is PRIMARY">
|
||||
User Store Domain
|
||||
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||
</label>
|
||||
<div class="wr-input-control">
|
||||
<select id="userStore" class="form-control select" disabled>
|
||||
<option value="{{userStore}}" selected>{{userStore}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<label class="wr-input-label">
|
||||
User Name <br>
|
||||
</label>
|
||||
<div class="wr-input-control">
|
||||
<input type="text" id="username" data-regex="{{usernameJSRegEx}}"
|
||||
data-errormsg="{{usernameRegExViolationErrorMsg}}" class="form-control"
|
||||
value="{{editUser.username}}" disabled/>
|
||||
</div>
|
||||
<label class="wr-input-label">First Name *</label>
|
||||
<div id="firstNameField" class="form-group wr-input-control">
|
||||
<input type="text" id="firstname" data-regex="{{firstnameJSRegEx}}"
|
||||
data-errormsg="{{firstnameRegExViolationErrorMsg}}" class="form-control"
|
||||
value="{{editUser.firstname}}"/>
|
||||
<span class="glyphicon glyphicon-remove form-control-feedback hidden fnError"></span>
|
||||
<label class=" hidden error fnError" for="summary">This field is required.</label>
|
||||
</div>
|
||||
<label class="wr-input-label">Last Name *</label>
|
||||
<div id="lastNameField" class="form-group wr-input-control">
|
||||
<input type="text" id="lastname" data-regex="{{lastnameJSRegEx}}"
|
||||
data-errormsg="{{lastnameRegExViolationErrorMsg}}" class="form-control"
|
||||
value="{{editUser.lastname}}"/>
|
||||
<span class="glyphicon glyphicon-remove form-control-feedback hidden lnError"></span>
|
||||
<label class=" hidden error lnError" for="summary">This field is required.</label>
|
||||
</div>
|
||||
<label class="wr-input-label">
|
||||
Email Address * <br>
|
||||
( ex: sam@gmail.com )
|
||||
</label>
|
||||
<div id="emailField" class=" form-group wr-input-control">
|
||||
<input type="email" id="emailAddress" class="form-control"
|
||||
value="{{editUser.emailAddress}}"/>
|
||||
<span class="glyphicon glyphicon-remove form-control-feedback hidden emailError"></span>
|
||||
<label class=" hidden error email-required" for="summary">This field is
|
||||
required.</label>
|
||||
<label class=" hidden error email-invalid" for="summary">Invalid Email
|
||||
Address.</label>
|
||||
</div>
|
||||
{{#if canViewRoles}}
|
||||
<label class="wr-input-label"
|
||||
title="Optional field that can have 0-to-many roles for the user">
|
||||
User Roles
|
||||
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||
</label>
|
||||
<div class="wr-input-control">
|
||||
<select id="roles" class="form-control select2" multiple="multiple"
|
||||
selectedVals="{{#each rolesByUsername}} {{this}}, {{/each}}">
|
||||
{{#each rolesByUserStore}}
|
||||
<option>{{this}}</option>
|
||||
{{/each}}
|
||||
</select>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<button id="add-user-btn" class="wr-btn">Save User</button>
|
||||
</div>
|
||||
<br>
|
||||
<button id="add-user-btn" class="wr-btn">Save User</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="user-created-msg" class="container col-centered wr-content hidden">
|
||||
<div class="wr-form">
|
||||
<p class="page-sub-title">User was updated successfully.</p>
|
||||
<div id="user-created-msg" class="container col-centered wr-content hidden">
|
||||
<div class="wr-form">
|
||||
<p class="page-sub-title">User was updated successfully.</p>
|
||||
|
||||
<br>Please click <b>"View Updated User"</b>, if you wish to view the updated user or click
|
||||
<b>"View User List"</b> to complete the process and go back to the user list.
|
||||
<hr/>
|
||||
<button class="wr-btn" onclick="window.location.href='{{@app.context}}/users'">View User List
|
||||
</button>
|
||||
<a href="{{@app.context}}/user/view?username={{editUser.username}}" class="cu-btn-inner">
|
||||
<br>Please click <b>"View Updated User"</b>, if you wish to view the updated user or click
|
||||
<b>"View User List"</b> to complete the process and go back to the user list.
|
||||
<hr/>
|
||||
<button class="wr-btn" onclick="window.location.href='{{@app.context}}/users'">View User List
|
||||
</button>
|
||||
<a href="{{@app.context}}/user/view?username={{editUser.username}}" class="cu-btn-inner">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-view fw-stack-1x"></i>
|
||||
</span>
|
||||
View Updated User
|
||||
</a>
|
||||
View Updated User
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /content -->
|
||||
</div>
|
||||
<!-- /content -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- /content/body -->
|
||||
{{else}}
|
||||
<h1 class="page-sub-title">
|
||||
Permission Denied
|
||||
</h1>
|
||||
<br>
|
||||
You not authorized to enter User Management Section.
|
||||
<br>
|
||||
{{/if}}
|
||||
<!-- /content/body -->
|
||||
{{else}}
|
||||
<h1 class="page-sub-title">
|
||||
Permission Denied
|
||||
</h1>
|
||||
<br>
|
||||
You not authorized to enter User Management Section.
|
||||
<br>
|
||||
{{/if}}
|
||||
|
||||
{{/zone}}
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ function onRequest() {
|
||||
|
||||
var userName = request.getParameter("username");
|
||||
var user = userModule.getUser(userName)["content"];
|
||||
|
||||
|
||||
if (user) {
|
||||
var title;
|
||||
if (user.firstname && user.lastname) {
|
||||
@ -63,6 +63,9 @@ function onRequest() {
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/users/manage")) {
|
||||
page.canManage = true;
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/roles/view")) {
|
||||
page.canViewRoles = true;
|
||||
}
|
||||
|
||||
page["usernameJSRegEx"] = devicemgtProps["userValidationConfig"]["usernameJSRegEx"];
|
||||
page["usernameRegExViolationErrorMsg"] = devicemgtProps["userValidationConfig"]["usernameRegExViolationErrorMsg"];
|
||||
|
||||
@ -75,7 +75,7 @@ var disableInlineError = function (inputField, errorMsg, errorSign) {
|
||||
*/
|
||||
validateInline["user-name"] = function () {
|
||||
var usernameinput = $("input#username");
|
||||
if (inputIsValid( usernameinput.data("regex"), usernameinput.val())) {
|
||||
if (inputIsValid(usernameinput.data("regex"), usernameinput.val())) {
|
||||
disableInlineError("usernameInputField", "usernameEmpty", "usernameError");
|
||||
} else {
|
||||
enableInlineError("usernameInputField", "usernameEmpty", "usernameError");
|
||||
@ -113,12 +113,12 @@ validateInline["last-name"] = function () {
|
||||
validateInline["emailAddress"] = function () {
|
||||
var email = $("#emailAddress").val();
|
||||
if (!email) {
|
||||
enableInlineError("emailField", "email-required" , "emailError");
|
||||
enableInlineError("emailField", "email-required", "emailError");
|
||||
} else if (emailIsValid(email)) {
|
||||
disableInlineError("emailField", "email-required" , "emailError");
|
||||
disableInlineError("emailField", "email-invalid" , "emailError");
|
||||
disableInlineError("emailField", "email-required", "emailError");
|
||||
disableInlineError("emailField", "email-invalid", "emailError");
|
||||
} else {
|
||||
enableInlineError("emailField", "email-invalid" , "emailError");
|
||||
enableInlineError("emailField", "email-invalid", "emailError");
|
||||
}
|
||||
};
|
||||
|
||||
@ -148,8 +148,8 @@ clearInline["last-name"] = function () {
|
||||
* clear Validation messages when gain focus to the field.
|
||||
*/
|
||||
clearInline["emailAddress"] = function () {
|
||||
disableInlineError("emailField", "email-required" , "emailError");
|
||||
disableInlineError("emailField", "email-invalid" , "emailError");
|
||||
disableInlineError("emailField", "email-required", "emailError");
|
||||
disableInlineError("emailField", "email-invalid", "emailError");
|
||||
};
|
||||
|
||||
/**
|
||||
@ -168,11 +168,16 @@ $(document).ready(function () {
|
||||
$("select.select2[multiple=multiple]").select2({
|
||||
tags: false
|
||||
});
|
||||
var roleList = $("#roles").attr("selectedVals").trim().replace(/ /g, "");
|
||||
roleList = roleList.replace(/(\r\n|\n|\r)/gm, "");
|
||||
var roleArr = roleList.split(",");
|
||||
$("#roles").val(roleArr).trigger("change");
|
||||
var roleList, roleArr;
|
||||
if ($("#roles").length > 0) {
|
||||
roleList = $("#roles").attr("selectedVals").trim().replace(/ /g, "");
|
||||
roleList = roleList.replace(/(\r\n|\n|\r)/gm, "");
|
||||
roleArr = roleList.split(",");
|
||||
}
|
||||
|
||||
if ($("#roles").length > 0) {
|
||||
$("#roles").val(roleArr).trigger("change");
|
||||
}
|
||||
/**
|
||||
* Following click function would execute
|
||||
* when a user clicks on "Add User" button
|
||||
@ -188,7 +193,10 @@ $(document).ready(function () {
|
||||
var firstname = firstnameInput.val();
|
||||
var lastname = lastnameInput.val();
|
||||
var emailAddress = $("input#emailAddress").val();
|
||||
var roles = $("select#roles").val();
|
||||
var roles;
|
||||
if ($("#roles").length > 0) {
|
||||
var roles = $("select#roles").val();
|
||||
}
|
||||
var errorMsgWrapper = "#user-create-error-msg";
|
||||
var errorMsg = "#user-create-error-msg span";
|
||||
if (!username) {
|
||||
@ -255,27 +263,27 @@ $(document).ready(function () {
|
||||
}
|
||||
});
|
||||
|
||||
$("#emailAddress").focus(function() {
|
||||
$("#emailAddress").focus(function () {
|
||||
clearInline["emailAddress"]();
|
||||
});
|
||||
|
||||
$("#emailAddress").blur(function() {
|
||||
$("#emailAddress").blur(function () {
|
||||
validateInline["emailAddress"]();
|
||||
});
|
||||
|
||||
$("#lastname").focus(function() {
|
||||
$("#lastname").focus(function () {
|
||||
clearInline["last-name"]();
|
||||
});
|
||||
|
||||
$("#lastname").blur(function() {
|
||||
$("#lastname").blur(function () {
|
||||
validateInline["last-name"]();
|
||||
});
|
||||
|
||||
$("#firstname").focus(function() {
|
||||
$("#firstname").focus(function () {
|
||||
clearInline["first-name"]();
|
||||
});
|
||||
|
||||
$("#firstname").blur(function() {
|
||||
$("#firstname").blur(function () {
|
||||
validateInline["first-name"]();
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user