charitha 9 years ago
parent d5950afe7a
commit 0ccaa9fe81

@ -24,17 +24,17 @@ import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException;
import org.wso2.carbon.device.mgt.jaxrs.beans.UserCredentialWrapper;
import org.wso2.carbon.device.mgt.jaxrs.beans.UserWrapper;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.EmailMetaInfo;
import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException;
import org.wso2.carbon.device.mgt.jaxrs.api.util.CredentialManagementResponseBuilder;
import org.wso2.carbon.device.mgt.jaxrs.api.util.DeviceMgtAPIUtils;
import org.wso2.carbon.device.mgt.jaxrs.api.util.ResponsePayload;
import org.wso2.carbon.device.mgt.jaxrs.beans.UserCredentialWrapper;
import org.wso2.carbon.device.mgt.jaxrs.beans.UserWrapper;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
import org.wso2.carbon.device.mgt.jaxrs.util.SetReferenceTransformer;
import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.user.api.UserStoreManager;
@ -60,7 +60,6 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Random;
import java.util.TreeSet;
/**
* This class represents the JAX-RS services of User related functionality.
@ -195,31 +194,23 @@ public class UserImpl implements org.wso2.carbon.device.mgt.jaxrs.api.User {
new String(decodedBytes, "UTF-8"));
log.debug("User credential of username: " + userWrapper.getUsername() + " has been changed");
}
List<String> listofFilteredRoles = getFilteredRoles(userStoreManager, userWrapper.getUsername());
final String[] existingRoles = listofFilteredRoles.toArray(new String[listofFilteredRoles.size()]);
List<String> currentRoles = getFilteredRoles(userStoreManager, userWrapper.getUsername());
List<String> newRoles = Arrays.asList(userWrapper.getRoles());
/*
Use the Set theory to find the roles to delete and roles to add
The difference of roles in existingRolesSet and newRolesSet needed to be deleted
new roles to add = newRolesSet - The intersection of roles in existingRolesSet and newRolesSet
*/
final TreeSet<String> existingRolesSet = new TreeSet<>();
Collections.addAll(existingRolesSet, existingRoles);
final TreeSet<String> newRolesSet = new TreeSet<>();
Collections.addAll(newRolesSet, userWrapper.getRoles());
existingRolesSet.removeAll(newRolesSet);
// Now we have the roles to delete
String[] rolesToDelete = existingRolesSet.toArray(new String[existingRolesSet.size()]);
List<String> roles = new ArrayList<>(Arrays.asList(rolesToDelete));
roles.remove(ROLE_EVERYONE);
rolesToDelete = new String[0];
// Clearing and re-initializing the set
existingRolesSet.clear();
Collections.addAll(existingRolesSet, existingRoles);
newRolesSet.removeAll(existingRolesSet);
// Now we have the roles to add
String[] rolesToAdd = newRolesSet.toArray(new String[newRolesSet.size()]);
userStoreManager.updateRoleListOfUser(userWrapper.getUsername(), rolesToDelete, rolesToAdd);
List<String> rolesToAdd = new ArrayList<>(newRoles);
List<String> rolesToDelete = new ArrayList<>();
for (String role : currentRoles) {
if (newRoles.contains(role)) {
rolesToAdd.remove(role);
} else {
rolesToDelete.add(role);
}
}
rolesToDelete.remove(ROLE_EVERYONE);
userStoreManager.updateRoleListOfUser(userWrapper.getUsername(),
rolesToDelete.toArray(new String[rolesToDelete.size()]),
rolesToAdd.toArray(new String[rolesToAdd.size()]));
userStoreManager.setUserClaimValues(userWrapper.getUsername(), defaultUserClaims, null);
// Outputting debug message upon successful addition of user
if (log.isDebugEnabled()) {

@ -252,7 +252,7 @@ function loadDevices(searchType, searchParam){
{ targets: 1, data: 'name', className: 'fade-edge' , render: function ( name, type, row, meta ) {
var model = getPropertyValue(row.properties, 'DEVICE_MODEL');
var vendor = getPropertyValue(row.properties, 'VENDOR');
var html = '<h4>Device ' + name + '</h4>';
var html = '<h4>' + name + '</h4>';
if (model) {
html += '<div>(' + vendor + '-' + model + ')</div>';
}

@ -19,5 +19,119 @@
{{/zone}}
{{#zone "content"}}
{{unit "cdmf.unit.user.create"}}
<!-- content/body -->
<div class="row">
<div class="col-md-12">
<!-- content -->
<div id="user-create-form" class="container col-centered wr-content">
<div class="wr-form">
<p class="page-sub-title">Add User</p>
<p>Please note that * sign represents required fields of data.</p>
<hr/>
<div class="row">
<div class="col-lg-8">
<div id="user-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" title="List of available secondary user stores">
User Stores
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
</label>
<div class="wr-input-control">
<select id="userStore" class="form-control select">
<option>PRIMARY</option>
{{#each userStores}}
<option>{{this}}</option>
{{/each}}
</select>
</div>
<label class="wr-input-label" title="{{usernameHelpMsg}}">
User Name *
<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"/>
<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>
</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"/>
<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"/>
<span class="glyphicon glyphicon-remove form-control-feedback hidden lnError"></span>
<label class=" hidden error lnError" for="summary">This field is required.</label>
</div>
<label class="wr-input-label" title="Ex: dan@abc.com">
Email Address *
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
</label>
<div id="emailField" class=" form-group wr-input-control">
<input type="email" id="emailAddress" class="form-control"/>
<span class="glyphicon glyphicon-remove form-control-feedback hidden emailError"></span>
<label class=" hidden error email-required" for="summary">This field is
required.</label>
<label class=" hidden error email-invalid" for="summary">Invalid Email Address.</label>
</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>
<div class="wr-input-control">
<select id="roles" class="form-control select2" multiple="multiple">
{{#each roles}}
<option>{{this}}</option>
{{/each}}
</select>
</div>
</div>
</div>
<br>
<button id="add-user-btn" class="wr-btn">Add User</button>
</div>
</div>
<div id="user-created-msg" class="container col-centered wr-content hidden">
<div class="wr-form">
<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>
</div>
</div>
<br>Please click <b>"Add Another User"</b>, if you wish to add another user or click
<b>"View User List"</b> to complete the process and go back to the user list.
<hr/>
<button class="wr-btn" onclick="window.location.href='{{@app.context}}/users'">View User List
</button>
<a href="{{@app.context}}/user/add" class="cu-btn-inner">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i>
</span>
Add Another User
</a>
</div>
</div>
<!-- /content -->
</div>
</div>
{{/zone}}
{{#zone "bottomJs"}}
{{js "js/bottomJs.js"}}
{{/zone}}

@ -26,16 +26,17 @@ function onRequest(context) {
var userModule = require("/app/modules/user.js")["userModule"];
var response = userModule.getRolesByUserStore("PRIMARY");
var devicemgtProps = require('/app/conf/devicemgt-props.js').config();
context["charLimit"] = devicemgtProps.usernameLength;
var page = {};
page["charLimit"] = devicemgtProps.usernameLength;
if (response["status"] == "success") {
context["roles"] = response["content"];
page["roles"] = response["content"];
}
context["usernameJSRegEx"] = devicemgtProps.userValidationConfig.usernameJSRegEx;
context["usernameHelpText"] = devicemgtProps.userValidationConfig.usernameHelpMsg;
context["usernameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.usernameRegExViolationErrorMsg;
context["firstnameJSRegEx"] = devicemgtProps.userValidationConfig.firstnameJSRegEx;
context["firstnameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.firstnameRegExViolationErrorMsg;
context["lastnameJSRegEx"] = devicemgtProps.userValidationConfig.lastnameJSRegEx;
context["lastnameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.lastnameRegExViolationErrorMsg;
return context;
page["usernameJSRegEx"] = devicemgtProps.userValidationConfig.usernameJSRegEx;
page["usernameHelpMsg"] = devicemgtProps.userValidationConfig.usernameHelpMsg;
page["usernameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.usernameRegExViolationErrorMsg;
page["firstnameJSRegEx"] = devicemgtProps.userValidationConfig.firstnameJSRegEx;
page["firstnameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.firstnameRegExViolationErrorMsg;
page["lastnameJSRegEx"] = devicemgtProps.userValidationConfig.lastnameJSRegEx;
page["lastnameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.lastnameRegExViolationErrorMsg;
return page;
}

@ -72,7 +72,7 @@ var disableInlineError = function (inputField, errorMsg, errorSign) {
*/
validateInline["user-name"] = function () {
var usernameinput = $("input#username");
if (inputIsValid( usernameinput.data("regex"), usernameinput.val())) {
if (inputIsValid(usernameinput.data("regex"), usernameinput.val())) {
disableInlineError("usernameInputField", "usernameEmpty", "usernameError");
} else {
enableInlineError("usernameInputField", "usernameEmpty", "usernameError");
@ -110,12 +110,12 @@ validateInline["last-name"] = function () {
validateInline["emailAddress"] = function () {
var email = $("#emailAddress").val();
if (!email) {
enableInlineError("emailField", "email-required" , "emailError");
enableInlineError("emailField", "email-required", "emailError");
} else if (emailIsValid(email)) {
disableInlineError("emailField", "email-required" , "emailError");
disableInlineError("emailField", "email-invalid" , "emailError");
disableInlineError("emailField", "email-required", "emailError");
disableInlineError("emailField", "email-invalid", "emailError");
} else {
enableInlineError("emailField", "email-invalid" , "emailError");
enableInlineError("emailField", "email-invalid", "emailError");
}
};
@ -145,8 +145,8 @@ clearInline["last-name"] = function () {
* clear Validation messages when gain focus to the field.
*/
clearInline["emailAddress"] = function () {
disableInlineError("emailField", "email-required" , "emailError");
disableInlineError("emailField", "email-invalid" , "emailError");
disableInlineError("emailField", "email-required", "emailError");
disableInlineError("emailField", "email-invalid", "emailError");
};
/**
@ -160,13 +160,13 @@ function emailIsValid(email) {
return regExp.test(email);
}
$( "#userStore" )
$("#userStore")
.change(function () {
var str = "";
$( "select option:selected" ).each(function() {
str += $( this ).text() + " ";
$("select option:selected").each(function () {
str += $(this).text() + " ";
});
var addUserAPI = "/devicemgt_admin/roles/"+ str;
var addUserAPI = "/devicemgt_admin/roles/" + str;
invokerUtil.get(
addUserAPI,
@ -175,10 +175,10 @@ $( "#userStore" )
if (data.errorMessage) {
$(errorMsg).text("Selected user store prompted an error : " + data.errorMessage);
$(errorMsgWrapper).removeClass("hidden");
} else if (data["status"] == 200) {
} else if (data["statusCode"] == 200) {
$("#roles").empty();
for (var i = 0; i < data.responseContent.length; i++) {
var newOption = $('<option value="'+data.responseContent[i]+'">'+data.responseContent[i]+'</option>');
var newOption = $('<option value="' + data.responseContent[i] + '">' + data.responseContent[i] + '</option>');
$('#roles').append(newOption);
}
}
@ -286,35 +286,35 @@ $(document).ready(function () {
}
});
$("#username").focus(function() {
$("#username").focus(function () {
clearInline["user-name"]();
});
$("#username").blur(function() {
$("#username").blur(function () {
validateInline["user-name"]();
});
$("#emailAddress").focus(function() {
$("#emailAddress").focus(function () {
clearInline["emailAddress"]();
});
$("#emailAddress").blur(function() {
$("#emailAddress").blur(function () {
validateInline["emailAddress"]();
});
$("#lastname").focus(function() {
$("#lastname").focus(function () {
clearInline["last-name"]();
});
$("#lastname").blur(function() {
$("#lastname").blur(function () {
validateInline["last-name"]();
});
$("#firstname").focus(function() {
$("#firstname").focus(function () {
clearInline["first-name"]();
});
$("#firstname").blur(function() {
$("#firstname").blur(function () {
validateInline["first-name"]();
});
});

@ -19,5 +19,105 @@
{{/zone}}
{{#zone "content"}}
{{unit "cdmf.unit.user.edit"}}
<!-- content/body -->
<div class="row">
<div class="col-md-12">
<!-- content -->
<div id="user-create-form" class="container col-centered wr-content">
<div class="wr-form">
<p class="page-sub-title">Edit User</p>
<p>Please note that * sign represents required fields of data.</p>
<hr/>
<div class="row">
<div class="col-lg-8">
<div id="user-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">
User Name <br>
</label>
<div class="wr-input-control">
<input type="text" id="username" data-regex="{{usernameJSRegEx}}"
data-errormsg="{{usernameRegExViolationErrorMsg}}" class="form-control"
value="{{editUser.username}}" disabled/>
</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"
value="{{editUser.firstname}}"/>
<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"
value="{{editUser.lastname}}"/>
<span class="glyphicon glyphicon-remove form-control-feedback hidden lnError"></span>
<label class=" hidden error lnError" for="summary">This field is required.</label>
</div>
<label class="wr-input-label">
Email Address * <br>
( ex: sam@gmail.com )
</label>
<div id="emailField" class=" form-group wr-input-control">
<input type="email" id="emailAddress" class="form-control"
value="{{editUser.emailAddress}}"/>
<span class="glyphicon glyphicon-remove form-control-feedback hidden emailError"></span>
<label class=" hidden error email-required" for="summary">This field is
required.</label>
<label class=" hidden error email-invalid" for="summary">Invalid Email Address.</label>
</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>
<div class="wr-input-control">
<select id="roles" class="form-control select2" multiple="multiple" selectedVals="
{{#each usersRoles}}
{{this}},
{{/each}}
">
{{#each userRoles}}
<option>{{this}}</option>
{{/each}}
</select>
</div>
</div>
</div>
<br>
<button id="add-user-btn" class="wr-btn">Save User</button>
</div>
</div>
<div id="user-created-msg" class="container col-centered wr-content hidden">
<div class="wr-form">
<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
<b>"View User List"</b> to complete the process and go back to the user list.
<hr/>
<button class="wr-btn" onclick="window.location.href='{{@app.context}}/users'">View User List
</button>
<a href="{{@app.context}}/user/view?username={{editUser.username}}" class="cu-btn-inner">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-view fw-stack-1x"></i>
</span>
View Updated User
</a>
</div>
</div>
<!-- /content -->
</div>
</div>
<!-- /content/body -->
{{/zone}}
{{#zone "bottomJs"}}
{{js "js/bottomJs.js"}}
{{/zone}}

@ -18,8 +18,9 @@
function onRequest(context) {
var userModule = require("/app/modules/user.js").userModule;
var username = request.getParameter("username");
var user = userModule.getUser(username)["content"];
var userName = request.getParameter("username");
var user = userModule.getUser(userName)["content"];
var devicemgtProps = require('/app/conf/devicemgt-props.js').config();
if (user) {
var title;
if (user.firstname || user.lastname) {
@ -27,6 +28,33 @@ function onRequest(context) {
} else {
title = user.username;
}
return {"user": user, "title": title};
var page = {"user": user, "title": title};
var userStore = "PRIMARY";
if (userName.indexOf("/") > -1) {
userStore = userName.substr(0, userName.indexOf('/'));
}
var response = userModule.getUser(userName);
if (response["status"] == "success") {
page["editUser"] = response["content"];
}
response = userModule.getRolesByUsername(userName);
if (response["status"] == "success") {
page["usersRoles"] = response["content"];
}
response = userModule.getRolesByUserStore(userStore);
if (response["status"] == "success") {
page["userRoles"] = response["content"];
}
}
page["usernameJSRegEx"] = devicemgtProps.userValidationConfig.usernameJSRegEx;
page["usernameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.usernameRegExViolationErrorMsg;
page["firstnameJSRegEx"] = devicemgtProps.userValidationConfig.firstnameJSRegEx;
page["firstnameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.firstnameRegExViolationErrorMsg;
page["lastnameJSRegEx"] = devicemgtProps.userValidationConfig.lastnameJSRegEx;
page["lastnameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.lastnameRegExViolationErrorMsg;
return page;
}

@ -232,7 +232,7 @@ $(document).ready(function () {
addUserFormData,
function (data) {
data = JSON.parse(data);
if (data["status"] == 201) {
if (data["statusCode"] == 201) {
// Clearing user input fields.
$("input#username").val("");
$("input#firstname").val("");
@ -244,9 +244,9 @@ $(document).ready(function () {
$("#user-created-msg").removeClass("hidden");
}
}, function (data) {
if (data["status"] == 409) {
if (data["statusCode"] == 409) {
$(errorMsg).text("User : " + username + " doesn't exists. You cannot proceed.");
} else if (data["status"] == 500) {
} else if (data["statusCode"] == 500) {
$(errorMsg).text("An unexpected error occurred @ backend server. Please try again later.");
} else {
$(errorMsg).text(data.errorMessage);

@ -13,11 +13,140 @@
</li>
<li>
<a href="#">
{{username}}
{{user.username}}
</a>
</li>
{{/zone}}
{{#zone "content"}}
{{unit "cdmf.unit.user.view"}}
{{#zone "contentTitle"}}
<div class="row wr-device-board">
<div class="col-lg-12 wr-secondary-bar">
<label class="device-id device-select" data-username="{{user.username}}">
{{#if user.firstname}}
{{user.firstname}} {{user.lastname}}
{{else}}
{{user.username}}
{{/if}}
</label>
</div>
</div>
{{/zone}}
<div class="row no-gutter add-padding-5x add-margin-top-5x" style="border: 1px solid #e4e4e4;">
<div class="media">
<div class="media-left media-middle asset-image col-xs-2 col-sm-2 col-md-2 col-lg-2">
<div class="thumbnail icon" style="margin-bottom: 43px"><i class="square-element text fw fw-user"></i>
</div>
<div class="media">
{{#if editPermitted}}
<button class="wr-btn"
onclick="location.href='{{@app.context}}/users/edit-user?username={{user.username}}';"
id="sortUpdateBtn"
style="width: 100%; vertical-align: bottom; background-color: #7fa030;"><span><i
class="fw fw-edit"></i> Edit</span></button>
{{/if}}
</div>
</div>
<div class="media-body asset-desc add-padding-left-5x">
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">Profile Overview</div>
{{#defineZone "user-detail-properties"}}
<table class="table table-responsive table-striped" id="members">
<tbody>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 7%;">Username</td>
<td style="padding:10px 15px;">{{user.username}}</td>
</tr>
<tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px;">First Name</td>
<td style="padding:10px 15px;">{{user.firstname}}</td>
</tr>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px;">Last Name</td>
<td style="padding:10px 15px;">{{user.lastname}}</td>
</tr>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px;">Email</td>
<td style="padding:10px 15px;">{{user.emailAddress}}</td>
</tr>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px;">Roles</td>
<td style="padding:10px 15px;">
{{#each userRoles}}
<option selected="selected">{{this}}</option>
{{/each}}
</td>
</tr>
</tbody>
</table>
{{/defineZone}}
</div>
</div>
<div class="media">
<div class="media-left col-xs-12 col-sm-2 col-md-2 col-lg-2">
<ul class="list-group" role="tablist">
<li class="active"><a class="list-group-item" href="#enrolled_devices" role="tab"
data-toggle="tab" aria-controls="enrolled_devices">Enrolled Devices</a>
</li>
</ul>
</div>
{{#defineZone "user-enrolled-devices"}}
<div class="media-body add-padding-left-5x remove-padding-xs tab-content">
<div class="panel-group tab-content">
<div class="panel panel-default tab-pane active" id="enrolled_devices"
role="tabpanel" aria-labelledby="enrolled_devices">
<div class="panel-heading">Enrolled Devices by
{{#if user.firstname}}
{{user.firstname}} {{user.lastname}}
{{else}}
{{user.username}}
{{/if}}
</div>
<div class="panel-body">
<div id="enrolled_devices-container">
<div class="panel-body">
{{#each devices}}
<div class="wr-list-group wr-sortable policy-list">
<span class="list-group-item" id="{{id}}">
<div class="row">
<div class="col-lg-3 clearfix">
<span class="wr-list-icon">
<div class="thumbnail icon">
<img class="square-element text fw "
src="{{thumb}}"/>
</div>
</span>
<span class="wr-list-desc">
<h3 class="wr-list-name">{{name}}</h3>
</span>
</div>
<div class="col-lg-6">
</div>
<div class="col-lg-3">
<span class="list-group-item-actions">
<a href="{{@app.context}}/device/{{type}}?id={{deviceIdentifier}}"
class="cu-btn-inner policy-view-link"
data-id="{{deviceIdentifier}}">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-view fw-stack-1x"></i>
</span>
View
</a>
</span>
</div>
</div>
</span>
</div>
{{/each}}
</div>
<br class="c-both"/>
</div>
</div>
</div>
</div>
</div>
{{/defineZone}}
</div>
</div>
{{/zone}}

@ -20,7 +20,26 @@ function onRequest(context) {
var userModule = require("/app/modules/user.js").userModule;
var username = request.getParameter("username");
var user = userModule.getUser(username)["content"];
if (user) {
return {"username": user.username};
var userModule = require("/app/modules/user.js")["userModule"];
var userName = request.getParameter("username");
var user, userRoles, devices;
if (userName) {
var response = userModule.getUser(userName);
if (response["status"] == "success") {
user = response["content"];
user.domain = response["userDomain"];
}
response = userModule.getRolesByUsername(userName);
if (response["status"] == "success") {
userRoles = response["content"];
}
var deviceModule = require("/app/modules/device.js").deviceModule;
devices = deviceModule.getDevices(userName);
}
return {"user": user, "userRoles": userRoles, "devices": devices};
}

@ -16,6 +16,18 @@
* under the License.
*/
/**
* Checks if provided input is valid against RegEx input.
*
* @param regExp Regular expression
* @param inputString Input string to check
* @returns {boolean} Returns true if input matches RegEx
*/
function inputIsValid(regExp, inputString) {
regExp = new RegExp(regExp);
return regExp.test(inputString);
}
/**
* Sorting function of users
* listed on User Management page in WSO2 Devicemgt Console.
@ -198,14 +210,14 @@ function resetPassword(uname) {
resetPasswordFormData,
function (data) { // The success callback
data = JSON.parse(data);
if (data.status == 201) {
if (data.statusCode == 201) {
$(modalPopupContent).html($('#reset-password-success-content').html());
$("a#reset-password-success-link").click(function () {
hidePopup();
});
}
}, function (data) { // The error callback
if (data.status == 400) {
if (data.statusCode == 400) {
$(errorMsg).text("Old password does not match with the provided value.");
$(errorMsgWrapper).removeClass("hidden");
} else {
@ -302,8 +314,7 @@ function loadUsers(searchParam) {
successCallback,
function (message) {
$('#ast-container').addClass('hidden');
$('#user-listing-status-msg').
text('Invalid search query. Try again with a valid search query');
$('#user-listing-status-msg').text('Invalid search query. Try again with a valid search query');
}
);
});

@ -28,5 +28,305 @@
{{/zone}}
{{#zone "content"}}
{{unit "cdmf.unit.user.listing"}}
<!-- content -->
<div id="loading-content" class="col-centered">
{{#if removePermitted}}
<input type="hidden" id="can-remove" value="true"/>
{{/if}}
{{#if editPermitted}}
<input type="hidden" id="can-edit" value="true"/>
{{/if}}
{{#if viewPermitted}}
<input type="hidden" id="can-view" value="true"/>
{{/if}}
{{#if invitePermitted}}
<input type="hidden" id="can-invite" value="true"/>
{{/if}}
{{#if resetPasswordPermitted}}
<input type="hidden" id="can-reset-password" value="true"/>
{{/if}}
<i class="fw fw-settings fw-spin fw-2x"></i>
Loading users . . .
<br>
</div>
<div id="user-listing-status" class="raw hidden">
<ul style="list-style-type: none;">
<li class="message message-info">
<h4>
<i class="icon fw fw-info"></i>
<a id="user-listing-status-msg"></a>
</h4>
</li>
</ul>
</div>
<div id="user-table" data-user={{adminUser}}>
<table class="table table-striped table-hover list-table display responsive nowrap data-table grid-view"
id="user-grid">
<thead>
<tr class="sort-row">
<th class="no-sort"></th>
<th class="no-sort"></th>
<th>By Username</th>
<th class="no-sort"></th>
<th class="no-sort"></th>
</tr>
<tr class="filter-row filter-box">
<th colspan="4">
<label class="wr-input-label" for="search-by-username">
By Username
</label>
<input id="search-by-username" type="text" class="form-control"
placeholder="Search By Username">
</th>
<th style="vertical-align:bottom;">
<button id="search-btn" class="wr-btn">
Search
</button>
</th>
</tr>
<tr class="bulk-action-row" id="invite-user-button">
<th colspan="5">
<ul class="tiles">
<li class="square">
<a href="#" data-click-event="remove-form" class="btn square-element invite-user-link"
data-toggle="modal" data-target="#modalDemo">
<span class="icon fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-invitation fw-stack-1x"></i>
</span>
Invite Selected
</a>
</li>
</ul>
</th>
</tr>
</thead>
<tbody id="ast-container">
<br class="c-both"/>
</tbody>
</table>
</div>
<br class="c-both"/>
<div id="content-filter-types" style="display: none">
<div class="sort-title">Sort By</div>
<div class="sort-options">
<a href="#">By Username</a>
</div>
</div>
<div id="invite-user-modal-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>
An invitation mail will be sent to the selected user(s) to initiate an enrolment process.
Do you wish to continue ?
</h3>
<div class="buttons">
<a href="#" id="invite-user-yes-link" class="btn-operations">
yes
</a>
<a href="#" id="invite-user-cancel-link" class="btn-operations">
No
</a>
</div>
</div>
</div>
</div>
</div>
<div id="invite-user-success-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>User invitation email for enrollment was successfully sent.</h3>
<div class="buttons">
<a href="#" id="invite-user-success-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="invite-user-error-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>An unexpected error occurred. Try again later.</h3>
<div class="buttons">
<a href="#" id="invite-user-error-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="remove-user-modal-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Do you really want to remove this user ?</h3>
<div class="buttons">
<a href="#" id="remove-user-yes-link" class="btn-operations">
Remove
</a>
<a href="#" id="remove-user-cancel-link" class="btn-operations">
Cancel
</a>
</div>
</div>
</div>
</div>
</div>
<div id="remove-user-success-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Done. User was successfully removed.</h3>
<div class="buttons">
<a href="#" id="remove-user-success-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="remove-user-error-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>An unexpected error occurred. Please try again later.</h3>
<div class="buttons">
<a href="#" id="remove-user-error-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="errorUsers" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-error fw-stack-1x"></i>
</span>
Operation cannot be performed !
</h3>
<h4>
Please select a user or a list of users to send invitation emails.
</h4>
<div class="buttons">
<a href="javascript:hidePopup()" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="errorUserView" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-error fw-stack-1x"></i>
</span>
Unauthorized action!
</h3>
</div>
</div>
</div>
</div>
<div id="reset-password-window" class="hide">
<input type="hidden" id="user" value="{{user.username}}">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-key fw-stack-1x"></i>
</span>
Reset Password
<br>
</h3>
<div id="notification-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>
<h4>
Enter new password
<br><br>
<div>
<input type="password" class="form-control modal-input operationDataKeys" id="new-password"
data-key="message"/>
</div>
<br>
Retype new password
<br><br>
<div>
<input type="password" class="form-control modal-input operationDataKeys"
id="confirmed-password" data-key="message"/>
</div>
<br>
</h4>
<div class="buttons">
<a href="#" id="reset-password-yes-link" class="btn-operations">
&nbsp;&nbsp;&nbsp;&nbsp;Save&nbsp;&nbsp;&nbsp;&nbsp;
</a>
&nbsp;&nbsp;
<a href="#" id="reset-password-cancel-link" class="btn-operations">
&nbsp;&nbsp;&nbsp;&nbsp;Cancel&nbsp;&nbsp;&nbsp;&nbsp;
</a>
</div>
</div>
</div>
</div>
</div>
<div id="reset-password-success-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Password reset is successful.</h3>
<div class="buttons">
<a href="#" id="reset-password-success-link" class="btn-operations">
&nbsp;&nbsp;&nbsp;&nbsp;Ok&nbsp;&nbsp;&nbsp;&nbsp;
</a>
</div>
</div>
</div>
</div>
</div>
{{/zone}}
{{#zone "common-navigation"}}
<!--Later add the navigation menu from here-->
{{/zone}}
{{#zone "bottomJs"}}
<script id="user-listing" data-current-user="{{currentUser.username}}"
src="{{@page.publicUri}}/templates/listing.hbs" type="text/x-handlebars-template"></script>
{{js "js/listing.js"}}
{{/zone}}

@ -26,4 +26,31 @@ function onRequest(context) {
return options.fn(this);
}
});
var page = {};
var userModule = require("/app/modules/user.js")["userModule"];
var deviceMgtProps = require("/app/conf/devicemgt-props.js").config();
page["permissions"] = userModule.getUIPermissions();
if (userModule.isAuthorized("/permission/admin/device-mgt/users/delete")) {
page["removePermitted"] = true;
}
if (userModule.isAuthorized("/permission/admin/device-mgt/users/remove")) {
page["removePermitted"] = true;
}
if (userModule.isAuthorized("/permission/admin/device-mgt/users/update")) {
page["editPermitted"] = true;
}
if (userModule.isAuthorized("/permission/admin/device-mgt/users/view")) {
page["viewPermitted"] = true;
}
if (userModule.isAuthorized("/permission/admin/device-mgt/users/invite")) {
page["invitePermitted"] = true;
}
if (userModule.isAuthorized("/permission/admin/device-mgt/users/reset-password")) {
page["resetPasswordPermitted"] = true;
}
page["adminUser"] = deviceMgtProps.adminUser;
return page;
}

@ -1,113 +0,0 @@
<!-- content/body -->
<div class="row">
<div class="col-md-12">
<!-- content -->
<div id="user-create-form" class="container col-centered wr-content">
<div class="wr-form">
<p class="page-sub-title">Add User</p>
<p>Please note that * sign represents required fields of data.</p>
<hr />
<div class="row">
<div class="col-lg-8">
<div id="user-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" title="List of available secondary user stores">
User Stores
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
</label>
<div class="wr-input-control">
<select id="userStore" class="form-control select" >
<option>PRIMARY</option>
{{#each userStores}}
<option>{{this}}</option>
{{/each}}
</select>
</div>
<label class="wr-input-label">
User Name *
</label>
<br>
<label class="wr-input-label">
( {{usernameHelpText}} )
</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"/>
<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>
</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"/>
<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"/>
<span class="glyphicon glyphicon-remove form-control-feedback hidden lnError"></span>
<label class=" hidden error lnError" for="summary">This field is required.</label>
</div>
<label class="wr-input-label">
Email Address * <br>
( ex: sam@gmail.com )
</label>
<div id="emailField" class=" form-group wr-input-control">
<input type="email" id="emailAddress" class="form-control"/>
<span class="glyphicon glyphicon-remove form-control-feedback hidden emailError"></span>
<label class=" hidden error email-required" for="summary">This field is required.</label>
<label class=" hidden error email-invalid" for="summary">Invalid Email Address.</label>
</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>
<div class="wr-input-control">
<select id="roles" class="form-control select2" multiple="multiple">
{{#each roles}}
<option>{{this}}</option>
{{/each}}
</select>
</div>
</div>
</div>
<br>
<button id="add-user-btn" class="wr-btn">Add User</button>
</div>
</div>
<div id="user-created-msg" class="container col-centered wr-content hidden">
<div class="wr-form">
<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>
</div>
</div>
<br>Please click <b>"Add Another User"</b>, if you wish to add another user or click
<b>"View User List"</b> to complete the process and go back to the user list.
<hr />
<button class="wr-btn" onclick="window.location.href='{{@app.context}}/users'">View User List</button>
<a href="{{@app.context}}/user/add" class="cu-btn-inner">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i>
</span>
Add Another User
</a>
</div>
</div>
<!-- /content -->
</div>
</div>
<!-- /content/body -->
{{#zone "bottomJs"}}
{{js "js/bottomJs.js"}}
{{/zone}}

@ -1,91 +0,0 @@
<!-- content/body -->
<div class="row">
<div class="col-md-12">
<!-- content -->
<div id="user-create-form" class="container col-centered wr-content">
<div class="wr-form">
<p class="page-sub-title">Edit User</p>
<p>Please note that * sign represents required fields of data.</p>
<hr />
<div class="row">
<div class="col-lg-8">
<div id="user-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">
User Name <br>
</label>
<div class="wr-input-control">
<input type="text" id="username" data-regex="{{usernameJSRegEx}}" data-errormsg="{{usernameRegExViolationErrorMsg}}" class="form-control" value="{{editUser.username}}" disabled/>
</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" value="{{editUser.firstname}}"/>
<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" value="{{editUser.lastname}}"/>
<span class="glyphicon glyphicon-remove form-control-feedback hidden lnError"></span>
<label class=" hidden error lnError" for="summary">This field is required.</label>
</div>
<label class="wr-input-label">
Email Address * <br>
( ex: sam@gmail.com )
</label>
<div id="emailField" class=" form-group wr-input-control">
<input type="email" id="emailAddress" class="form-control" value="{{editUser.emailAddress}}"/>
<span class="glyphicon glyphicon-remove form-control-feedback hidden emailError"></span>
<label class=" hidden error email-required" for="summary">This field is required.</label>
<label class=" hidden error email-invalid" for="summary">Invalid Email Address.</label>
</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>
<div class="wr-input-control">
<select id="roles" class="form-control select2" multiple="multiple" selectedVals="
{{#each usersRoles}}
{{this}},
{{/each}}
">
{{#each userRoles}}
<option >{{this}}</option>
{{/each}}
</select>
</div>
</div>
</div>
<br>
<button id="add-user-btn" class="wr-btn">Save User</button>
</div>
</div>
<div id="user-created-msg" class="container col-centered wr-content hidden">
<div class="wr-form">
<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
<b>"View User List"</b> to complete the process and go back to the user list.
<hr />
<button class="wr-btn" onclick="window.location.href='{{@app.context}}/users'">View User List</button>
<a href="{{@app.context}}/user/view?username={{editUser.username}}" class="cu-btn-inner">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-view fw-stack-1x"></i>
</span>
View Updated User
</a>
</div>
</div>
<!-- /content -->
</div>
</div>
<!-- /content/body -->
{{#zone "bottomJs"}}
{{js "js/bottomJs.js"}}
{{/zone}}

@ -1,58 +0,0 @@
/*
* Copyright (c) 2016, 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
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Returns a context with the user object to be populated by the edit-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) {
var userModule = require("/app/modules/user.js")["userModule"];
var devicemgtProps = require('/app/conf/devicemgt-props.js').config();
var userName = request.getParameter("username");
if (userName) {
var userStore = "PRIMARY";
if (userName.indexOf("/") > -1) {
userStore = userName.substr(0, userName.indexOf('/'));
}
var response = userModule.getUser(userName);
if (response["status"] == "success") {
context["editUser"] = response["content"];
}
response = userModule.getRolesByUsername(userName);
if (response["status"] == "success") {
context["usersRoles"] = response["content"];
}
response = userModule.getRolesByUserStore(userStore);
if (response["status"] == "success") {
context["userRoles"] = response["content"];
}
}
context["usernameJSRegEx"] = devicemgtProps.userValidationConfig.usernameJSRegEx;
context["usernameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.usernameRegExViolationErrorMsg;
context["firstnameJSRegEx"] = devicemgtProps.userValidationConfig.firstnameJSRegEx;
context["firstnameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.firstnameRegExViolationErrorMsg;
context["lastnameJSRegEx"] = devicemgtProps.userValidationConfig.lastnameJSRegEx;
context["lastnameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.lastnameRegExViolationErrorMsg;
return context;
}

@ -1,299 +0,0 @@
<!-- content -->
<div id="loading-content" class="col-centered">
{{#if removePermitted}}
<input type="hidden" id="can-remove" value="true"/>
{{/if}}
{{#if editPermitted}}
<input type="hidden" id="can-edit" value="true"/>
{{/if}}
{{#if viewPermitted}}
<input type="hidden" id="can-view" value="true"/>
{{/if}}
{{#if invitePermitted}}
<input type="hidden" id="can-invite" value="true"/>
{{/if}}
{{#if resetPasswordPermitted}}
<input type="hidden" id="can-reset-password" value="true"/>
{{/if}}
<i class="fw fw-settings fw-spin fw-2x"></i>
Loading users . . .
<br>
</div>
<div id="user-listing-status" class="raw hidden">
<ul style="list-style-type: none;">
<li class="message message-info" >
<h4>
<i class="icon fw fw-info"></i>
<a id="user-listing-status-msg"></a>
</h4>
</li>
</ul>
</div>
<div id="user-table" data-user={{adminUser}}>
<table class="table table-striped table-hover list-table display responsive nowrap data-table grid-view"
id="user-grid">
<thead>
<tr class="sort-row">
<th class="no-sort"></th>
<th class="no-sort"></th>
<th>By Username</th>
<th class="no-sort"></th>
<th class="no-sort"></th>
</tr>
<tr class="filter-row filter-box">
<th colspan="4">
<label class="wr-input-label" for="search-by-username">
By Username
</label>
<input id="search-by-username" type="text" class="form-control"
placeholder="Search By Username">
</th>
<th style="vertical-align:bottom;">
<button id="search-btn" class="wr-btn">
Search
</button>
</th>
</tr>
<tr class="bulk-action-row" id="invite-user-button">
<th colspan="5">
<ul class="tiles">
<li class="square">
<a href="#" data-click-event="remove-form" class="btn square-element invite-user-link"
data-toggle="modal" data-target="#modalDemo">
<span class="icon fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-invitation fw-stack-1x"></i>
</span>
Invite Selected
</a>
</li>
</ul>
</th>
</tr>
</thead>
<tbody id="ast-container">
<br class="c-both"/>
</tbody>
</table>
</div>
<br class="c-both"/>
<div id="content-filter-types" style="display: none">
<div class="sort-title">Sort By</div>
<div class="sort-options">
<a href="#">By Username</a>
</div>
</div>
<div id="invite-user-modal-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>
An invitation mail will be sent to the selected user(s) to initiate an enrolment process.
Do you wish to continue ?
</h3>
<div class="buttons">
<a href="#" id="invite-user-yes-link" class="btn-operations">
yes
</a>
<a href="#" id="invite-user-cancel-link" class="btn-operations">
No
</a>
</div>
</div>
</div>
</div>
</div>
<div id="invite-user-success-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>User invitation email for enrollment was successfully sent.</h3>
<div class="buttons">
<a href="#" id="invite-user-success-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="invite-user-error-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>An unexpected error occurred. Try again later.</h3>
<div class="buttons">
<a href="#" id="invite-user-error-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="remove-user-modal-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Do you really want to remove this user ?</h3>
<div class="buttons">
<a href="#" id="remove-user-yes-link" class="btn-operations">
Remove
</a>
<a href="#" id="remove-user-cancel-link" class="btn-operations">
Cancel
</a>
</div>
</div>
</div>
</div>
</div>
<div id="remove-user-success-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Done. User was successfully removed.</h3>
<div class="buttons">
<a href="#" id="remove-user-success-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="remove-user-error-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>An unexpected error occurred. Please try again later.</h3>
<div class="buttons">
<a href="#" id="remove-user-error-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="errorUsers" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-error fw-stack-1x"></i>
</span>
Operation cannot be performed !
</h3>
<h4>
Please select a user or a list of users to send invitation emails.
</h4>
<div class="buttons">
<a href="javascript:hidePopup()" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="errorUserView" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-error fw-stack-1x"></i>
</span>
Unauthorized action!
</h3>
</div>
</div>
</div>
</div>
<div id="reset-password-window" class="hide">
<input type="hidden" id="user" value="{{user.username}}">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-key fw-stack-1x"></i>
</span>
Reset Password
<br>
</h3>
<div id="notification-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>
<h4>
Enter new password
<br><br>
<div>
<input type="password" class="form-control modal-input operationDataKeys" id="new-password" data-key="message"/>
</div>
<br>
Retype new password
<br><br>
<div>
<input type="password" class="form-control modal-input operationDataKeys" id="confirmed-password" data-key="message"/>
</div>
<br>
</h4>
<div class="buttons">
<a href="#" id="reset-password-yes-link" class="btn-operations">
&nbsp;&nbsp;&nbsp;&nbsp;Save&nbsp;&nbsp;&nbsp;&nbsp;
</a>
&nbsp;&nbsp;
<a href="#" id="reset-password-cancel-link" class="btn-operations">
&nbsp;&nbsp;&nbsp;&nbsp;Cancel&nbsp;&nbsp;&nbsp;&nbsp;
</a>
</div>
</div>
</div>
</div>
</div>
<div id="reset-password-success-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Password reset is successful.</h3>
<div class="buttons">
<a href="#" id="reset-password-success-link" class="btn-operations">
&nbsp;&nbsp;&nbsp;&nbsp;Ok&nbsp;&nbsp;&nbsp;&nbsp;
</a>
</div>
</div>
</div>
</div>
</div>
{{#zone "common-navigation"}}
<!--Later add the navigation menu from here-->
{{/zone}}
{{#zone "bottomJs"}}
<script id="user-listing" data-current-user="{{currentUser.username}}" src="{{@unit.publicUri}}/templates/listing.hbs" type="text/x-handlebars-template" ></script>
{{js "js/listing.js"}}
{{/zone}}

@ -1,46 +0,0 @@
/*
* Copyright (c) 2016, 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
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function onRequest(context) {
var userModule = require("/app/modules/user.js")["userModule"];
var deviceMgtProps = require("/app/conf/devicemgt-props.js").config();
context["permissions"] = userModule.getUIPermissions();
if (userModule.isAuthorized("/permission/admin/device-mgt/users/delete")) {
context["removePermitted"] = true;
}
if (userModule.isAuthorized("/permission/admin/device-mgt/users/remove")) {
context["removePermitted"] = true;
}
if (userModule.isAuthorized("/permission/admin/device-mgt/users/update")) {
context["editPermitted"] = true;
}
if (userModule.isAuthorized("/permission/admin/device-mgt/users/view")) {
context["viewPermitted"] = true;
}
if (userModule.isAuthorized("/permission/admin/device-mgt/users/invite")) {
context["invitePermitted"] = true;
}
if (userModule.isAuthorized("/permission/admin/device-mgt/users/reset-password")) {
context["resetPasswordPermitted"] = true;
}
context["adminUser"] = deviceMgtProps.adminUser;
return context;
}

@ -1,129 +0,0 @@
{{#zone "contentTitle"}}
<div class="row wr-device-board">
<div class="col-lg-12 wr-secondary-bar">
<label class="device-id device-select" data-username="{{user.username}}">
{{#if user.firstname}}
{{user.firstname}} {{user.lastname}}
{{else}}
{{user.username}}
{{/if}}
</label>
</div>
</div>
{{/zone}}
<div class="row no-gutter add-padding-5x add-margin-top-5x" style="border: 1px solid #e4e4e4;">
<div class="media">
<div class="media-left media-middle asset-image col-xs-2 col-sm-2 col-md-2 col-lg-2">
<div class="thumbnail icon" style="margin-bottom: 43px"><i class="square-element text fw fw-user"></i></div>
<div class="media">
{{#if editPermitted}}
<button class="wr-btn"
onclick="location.href='{{@app.context}}/users/edit-user?username={{user.username}}';"
id="sortUpdateBtn"
style="width: 100%; vertical-align: bottom; background-color: #7fa030;"><span><i
class="fw fw-edit"></i> Edit</span></button>
{{/if}}
</div>
</div>
<div class="media-body asset-desc add-padding-left-5x">
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">Profile Overview</div>
{{#defineZone "user-detail-properties"}}
<table class="table table-responsive table-striped" id="members">
<tbody>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 7%;">Username</td>
<td style="padding:10px 15px;">{{user.username}}</td>
</tr>
<tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px;">First Name</td>
<td style="padding:10px 15px;">{{user.firstname}}</td>
</tr>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px;">Last Name</td>
<td style="padding:10px 15px;">{{user.lastname}}</td>
</tr>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px;">Email</td>
<td style="padding:10px 15px;">{{user.emailAddress}}</td>
</tr>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px;">Roles</td>
<td style="padding:10px 15px;">
{{#each userRoles}}
<option selected="selected">{{this}}</option>
{{/each}}
</td>
</tr>
</tbody>
</table>
{{/defineZone}}
</div>
</div>
<div class="media">
<div class="media-left col-xs-12 col-sm-2 col-md-2 col-lg-2">
<ul class="list-group" role="tablist">
<li class="active"><a class="list-group-item" href="#enrolled_devices" role="tab"
data-toggle="tab" aria-controls="enrolled_devices">Enrolled Devices</a>
</li>
</ul>
</div>
{{#defineZone "user-enrolled-devices"}}
<div class="media-body add-padding-left-5x remove-padding-xs tab-content">
<div class="panel-group tab-content">
<div class="panel panel-default tab-pane active" id="enrolled_devices"
role="tabpanel" aria-labelledby="enrolled_devices">
<div class="panel-heading">Enrolled Devices by
{{#if user.firstname}}
{{user.firstname}} {{user.lastname}}
{{else}}
{{user.username}}
{{/if}}
</div>
<div class="panel-body">
<div id="enrolled_devices-container">
<div class="panel-body">
{{#each devices}}
<div class="wr-list-group wr-sortable policy-list">
<span class="list-group-item" id="{{id}}">
<div class="row">
<div class="col-lg-3 clearfix">
<span class="wr-list-icon">
<div class="thumbnail icon">
<img class="square-element text fw "
src="{{thumb}}"/>
</div>
</span>
<span class="wr-list-desc">
<h3 class="wr-list-name">{{name}}</h3>
</span>
</div>
<div class="col-lg-6">
</div>
<div class="col-lg-3">
<span class="list-group-item-actions">
<a href="{{@app.context}}/device/{{type}}?id={{deviceIdentifier}}"
class="cu-btn-inner policy-view-link" data-id="{{deviceIdentifier}}">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-view fw-stack-1x"></i>
</span>
View
</a>
</span>
</div>
</div>
</span>
</div>
{{/each}}
</div>
<br class="c-both"/>
</div>
</div>
</div>
</div>
</div>
{{/defineZone}}
</div>
</div>

@ -1,48 +0,0 @@
/*
* Copyright (c) 2016, 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
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Returns a context with the user object to be populated by the edit-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) {
var userModule = require("/app/modules/user.js")["userModule"];
var userName = request.getParameter("username");
var user, userRoles, devices;
if (userName) {
var response = userModule.getUser(userName);
if (response["status"] == "success") {
user = response["content"];
user.domain = response["userDomain"];
}
response = userModule.getRolesByUsername(userName);
if (response["status"] == "success") {
userRoles = response["content"];
}
var deviceModule = require("/app/modules/device.js").deviceModule;
devices = deviceModule.getDevices(userName);
}
return {"user": user, "userRoles": userRoles, "devices": devices};
}
Loading…
Cancel
Save