Fixing Role Editing UI

revert-70aa11f8
dilanua 8 years ago
parent c57e9eba3a
commit e881aa6da4

@ -308,7 +308,9 @@ var userModule = function () {
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] +
"/roles/" + encodeURIComponent(roleName); "/roles/" + encodeURIComponent(roleName);
var response = privateMethods.callBackend(url, constants["HTTP_GET"]); var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
response.content = parse(response.content); if (response.status == "success") {
response.content = parse(response.content);
}
return response; return response;
} catch (e) { } catch (e) {
throw e; throw e;

@ -26,6 +26,7 @@
</a> </a>
</li> </li>
<li> <li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/roles"> <a href="{{@app.context}}/roles">
Roles Roles
</a> </a>

@ -31,11 +31,8 @@
</div> </div>
<label class="wr-input-label">Domain</label> <label class="wr-input-label">Domain</label>
<div class="wr-input-control"> <div class="wr-input-control">
<select id="domain" class="form-control select"> <select id="domain" class="form-control select" disabled>
<option>PRIMARY</option> <option>{{userStore}}</option>
{{#each userStores}}
<option>{{this}}</option>
{{/each}}
</select> </select>
</div> </div>
<label class="wr-input-label"> <label class="wr-input-label">
@ -52,8 +49,8 @@
value="{{role.roleName}}" /> value="{{role.roleName}}" />
<span class=" rolenameError hidden glyphicon glyphicon-remove form-control-feedback"></span> <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 <label class="error rolenameEmpty hidden" for="summary">Role name is required & Should be in
minimum 3 characters long and do not minimum 3 characters long and do not
include any whitespaces. </label> include any whitespaces. </label>
</div> </div>
</div> </div>
</div> </div>

@ -25,23 +25,31 @@
function onRequest(context) { function onRequest(context) {
var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var uri = request.getRequestURI(); var uri = request.getRequestURI();
var uriMatcher = new URIMatcher(String(uri)); var uriMatcher = new URIMatcher(String(uri));
var isMatched = uriMatcher.match("/{context}/role/edit/{rolename}"); var isMatched = uriMatcher.match("/{context}/role/edit/{roleName}");
if (isMatched) { if (isMatched) {
var matchedElements = uriMatcher.elements(); var matchedElements = uriMatcher.elements();
var roleName = matchedElements.rolename; var roleName = matchedElements["roleName"];
var response = userModule.getRole(roleName); var response = userModule.getRole(roleName);
if (response["status"] == "success") { if (response["status"] == "success") {
context["role"] = response["content"]; context["role"] = response["content"];
} }
var userStores = userModule.getSecondaryUserStores(); var userStore;
context["userStores"] = userStores; if (roleName.indexOf("/") > -1) {
userStore = roleName.substring(0, roleName.indexOf("/"));
} else {
userStore = "PRIMARY";
}
context["userStore"] = userStore;
context["roleNameJSRegEx"] = deviceMgtProps["roleValidationConfig"]["roleNameJSRegEx"];
context["roleNameHelpText"] = deviceMgtProps["roleValidationConfig"]["roleNameHelpMsg"];
context["roleNameRegExViolationErrorMsg"] = deviceMgtProps["roleValidationConfig"]["roleNameRegExViolationErrorMsg"];
return context;
} else {
//TODO: handle error scenario
return context;
} }
//TODO: error scenario
context["roleNameJSRegEx"] = deviceMgtProps.roleValidationConfig.rolenameJSRegEx;
context["roleNameHelpText"] = deviceMgtProps.roleValidationConfig.rolenameHelpMsg;
context["roleNameRegExViolationErrorMsg"] = deviceMgtProps.roleValidationConfig.rolenameRegExViolationErrorMsg;
return context;
} }
Loading…
Cancel
Save