mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge pull request #937 from menakaj/master
Disabled edit button of admin role in role listing page.
This commit is contained in:
commit
286634085b
@ -150,6 +150,8 @@ function loadRoles() {
|
||||
|
||||
var innerhtml = '';
|
||||
|
||||
var isAdminRole = $("#role-table").data("role") === data.name;
|
||||
|
||||
var editLink = '<a onclick="javascript:loadRoleBasedActionURL(\'edit\', \'' + data.name + '\')" ' +
|
||||
'data-role="' + data.name + '" ' +
|
||||
'data-click-event="edit-form" ' +
|
||||
@ -196,7 +198,7 @@ function loadRoles() {
|
||||
'<span class="hidden-xs hidden-on-grid-view">Remove</span>' +
|
||||
'</a>';
|
||||
|
||||
if (!isCloud) {
|
||||
if (!isCloud && !isAdminRole) {
|
||||
innerhtml = editLink + editPermissionLink + removeLink;
|
||||
}
|
||||
return innerhtml;
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
|
||||
function onRequest(context) {
|
||||
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
|
||||
var username = request.getParameter("username");
|
||||
var user = userModule.getUser(username)["content"];
|
||||
var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"];
|
||||
var isExsistingUser = false;
|
||||
var userName = request.getParameter("username");
|
||||
@ -49,7 +47,8 @@ function onRequest(context) {
|
||||
}
|
||||
|
||||
var canEdit = false;
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/users/edit")) {
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/users/edit") &&
|
||||
userName !== deviceMgtProps['adminUser'].split("@")[0]) {
|
||||
canEdit = true;
|
||||
}
|
||||
|
||||
|
||||
@ -19,68 +19,80 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<!-- content -->
|
||||
<div id="role-create-form" data-cloud={{isCloud}} class="container col-centered wr-content">
|
||||
<div class="wr-form">
|
||||
<p class="page-sub-title">Edit Role</p>
|
||||
<p>Please note that * sign represents required fields of data.</p>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<div id="role-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">Domain</label>
|
||||
<div class="wr-input-control">
|
||||
<select id="domain" class="form-control select" disabled>
|
||||
<option>{{userStore}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<label class="wr-input-label">
|
||||
Role Name *
|
||||
</label>
|
||||
<br>
|
||||
<label class="wr-input-label" id="roleNameValidationText">
|
||||
( {{roleNameHelpText}} )
|
||||
</label>
|
||||
{{#if isCloud}}
|
||||
<div id="roleNameField" class="form-group wr-input-control input-group">
|
||||
<!--suppress HtmlFormInputWithoutLabel -->
|
||||
<span class="input-group-addon" id="basic-addon1">devicemgt</span>
|
||||
<input aria-describedby="basic-addon1" type="text" id="rolename"
|
||||
data-regex="{{roleNameJSRegEx}}"
|
||||
data-errormsg="{{roleNameRegExViolationErrorMsg}}" class="form-control"
|
||||
data-currentrole="{{role.roleName}}"
|
||||
value="{{role.roleName}}"/>
|
||||
|
||||
{{else}}
|
||||
<div id="roleNameField" class="form-group wr-input-control">
|
||||
<input type="text" id="rolename" data-regex="{{roleNameJSRegEx}}"
|
||||
data-errormsg="{{roleNameRegExViolationErrorMsg}}" class="form-control"
|
||||
data-currentrole="{{role.roleName}}"
|
||||
value="{{role.roleName}}"/>
|
||||
{{/if}}
|
||||
{{#if isAdminRole}}
|
||||
<div class="container col-centered wr-content">
|
||||
<div class="wr-form">
|
||||
<p class="page-sub-title">Attention!</p>
|
||||
<hr/>
|
||||
<br>This is an prohibited action.
|
||||
</div>
|
||||
</div>
|
||||
{{else}}
|
||||
<div id="role-create-form" data-cloud={{isCloud}} class="container">
|
||||
<div class="wr-form">
|
||||
<p class="page-sub-title">Edit Role</p>
|
||||
<p>Please note that * sign represents required fields of data.</p>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<div id="role-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">Domain</label>
|
||||
<div class="wr-input-control">
|
||||
<select id="domain" class="form-control select" disabled>
|
||||
<option>{{userStore}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<label class="wr-input-label">
|
||||
Role Name *
|
||||
</label>
|
||||
<br>
|
||||
<label class="wr-input-label" id="roleNameValidationText">
|
||||
( {{roleNameHelpText}} )
|
||||
</label>
|
||||
{{#if isCloud}}
|
||||
<div id="roleNameField" class="form-group wr-input-control input-group">
|
||||
<!--suppress HtmlFormInputWithoutLabel -->
|
||||
<span class="input-group-addon" id="basic-addon1">devicemgt</span>
|
||||
<input aria-describedby="basic-addon1" type="text" id="rolename"
|
||||
data-regex="{{roleNameJSRegEx}}"
|
||||
data-errormsg="{{roleNameRegExViolationErrorMsg}}" class="form-control"
|
||||
data-currentrole="{{role.roleName}}"
|
||||
value="{{role.roleName}}"/>
|
||||
</div>
|
||||
{{else}}
|
||||
<div id="roleNameField" class="form-group wr-input-control">
|
||||
<input type="text" id="rolename" data-regex="{{roleNameJSRegEx}}"
|
||||
data-errormsg="{{roleNameRegExViolationErrorMsg}}" class="form-control"
|
||||
data-currentrole="{{role.roleName}}"
|
||||
value="{{role.roleName}}"/>
|
||||
</div>
|
||||
{{/if}}
|
||||
<span class=" rolenameError hidden glyphicon glyphicon-remove form-control-feedback"></span>
|
||||
<label class="error rolenameEmpty hidden" for="summary">Role name is required & Should be in
|
||||
minimum 3 characters long and do not
|
||||
include any whitespaces. </label>
|
||||
minimum 3 characters long and do not
|
||||
include any whitespaces. </label>
|
||||
|
||||
<br>
|
||||
<button id="add-role-btn" class="wr-btn">Update Role</button>
|
||||
|
||||
<div id="role-created-msg" class="container col-centered wr-content hidden">
|
||||
<div class="wr-form">
|
||||
<p class="page-sub-title">Role was updated successfully.</p>
|
||||
<br>You will be redirected to Roles Listing Page in a moment.
|
||||
</div>
|
||||
</div>
|
||||
<!-- /content -->
|
||||
<div id="app-context" data-app-context="{{@app.context}}" class="hidden"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<button id="add-role-btn" class="wr-btn">Update Role</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="role-created-msg" class="container col-centered wr-content hidden">
|
||||
<div class="wr-form">
|
||||
<p class="page-sub-title">Role was updated successfully.</p>
|
||||
<br>You will be redirected to Roles Listing Page in a moment.
|
||||
</div>
|
||||
</div>
|
||||
<!-- /content -->
|
||||
<div id="app-context" data-app-context="{{@app.context}}" class="hidden"></div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
<!-- /content/body -->
|
||||
{{#zone "bottomJs"}}
|
||||
{{js "js/bottomJs.js"}}
|
||||
{{/zone}}
|
||||
</div>
|
||||
<!-- /content/body -->
|
||||
{{#zone "bottomJs"}}
|
||||
{{js "js/bottomJs.js"}}
|
||||
{{/zone}}
|
||||
|
||||
@ -31,6 +31,8 @@ function onRequest(context) {
|
||||
var userStore;
|
||||
context.isCloud = deviceMgtProps.isCloud;
|
||||
|
||||
var isAdminRole = deviceMgtProps["adminRole"] === roleName;
|
||||
|
||||
if (roleName) {
|
||||
if (roleName.indexOf("/") > -1) {
|
||||
userStore = roleName.substr(0, roleName.indexOf("/"));
|
||||
@ -41,6 +43,7 @@ function onRequest(context) {
|
||||
if (response["status"] == "success") {
|
||||
context["role"] = response["content"];
|
||||
}
|
||||
context["isAdminRole"] = isAdminRole;
|
||||
context["userStore"] = userStore;
|
||||
context["roleNameJSRegEx"] = deviceMgtProps["roleValidationConfig"]["roleNameJSRegEx"];
|
||||
context["roleNameHelpText"] = deviceMgtProps["roleValidationConfig"]["roleNameHelpMsg"];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user