revert-70aa11f8
harshanl 8 years ago
commit c448d915d8

@ -22,7 +22,7 @@ deviceModule = function () {
var utility = require('/app/modules/utility.js').utility; var utility = require('/app/modules/utility.js').utility;
var constants = require('/app/modules/constants.js'); var constants = require('/app/modules/constants.js');
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
// var ArrayList = Packages.java.util.ArrayList; // var ArrayList = Packages.java.util.ArrayList;
@ -33,6 +33,8 @@ deviceModule = function () {
// var ConfigOperation = Packages.org.wso2.carbon.device.mgt.core.operation.mgt.ConfigOperation; // var ConfigOperation = Packages.org.wso2.carbon.device.mgt.core.operation.mgt.ConfigOperation;
// var CommandOperation = Packages.org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; // var CommandOperation = Packages.org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
var deviceManagementService = utility.getDeviceManagementService();
var publicMethods = {}; var publicMethods = {};
var privateMethods = {}; var privateMethods = {};
@ -215,18 +217,20 @@ deviceModule = function () {
var utility = require('/app/modules/utility.js')["utility"]; var utility = require('/app/modules/utility.js')["utility"];
try { try {
utility.startTenantFlow(carbonUser); utility.startTenantFlow(carbonUser);
//var url = mdmProps["httpsURL"] + "/mdm-admin/devices/view?type=" + deviceType + "&id=" + deviceId;
var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/view?type=" + deviceType + "&id=" + deviceId; var url = mdmProps["httpsURL"] + "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId;
return serviceInvokers.XMLHttp.get( return serviceInvokers.XMLHttp.get(
url, function (responsePayload) { url,
var device = responsePayload.responseContent; function (backendResponse) {
if (device) { var response = {};
if (backendResponse.status == 200 && backendResponse.responseText) {
response["status"] = "success";
var device = parse(backendResponse.responseText);
var propertiesList = device["properties"]; var propertiesList = device["properties"];
var properties = {}; var properties = {};
if (propertiesList){
for (var i = 0; i < propertiesList.length; i++) { for (var i = 0; i < propertiesList.length; i++) {
properties[propertiesList[i]["name"]] = propertiesList[i]["value"]; properties[propertiesList[i]["name"]] =
} propertiesList[i]["value"];
} }
var deviceObject = {}; var deviceObject = {};
deviceObject[constants["DEVICE_IDENTIFIER"]] = device["deviceIdentifier"]; deviceObject[constants["DEVICE_IDENTIFIER"]] = device["deviceIdentifier"];
@ -241,14 +245,13 @@ deviceModule = function () {
properties[constants["DEVICE_VENDOR"]] = constants["VENDOR_APPLE"]; properties[constants["DEVICE_VENDOR"]] = constants["VENDOR_APPLE"];
} }
deviceObject[constants["DEVICE_PROPERTIES"]] = properties; deviceObject[constants["DEVICE_PROPERTIES"]] = properties;
return deviceObject; response["content"] = deviceObject;
} return response;
}, } else {
function (responsePayload) {
var response = {};
response["status"] = "error"; response["status"] = "error";
return response; return response;
} }
}
); );
} catch (e) { } catch (e) {
throw e; throw e;
@ -310,9 +313,9 @@ deviceModule = function () {
var url; var url;
var license; var license;
if (deviceType == "windows") { if (deviceType == "windows") {
url = devicemgtProps["httpURL"] + "/mdm-windows-agent/services/device/license"; url = mdmProps["httpURL"] + "/mdm-windows-agent/services/device/license";
} else if (deviceType == "ios") { } else if (deviceType == "ios") {
url = devicemgtProps["httpsURL"] + "/ios-enrollment/license/"; url = mdmProps["httpsURL"] + "/ios-enrollment/license/";
} }
if (url != null && url != undefined) { if (url != null && url != undefined) {

@ -239,8 +239,7 @@ var userModule = function () {
* Get User Roles from user store (Internal roles not included). * Get User Roles from user store (Internal roles not included).
* @returns {object} a response object with status and content on success. * @returns {object} a response object with status and content on success.
*/ */
publicMethods.getRolesByUserStore = function () { publicMethods.getRolesByUserStore = function (userStore) {
var ROLE_LIMIT = devicemgtProps["pageSize"];
var carbonUser = session.get(constants["USER_SESSION_KEY"]); var carbonUser = session.get(constants["USER_SESSION_KEY"]);
var utility = require("/app/modules/utility.js")["utility"]; var utility = require("/app/modules/utility.js")["utility"];
if (!carbonUser) { if (!carbonUser) {
@ -249,7 +248,8 @@ var userModule = function () {
} }
try { try {
utility.startTenantFlow(carbonUser); 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"]); var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
if (response.status == "success") { if (response.status == "success") {
response.content = parse(response.content).roles; response.content = parse(response.content).roles;

@ -67,25 +67,19 @@
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span> <span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
</label> </label>
<div id="usernameInputField" class="form-group wr-input-control"> <div id="usernameInputField" class="form-group wr-input-control">
<input limit="{{charLimit}}" type="text" id="username" data-regex="{{usernameJSRegEx}}" <input limit="{{charLimit}}" type="text" id="username" data-regex="{{usernameJSRegEx}}" data-errormsg="{{usernameRegExViolationErrorMsg}}" class="form-control"/>
data-errormsg="{{usernameRegExViolationErrorMsg}}" class="form-control"/>
<span class=" usernameError hidden glyphicon glyphicon-remove form-control-feedback"></span> <span class=" usernameError hidden glyphicon glyphicon-remove form-control-feedback"></span>
<label class="error usernameEmpty hidden" for="summary">This field is required. Username <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>
should be in minimum 3
characters long and do not
include any whitespaces.</label>
</div> </div>
<label class="wr-input-label">First Name *</label> <label class="wr-input-label">First Name *</label>
<div id="firstNameField" class="form-group wr-input-control"> <div id="firstNameField" class="form-group wr-input-control">
<input type="text" id="firstname" data-regex="{{firstnameJSRegEx}}" <input type="text" id="firstname" data-regex="{{firstnameJSRegEx}}" data-errormsg="{{firstnameRegExViolationErrorMsg}}" class="form-control"/>
data-errormsg="{{firstnameRegExViolationErrorMsg}}" class="form-control"/>
<span class="glyphicon glyphicon-remove form-control-feedback hidden fnError"></span> <span class="glyphicon glyphicon-remove form-control-feedback hidden fnError"></span>
<label class=" hidden error fnError" for="summary">This field is required.</label> <label class=" hidden error fnError" for="summary">This field is required.</label>
</div> </div>
<label class="wr-input-label">Last Name *</label> <label class="wr-input-label">Last Name *</label>
<div id="lastNameField" class="form-group wr-input-control"> <div id="lastNameField" class="form-group wr-input-control">
<input type="text" id="lastname" data-regex="{{lastnameJSRegEx}}" <input type="text" id="lastname" data-regex="{{lastnameJSRegEx}}" data-errormsg="{{lastnameRegExViolationErrorMsg}}" class="form-control"/>
data-errormsg="{{lastnameRegExViolationErrorMsg}}" class="form-control"/>
<span class="glyphicon glyphicon-remove form-control-feedback hidden lnError"></span> <span class="glyphicon glyphicon-remove form-control-feedback hidden lnError"></span>
<label class=" hidden error lnError" for="summary">This field is required.</label> <label class=" hidden error lnError" for="summary">This field is required.</label>
</div> </div>
@ -121,6 +115,8 @@
<p class="page-sub-title">User was added successfully.</p> <p class="page-sub-title">User was added successfully.</p>
<br> <br>
An invitation mail will be sent to this user to initiate device enrollment. 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 panel-default">
<div class="panel-body"> <div class="panel-body">
<div class="qr-code col-lg-5 col-md-6 col-centered"></div> <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. * 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 * @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 log = new Log("/app/pages/cdmf.page.user.create server-side js");
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 page = {}; var page = {};
var response = userModule.getRolesByUserStore(); var response = userModule.getRolesByUserStore("PRIMARY");
if (response["status"] == "success") { if (response["status"] == "success") {
page["roles"] = response["content"]; 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, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * 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. * Validate if provided username is valid against RegEx configures.
*/ */
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");
@ -84,8 +84,8 @@ validateInline["user-name"] = function () {
* Validate if provided first name is valid against RegEx configures. * Validate if provided first name is valid against RegEx configures.
*/ */
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");
@ -96,8 +96,8 @@ validateInline["first-name"] = function () {
* Validate if provided last name is valid against RegEx configures. * Validate if provided last name is valid against RegEx configures.
*/ */
validateInline["last-name"] = function () { validateInline["last-name"] = function () {
var lastnameinput = $("input#lastname"); var lastnameInput = $("input#lastname");
if (lastnameinput.val()) { if (lastnameInput.val()) {
disableInlineError("lastNameField", "lnError"); disableInlineError("lastNameField", "lnError");
} else { } else {
enableInlineError("lastNameField", "lnError"); enableInlineError("lastNameField", "lnError");
@ -167,7 +167,7 @@ $("#userStore").change(
$("select option:selected").each(function () { $("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( invokerUtil.get(
getRolesAPI, getRolesAPI,
@ -188,8 +188,7 @@ $("#userStore").change(
} }
); );
} }).change();
).change();
$(document).ready(function () { $(document).ready(function () {
$("#emailValidationText").hide(); $("#emailValidationText").hide();
@ -207,7 +206,7 @@ $(document).ready(function () {
var usernameInput = $("input#username"); var usernameInput = $("input#username");
var firstnameInput = $("input#firstname"); var firstnameInput = $("input#firstname");
var lastnameInput = $("input#lastname"); var lastnameInput = $("input#lastname");
//var charLimit = parseInt($("input#username").attr("limit")); var charLimit = parseInt($("input#username").attr("limit"));
var domain = $("#userStore").val(); var domain = $("#userStore").val();
var username = usernameInput.val().trim(); var username = usernameInput.val().trim();
var firstname = firstnameInput.val(); var firstname = firstnameInput.val();

@ -27,8 +27,10 @@ var invokerUtil = function () {
restAPIRequestDetails["requestURL"] = requestURL; restAPIRequestDetails["requestURL"] = requestURL;
restAPIRequestDetails["requestPayload"] = JSON.stringify(requestPayload); restAPIRequestDetails["requestPayload"] = JSON.stringify(requestPayload);
var appContext = $("#app-context").data("app-context");
var request = { var request = {
url: context + "/api/invoker/execute/", url: appContext + "/api/invoker/execute/",
type: "POST", type: "POST",
contentType: "application/json", contentType: "application/json",
data: JSON.stringify(restAPIRequestDetails), data: JSON.stringify(restAPIRequestDetails),

@ -31,11 +31,16 @@
</div> </div>
</div> </div>
</div> </div>
<div id="app-context" data-app-context="{{@app.context}}" class="hidden"></div>
{{/zone}} {{/zone}}
{{#zone "bottomJs"}}
{{#zone "topJs"}}
<script type="text/javascript"> <script type="text/javascript">
var context = "{{@app.context}}" var context = "{{@app.context}}"
</script> </script>
{{/zone}}
{{#zone "bottomJs"}}
{{js "js/js.cookie.js"}} {{js "js/js.cookie.js"}}
{{js "js/invoker-lib.js"}} {{js "js/invoker-lib.js"}}
{{/zone}} {{/zone}}

Loading…
Cancel
Save