mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Adding user create UI
This commit is contained in:
parent
390d929e70
commit
0945c8f547
@ -239,8 +239,7 @@ var userModule = function () {
|
||||
* Get User Roles from user store (Internal roles not included).
|
||||
* @returns {object} a response object with status and content on success.
|
||||
*/
|
||||
publicMethods.getRolesByUserStore = function () {
|
||||
var ROLE_LIMIT = devicemgtProps["pageSize"];
|
||||
publicMethods.getRolesByUserStore = function (userStore) {
|
||||
var carbonUser = session.get(constants["USER_SESSION_KEY"]);
|
||||
var utility = require("/app/modules/utility.js")["utility"];
|
||||
if (!carbonUser) {
|
||||
@ -249,7 +248,8 @@ var userModule = function () {
|
||||
}
|
||||
try {
|
||||
utility.startTenantFlow(carbonUser);
|
||||
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/roles?limit=" + ROLE_LIMIT;
|
||||
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] +
|
||||
"/roles?user-store=" + userStore + "&limit=100";
|
||||
var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
|
||||
if (response.status == "success") {
|
||||
response.content = parse(response.content).roles;
|
||||
|
||||
@ -67,25 +67,19 @@
|
||||
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||
</label>
|
||||
<div id="usernameInputField" class="form-group wr-input-control">
|
||||
<input limit="{{charLimit}}" type="text" id="username" data-regex="{{usernameJSRegEx}}"
|
||||
data-errormsg="{{usernameRegExViolationErrorMsg}}" class="form-control"/>
|
||||
<input limit="{{charLimit}}" type="text" id="username" data-regex="{{usernameJSRegEx}}" data-errormsg="{{usernameRegExViolationErrorMsg}}" class="form-control"/>
|
||||
<span class=" usernameError hidden glyphicon glyphicon-remove form-control-feedback"></span>
|
||||
<label class="error usernameEmpty hidden" for="summary">This field is required. Username
|
||||
should be in minimum 3
|
||||
characters long and do not
|
||||
include any whitespaces.</label>
|
||||
<label class="error usernameEmpty hidden" for="summary">This field is required. Username should be in minimum 3 characters long and do not include any whitespaces.</label>
|
||||
</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"/>
|
||||
<input type="text" id="firstname" data-regex="{{firstnameJSRegEx}}" data-errormsg="{{firstnameRegExViolationErrorMsg}}" class="form-control"/>
|
||||
<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"/>
|
||||
<input type="text" id="lastname" data-regex="{{lastnameJSRegEx}}" data-errormsg="{{lastnameRegExViolationErrorMsg}}" class="form-control"/>
|
||||
<span class="glyphicon glyphicon-remove form-control-feedback hidden lnError"></span>
|
||||
<label class=" hidden error lnError" for="summary">This field is required.</label>
|
||||
</div>
|
||||
@ -121,6 +115,8 @@
|
||||
<p class="page-sub-title">User was added successfully.</p>
|
||||
<br>
|
||||
An invitation mail will be sent to this user to initiate device enrollment.
|
||||
Below QR code can also be used to enroll a device.
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<div class="qr-code col-lg-5 col-md-6 col-centered"></div>
|
||||
|
||||
@ -18,18 +18,16 @@
|
||||
|
||||
/**
|
||||
* Returns the dynamic state to be populated by add-user page.
|
||||
*
|
||||
* @param context Object that gets updated with the dynamic state of this page to be presented
|
||||
* @returns {*} A context object that returns the dynamic state of this page to be presented
|
||||
*/
|
||||
function onRequest(context) {
|
||||
function onRequest() {
|
||||
//var log = new Log("/app/pages/cdmf.page.user.create server-side js");
|
||||
|
||||
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
|
||||
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
|
||||
|
||||
var page = {};
|
||||
var response = userModule.getRolesByUserStore();
|
||||
var response = userModule.getRolesByUserStore("PRIMARY");
|
||||
if (response["status"] == "success") {
|
||||
page["roles"] = response["content"];
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
@ -72,8 +72,8 @@ var disableInlineError = function (inputField, errorMsg, errorSign) {
|
||||
* Validate if provided username is valid against RegEx configures.
|
||||
*/
|
||||
validateInline["user-name"] = function () {
|
||||
var usernameinput = $("input#username");
|
||||
if (inputIsValid(usernameinput.data("regex"), usernameinput.val())) {
|
||||
var usernameInput = $("input#username");
|
||||
if (inputIsValid(usernameInput.data("regex"), usernameInput.val())) {
|
||||
disableInlineError("usernameInputField", "usernameEmpty", "usernameError");
|
||||
} else {
|
||||
enableInlineError("usernameInputField", "usernameEmpty", "usernameError");
|
||||
@ -84,9 +84,9 @@ validateInline["user-name"] = function () {
|
||||
* Validate if provided first name is valid against RegEx configures.
|
||||
*/
|
||||
validateInline["first-name"] = function () {
|
||||
var firstnameinput = $("input#firstname");
|
||||
if (firstnameinput.val()) {
|
||||
disableInlineError("firstNameField", "fnError");
|
||||
var firstnameInput = $("input#firstname");
|
||||
if (firstnameInput.val()) {
|
||||
disableInlineError("firstNameField", "fnError");
|
||||
} else {
|
||||
enableInlineError("firstNameField", "fnError");
|
||||
}
|
||||
@ -96,8 +96,8 @@ validateInline["first-name"] = function () {
|
||||
* Validate if provided last name is valid against RegEx configures.
|
||||
*/
|
||||
validateInline["last-name"] = function () {
|
||||
var lastnameinput = $("input#lastname");
|
||||
if (lastnameinput.val()) {
|
||||
var lastnameInput = $("input#lastname");
|
||||
if (lastnameInput.val()) {
|
||||
disableInlineError("lastNameField", "lnError");
|
||||
} else {
|
||||
enableInlineError("lastNameField", "lnError");
|
||||
@ -165,9 +165,9 @@ $("#userStore").change(
|
||||
function () {
|
||||
var str = "";
|
||||
$("select option:selected").each(function () {
|
||||
str += $(this).text() + " ";
|
||||
str += $(this).text() + "";
|
||||
});
|
||||
var getRolesAPI = deviceMgtAPIsBasePath + "/roles/"+ str;
|
||||
var getRolesAPI = deviceMgtAPIsBasePath + "/roles?user-store=" + str + "&limit=100";
|
||||
|
||||
invokerUtil.get(
|
||||
getRolesAPI,
|
||||
@ -188,8 +188,7 @@ $("#userStore").change(
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
).change();
|
||||
}).change();
|
||||
|
||||
$(document).ready(function () {
|
||||
$("#emailValidationText").hide();
|
||||
@ -207,7 +206,7 @@ $(document).ready(function () {
|
||||
var usernameInput = $("input#username");
|
||||
var firstnameInput = $("input#firstname");
|
||||
var lastnameInput = $("input#lastname");
|
||||
//var charLimit = parseInt($("input#username").attr("limit"));
|
||||
var charLimit = parseInt($("input#username").attr("limit"));
|
||||
var domain = $("#userStore").val();
|
||||
var username = usernameInput.val().trim();
|
||||
var firstname = firstnameInput.val();
|
||||
|
||||
@ -27,8 +27,10 @@ var invokerUtil = function () {
|
||||
restAPIRequestDetails["requestURL"] = requestURL;
|
||||
restAPIRequestDetails["requestPayload"] = JSON.stringify(requestPayload);
|
||||
|
||||
var appContext = $("#app-context").data("app-context");
|
||||
|
||||
var request = {
|
||||
url: context + "/api/invoker/execute/",
|
||||
url: appContext + "/api/invoker/execute/",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(restAPIRequestDetails),
|
||||
|
||||
@ -31,11 +31,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="app-context" data-app-context="{{@app.context}}" class="hidden"></div>
|
||||
{{/zone}}
|
||||
{{#zone "bottomJs"}}
|
||||
<script type="text/javascript">
|
||||
var context = "{{@app.context}}"
|
||||
</script>
|
||||
{{js "js/js.cookie.js"}}
|
||||
{{js "js/invoker-lib.js"}}
|
||||
{{/zone}}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user