Fix for EMM-1575

4.x.x
kamidu 8 years ago
parent 75df243a33
commit 0ab9db2afd

@ -103,12 +103,12 @@
<label class=" hidden error email-invalid" for="summary">Invalid Email <label class=" hidden error email-invalid" for="summary">Invalid Email
Address.</label> Address.</label>
</div> </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}} {{#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"> <div class="wr-input-control">
<select id="roles" class="form-control select2" multiple="multiple"> <select id="roles" class="form-control select2" multiple="multiple">
{{#each roles}} {{#each roles}}

@ -86,7 +86,7 @@ validateInline["user-name"] = function () {
validateInline["first-name"] = function () { validateInline["first-name"] = function () {
var firstnameInput = $("input#firstname"); var firstnameInput = $("input#firstname");
if (firstnameInput.val()) { if (firstnameInput.val()) {
disableInlineError("firstNameField", "fnError"); disableInlineError("firstNameField", "fnError");
} else { } else {
enableInlineError("firstNameField", "fnError"); enableInlineError("firstNameField", "fnError");
} }
@ -179,27 +179,30 @@ $("#userStore").change(
$("select option:selected").each(function () { $("select option:selected").each(function () {
str += $(this).text() + ""; 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, invokerUtil.get(
function (data) { getRolesAPI,
data = JSON.parse(data); function (data) {
if (data.errorMessage) { data = JSON.parse(data);
$(errorMsg).text("Selected user store prompted an error : " + data.errorMessage); if (data.errorMessage) {
$(errorMsgWrapper).removeClass("hidden"); $(errorMsg).text("Selected user store prompted an error : " + data.errorMessage);
} else if (data["statusCode"] == 200) { $(errorMsgWrapper).removeClass("hidden");
$("#roles").empty(); } else if (data["statusCode"] == 200) {
for (var i = 0; i < data.responseContent.length; i++) { $("#roles").empty();
var newOption = $('<option value="' + data.responseContent[i] + '">' + data.responseContent[i] + '</option>'); for (var i = 0; i < data.responseContent.length; i++) {
$('#roles').append(newOption); var newOption = $('<option value="' + data.responseContent[i] + '">' + data.responseContent[i] + '</option>');
$('#roles').append(newOption);
}
} }
},
function (jqXHR) {
} }
}, );
function (jqXHR) {
} }
);
}).change(); }).change();
$(document).ready(function () { $(document).ready(function () {
@ -224,7 +227,10 @@ $(document).ready(function () {
var firstname = firstnameInput.val(); var firstname = firstnameInput.val();
var lastname = lastnameInput.val(); var lastname = lastnameInput.val();
var emailAddress = $("input#emailAddress").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 errorMsgWrapper = "#user-create-error-msg";
var errorMsg = "#user-create-error-msg span"; var errorMsg = "#user-create-error-msg span";
if (!username) { if (!username) {
@ -272,7 +278,9 @@ $(document).ready(function () {
$("input#firstname").val(""); $("input#firstname").val("");
$("input#lastname").val(""); $("input#lastname").val("");
$("input#email").val(""); $("input#email").val("");
$("select#roles").select2("val", ""); if ($("#roles").length > 0) {
$("select#roles").select2("val", "");
}
// Refreshing with success message // Refreshing with success message
$("#user-create-form").addClass("hidden"); $("#user-create-form").addClass("hidden");
$("#user-created-msg").removeClass("hidden"); $("#user-created-msg").removeClass("hidden");

@ -36,115 +36,119 @@
{{/zone}} {{/zone}}
{{#zone "content"}} {{#zone "content"}}
{{#if canManage}} {{#if canManage}}
<!-- content/body --> <!-- content/body -->
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<!-- content --> <!-- content -->
<div id="user-create-form" class="container col-centered wr-content"> <div id="user-create-form" class="container col-centered wr-content">
<div class="wr-form"> <div class="wr-form">
<p class="page-sub-title">Edit User</p> <p class="page-sub-title">Edit User</p>
<p>Please note that * sign represents required fields of data.</p> <p>Please note that * sign represents required fields of data.</p>
<hr/> <hr/>
<div class="row"> <div class="row">
<div class="col-lg-8"> <div class="col-lg-8">
<div id="user-create-error-msg" class="alert alert-danger hidden" role="alert"> <div id="user-create-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span> <i class="icon fw fw-error"></i><span></span>
</div> </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"> <label class="wr-input-label"
User Store Domain title="Select the domain of the user store from the drop-down given below. The domain of the default user store is PRIMARY">
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span> User Store Domain
</label> <span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
<div class="wr-input-control"> </label>
<select id="userStore" class="form-control select" disabled> <div class="wr-input-control">
<option value="{{userStore}}" selected>{{userStore}}</option> <select id="userStore" class="form-control select" disabled>
</select> <option value="{{userStore}}" selected>{{userStore}}</option>
</div> </select>
<label class="wr-input-label"> </div>
User Name <br> <label class="wr-input-label">
</label> User Name <br>
<div class="wr-input-control"> </label>
<input type="text" id="username" data-regex="{{usernameJSRegEx}}" <div class="wr-input-control">
data-errormsg="{{usernameRegExViolationErrorMsg}}" class="form-control" <input type="text" id="username" data-regex="{{usernameJSRegEx}}"
value="{{editUser.username}}" disabled/> data-errormsg="{{usernameRegExViolationErrorMsg}}" class="form-control"
</div> value="{{editUser.username}}" disabled/>
<label class="wr-input-label">First Name *</label> </div>
<div id="firstNameField" class="form-group wr-input-control"> <label class="wr-input-label">First Name *</label>
<input type="text" id="firstname" data-regex="{{firstnameJSRegEx}}" <div id="firstNameField" class="form-group wr-input-control">
data-errormsg="{{firstnameRegExViolationErrorMsg}}" class="form-control" <input type="text" id="firstname" data-regex="{{firstnameJSRegEx}}"
value="{{editUser.firstname}}"/> data-errormsg="{{firstnameRegExViolationErrorMsg}}" class="form-control"
<span class="glyphicon glyphicon-remove form-control-feedback hidden fnError"></span> value="{{editUser.firstname}}"/>
<label class=" hidden error fnError" for="summary">This field is required.</label> <span class="glyphicon glyphicon-remove form-control-feedback hidden fnError"></span>
</div> <label class=" hidden error fnError" for="summary">This field is required.</label>
<label class="wr-input-label">Last Name *</label> </div>
<div id="lastNameField" class="form-group wr-input-control"> <label class="wr-input-label">Last Name *</label>
<input type="text" id="lastname" data-regex="{{lastnameJSRegEx}}" <div id="lastNameField" class="form-group wr-input-control">
data-errormsg="{{lastnameRegExViolationErrorMsg}}" class="form-control" <input type="text" id="lastname" data-regex="{{lastnameJSRegEx}}"
value="{{editUser.lastname}}"/> data-errormsg="{{lastnameRegExViolationErrorMsg}}" class="form-control"
<span class="glyphicon glyphicon-remove form-control-feedback hidden lnError"></span> value="{{editUser.lastname}}"/>
<label class=" hidden error lnError" for="summary">This field is required.</label> <span class="glyphicon glyphicon-remove form-control-feedback hidden lnError"></span>
</div> <label class=" hidden error lnError" for="summary">This field is required.</label>
<label class="wr-input-label"> </div>
Email Address * <br> <label class="wr-input-label">
( ex: sam@gmail.com ) Email Address * <br>
</label> ( ex: sam@gmail.com )
<div id="emailField" class=" form-group wr-input-control"> </label>
<input type="email" id="emailAddress" class="form-control" <div id="emailField" class=" form-group wr-input-control">
value="{{editUser.emailAddress}}"/> <input type="email" id="emailAddress" class="form-control"
<span class="glyphicon glyphicon-remove form-control-feedback hidden emailError"></span> value="{{editUser.emailAddress}}"/>
<label class=" hidden error email-required" for="summary">This field is <span class="glyphicon glyphicon-remove form-control-feedback hidden emailError"></span>
required.</label> <label class=" hidden error email-required" for="summary">This field is
<label class=" hidden error email-invalid" for="summary">Invalid Email Address.</label> required.</label>
</div> <label class=" hidden error email-invalid" for="summary">Invalid Email
<label class="wr-input-label" Address.</label>
title="Optional field that can have 0-to-many roles for the user"> </div>
User Roles {{#if canViewRoles}}
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span> <label class="wr-input-label"
</label> title="Optional field that can have 0-to-many roles for the user">
<div class="wr-input-control"> User Roles
<select id="roles" class="form-control select2" multiple="multiple" <span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
selectedVals="{{#each rolesByUsername}} {{this}}, {{/each}}"> </label>
{{#each rolesByUserStore}} <div class="wr-input-control">
<option>{{this}}</option> <select id="roles" class="form-control select2" multiple="multiple"
{{/each}} selectedVals="{{#each rolesByUsername}} {{this}}, {{/each}}">
</select> {{#each rolesByUserStore}}
<option>{{this}}</option>
{{/each}}
</select>
</div>
{{/if}}
</div> </div>
</div> </div>
<br>
<button id="add-user-btn" class="wr-btn">Save User</button>
</div> </div>
<br>
<button id="add-user-btn" class="wr-btn">Save User</button>
</div> </div>
</div> <div id="user-created-msg" class="container col-centered wr-content hidden">
<div id="user-created-msg" class="container col-centered wr-content hidden"> <div class="wr-form">
<div class="wr-form"> <p class="page-sub-title">User was updated successfully.</p>
<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 <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. <b>"View User List"</b> to complete the process and go back to the user list.
<hr/> <hr/>
<button class="wr-btn" onclick="window.location.href='{{@app.context}}/users'">View User List <button class="wr-btn" onclick="window.location.href='{{@app.context}}/users'">View User List
</button> </button>
<a href="{{@app.context}}/user/view?username={{editUser.username}}" class="cu-btn-inner"> <a href="{{@app.context}}/user/view?username={{editUser.username}}" class="cu-btn-inner">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-view fw-stack-1x"></i> <i class="fw fw-view fw-stack-1x"></i>
</span> </span>
View Updated User View Updated User
</a> </a>
</div>
</div> </div>
<!-- /content -->
</div> </div>
<!-- /content -->
</div> </div>
</div> <!-- /content/body -->
<!-- /content/body --> {{else}}
{{else}} <h1 class="page-sub-title">
<h1 class="page-sub-title"> Permission Denied
Permission Denied </h1>
</h1> <br>
<br> You not authorized to enter User Management Section.
You not authorized to enter User Management Section. <br>
<br> {{/if}}
{{/if}}
{{/zone}} {{/zone}}

@ -22,7 +22,7 @@ function onRequest() {
var userName = request.getParameter("username"); var userName = request.getParameter("username");
var user = userModule.getUser(userName)["content"]; var user = userModule.getUser(userName)["content"];
if (user) { if (user) {
var title; var title;
if (user.firstname && user.lastname) { if (user.firstname && user.lastname) {
@ -63,6 +63,9 @@ function onRequest() {
if (userModule.isAuthorized("/permission/admin/device-mgt/users/manage")) { if (userModule.isAuthorized("/permission/admin/device-mgt/users/manage")) {
page.canManage = true; page.canManage = true;
} }
if (userModule.isAuthorized("/permission/admin/device-mgt/roles/view")) {
page.canViewRoles = true;
}
page["usernameJSRegEx"] = devicemgtProps["userValidationConfig"]["usernameJSRegEx"]; page["usernameJSRegEx"] = devicemgtProps["userValidationConfig"]["usernameJSRegEx"];
page["usernameRegExViolationErrorMsg"] = devicemgtProps["userValidationConfig"]["usernameRegExViolationErrorMsg"]; page["usernameRegExViolationErrorMsg"] = devicemgtProps["userValidationConfig"]["usernameRegExViolationErrorMsg"];

@ -75,7 +75,7 @@ var disableInlineError = function (inputField, errorMsg, errorSign) {
*/ */
validateInline["user-name"] = function () { validateInline["user-name"] = function () {
var usernameinput = $("input#username"); var usernameinput = $("input#username");
if (inputIsValid( usernameinput.data("regex"), usernameinput.val())) { if (inputIsValid(usernameinput.data("regex"), usernameinput.val())) {
disableInlineError("usernameInputField", "usernameEmpty", "usernameError"); disableInlineError("usernameInputField", "usernameEmpty", "usernameError");
} else { } else {
enableInlineError("usernameInputField", "usernameEmpty", "usernameError"); enableInlineError("usernameInputField", "usernameEmpty", "usernameError");
@ -113,12 +113,12 @@ validateInline["last-name"] = function () {
validateInline["emailAddress"] = function () { validateInline["emailAddress"] = function () {
var email = $("#emailAddress").val(); var email = $("#emailAddress").val();
if (!email) { if (!email) {
enableInlineError("emailField", "email-required" , "emailError"); enableInlineError("emailField", "email-required", "emailError");
} else if (emailIsValid(email)) { } else if (emailIsValid(email)) {
disableInlineError("emailField", "email-required" , "emailError"); disableInlineError("emailField", "email-required", "emailError");
disableInlineError("emailField", "email-invalid" , "emailError"); disableInlineError("emailField", "email-invalid", "emailError");
} else { } 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. * clear Validation messages when gain focus to the field.
*/ */
clearInline["emailAddress"] = function () { clearInline["emailAddress"] = function () {
disableInlineError("emailField", "email-required" , "emailError"); disableInlineError("emailField", "email-required", "emailError");
disableInlineError("emailField", "email-invalid" , "emailError"); disableInlineError("emailField", "email-invalid", "emailError");
}; };
/** /**
@ -168,11 +168,16 @@ $(document).ready(function () {
$("select.select2[multiple=multiple]").select2({ $("select.select2[multiple=multiple]").select2({
tags: false tags: false
}); });
var roleList = $("#roles").attr("selectedVals").trim().replace(/ /g, ""); var roleList, roleArr;
roleList = roleList.replace(/(\r\n|\n|\r)/gm, ""); if ($("#roles").length > 0) {
var roleArr = roleList.split(","); roleList = $("#roles").attr("selectedVals").trim().replace(/ /g, "");
$("#roles").val(roleArr).trigger("change"); 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 * Following click function would execute
* when a user clicks on "Add User" button * when a user clicks on "Add User" button
@ -188,7 +193,10 @@ $(document).ready(function () {
var firstname = firstnameInput.val(); var firstname = firstnameInput.val();
var lastname = lastnameInput.val(); var lastname = lastnameInput.val();
var emailAddress = $("input#emailAddress").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 errorMsgWrapper = "#user-create-error-msg";
var errorMsg = "#user-create-error-msg span"; var errorMsg = "#user-create-error-msg span";
if (!username) { if (!username) {
@ -255,27 +263,27 @@ $(document).ready(function () {
} }
}); });
$("#emailAddress").focus(function() { $("#emailAddress").focus(function () {
clearInline["emailAddress"](); clearInline["emailAddress"]();
}); });
$("#emailAddress").blur(function() { $("#emailAddress").blur(function () {
validateInline["emailAddress"](); validateInline["emailAddress"]();
}); });
$("#lastname").focus(function() { $("#lastname").focus(function () {
clearInline["last-name"](); clearInline["last-name"]();
}); });
$("#lastname").blur(function() { $("#lastname").blur(function () {
validateInline["last-name"](); validateInline["last-name"]();
}); });
$("#firstname").focus(function() { $("#firstname").focus(function () {
clearInline["first-name"](); clearInline["first-name"]();
}); });
$("#firstname").blur(function() { $("#firstname").blur(function () {
validateInline["first-name"](); validateInline["first-name"]();
}); });
}); });
Loading…
Cancel
Save