merge-requests/7/head
harshanl 8 years ago
commit 8e6c15acf2

@ -28,13 +28,15 @@
<baseDirectory>${basedir}/src</baseDirectory> <baseDirectory>${basedir}/src</baseDirectory>
<fileSets> <fileSets>
<fileSet> <fileSet>
<!-- CDMF base app -->
<directory>${basedir}/src/main/resources/jaggeryapps/devicemgt</directory> <directory>${basedir}/src/main/resources/jaggeryapps/devicemgt</directory>
<outputDirectory>/jaggeryapps/devicemgt-cdmf/</outputDirectory> <outputDirectory>/jaggeryapps/devicemgt-cdmf/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes> <useDefaultExcludes>true</useDefaultExcludes>
</fileSet> </fileSet>
<fileSet> <fileSet>
<!-- UUF framework app -->
<directory>${basedir}/src/main/resources/jaggeryapps/uuf-template-app</directory> <directory>${basedir}/src/main/resources/jaggeryapps/uuf-template-app</directory>
<outputDirectory>/jaggeryapps/devicemgt-cdmf/</outputDirectory> <outputDirectory>/jaggeryapps/uuf-template-app/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes> <useDefaultExcludes>true</useDefaultExcludes>
</fileSet> </fileSet>
<fileSet> <fileSet>

@ -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"]);
if (response.status == "success") {
response.content = parse(response.content); response.content = parse(response.content);
}
return response; return response;
} catch (e) { } catch (e) {
throw e; throw e;

@ -24,17 +24,117 @@
</a> </a>
</li> </li>
<li> <li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/roles"> <a href="{{@app.context}}/roles">
Roles Roles
</a> </a>
</li> </li>
<li> <li>
<a href="{{@app.context}}/roles/add-role"> <!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/role/add">
Add Add
</a> </a>
</li> </li>
{{/zone}} {{/zone}}
{{#zone "content"}} {{#zone "content"}}
{{unit "cdmf.unit.role.create"}} <!-- content/body -->
<div class="row">
<div class="col-md-12">
<!-- content -->
<div id="role-create-form" class="container col-centered wr-content">
<div class="wr-form">
<p class="page-sub-title">Add Role</p>
<hr />
<div class="row">
<div class="col-lg-8">
<div class="wr-steps">
<div class="col-md-6 col-xs-6">
<div class="itm-wiz itm-wiz-current" data-step="policy-platform">
<div class="wiz-no">1</div>
<div class="wiz-lbl hidden-xs"><span>Add a role</span></div>
</div>
</div>
<div class="col-md-6 col-xs-6">
<div class="itm-wiz" data-step="policy-profile">
<div class="wiz-no">2</div>
<div class="wiz-lbl hidden-xs"><span>Assign permissions</span></div>
</div>
</div>
<br class="c-both" />
</div>
<br /><br />
<hr />
<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">User Store Domain</label>
<div class="wr-input-control">
<!--suppress HtmlFormInputWithoutLabel -->
<select id="domain" class="form-control select">
<option>PRIMARY</option>
{{#each userStores}}
<option>{{this}}</option>
{{/each}}
</select>
</div>
<label class="wr-input-label">
Role Name *
</label>
<br>
<label class="wr-input-label">
( {{roleNameHelpText}} )
</label>
<div id="roleNameField" class="form-group wr-input-control">
<!--suppress HtmlFormInputWithoutLabel -->
<input type="text" id="roleName" data-regex="{{roleNameJSRegEx}}"
data-error-msg="{{roleNameRegExViolationErrorMsg}}" class="form-control" />
<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 not include any whitespaces.
</label>
</div>
<label class="wr-input-label">
User list
</label>
<div class="wr-input-control">
<!--suppress HtmlFormInputWithoutLabel -->
<select id="users" class="form-control select2" multiple="multiple"></select>
</div>
</div>
</div>
<br>
<button id="add-role-btn" class="wr-btn">Add 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 added successfully.</p>
<br>Please click <b>"Add Another Role"</b>, if you wish to add another role or click
<b>"View Role List"</b> to complete the process and go back to the role list.
<hr />
<button class="wr-btn" onclick="window.location.href='{{@app.context}}/roles'">
View Role List
</button>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/role/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 Role
</a>
</div>
</div>
<!-- /content -->
<div id="app-context" data-app-context="{{@app.context}}" class="hidden"></div>
</div>
</div>
<!-- /content/body -->
{{/zone}}
{{#zone "bottomJs"}}
{{js "js/bottomJs.js"}}
{{/zone}} {{/zone}}

@ -25,14 +25,11 @@
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 response = userModule.getRoles();
if (response["status"] == "success") { context["userStores"] = userModule.getSecondaryUserStores();
context["roles"] = response["content"]; context["roleNameJSRegEx"] = deviceMgtProps["roleValidationConfig"]["roleNameJSRegEx"];
} context["roleNameHelpText"] = deviceMgtProps["roleValidationConfig"]["roleNameHelpMsg"];
var userStores = userModule.getSecondaryUserStores(); context["roleNameRegExViolationErrorMsg"] = deviceMgtProps["roleValidationConfig"]["roleNameRegExViolationErrorMsg"];
context["userStores"] = userStores;
context["roleNameJSRegEx"] = deviceMgtProps.roleValidationConfig.rolenameJSRegEx;
context["roleNameHelpText"] = deviceMgtProps.roleValidationConfig.rolenameHelpMsg;
context["roleNameRegExViolationErrorMsg"] = deviceMgtProps.roleValidationConfig.rolenameRegExViolationErrorMsg;
return context; return context;
} }

@ -1,5 +1,5 @@
{ {
"version": "1.0.0", "version": "1.0.0",
"uri": "/roles/add-role", "uri": "/role/add",
"layout": "cdmf.layout.default" "layout": "cdmf.layout.default"
} }

@ -73,19 +73,19 @@ var disableInlineError = function (inputField, errorMsg, errorSign) {
*clear inline validation messages. *clear inline validation messages.
*/ */
clearInline["role-name"] = function () { clearInline["role-name"] = function () {
disableInlineError("roleNameField", "rolenameEmpty", "rolenameError"); disableInlineError("roleNameField", "roleNameEmpty", "roleNameError");
}; };
/** /**
* Validate if provided rolename is valid against RegEx configures. * Validate if provided role-name is valid against RegEx configures.
*/ */
validateInline["role-name"] = function () { validateInline["role-name"] = function () {
var rolenameinput = $("input#rolename"); var roleNameInput = $("input#roleName");
if (inputIsValid( rolenameinput.data("regex"), rolenameinput.val())) { if (inputIsValid( roleNameInput.data("regex"), roleNameInput.val())) {
disableInlineError("roleNameField", "rolenameEmpty", "rolenameError"); disableInlineError("roleNameField", "roleNameEmpty", "roleNameError");
} else { } else {
enableInlineError("roleNameField", "rolenameEmpty", "rolenameError"); enableInlineError("roleNameField", "roleNameEmpty", "roleNameError");
} }
}; };
@ -97,16 +97,16 @@ function formatRepo (user) {
return; return;
} }
var markup = '<div class="clearfix">' + var markup = '<div class="clearfix">' +
'<div clas="col-sm-8">' + '<div class="col-sm-8">' +
'<div class="clearfix">' + '<div class="clearfix">' +
'<div class="col-sm-3">' + user.username + '</div>'; '<div class="col-sm-3">User : ' + user.username + '</div>';
if (user.firstname) { if (user.name) {
markup += '<div class="col-sm-3"><i class="fa fa-code-fork"></i> ' + user.firstname + '</div>'; markup += '<div class="col-sm-3"> ' + user.name + '</div>';
} }
if (user.emailAddress) { if (user.emailAddress) {
markup += '<div class="col-sm-2"><i class="fa fa-star"></i> ' + user.emailAddress + '</div></div>'; markup += '<div class="col-sm-3"> ' + user.emailAddress + '</div>';
} }
markup += '</div></div>'; markup += '</div></div></div>';
return markup; return markup;
} }
@ -129,17 +129,19 @@ $(document).ready(function () {
}, },
data: function (params) { data: function (params) {
var postData = {}; var postData = {};
postData.actionMethod = "GET"; postData.requestMethod = "GET";
postData.actionUrl = apiBasePath + "/users/search/usernames?filter=" + params.term; postData.requestURL = "/api/device-mgt/v1.0/users/search/usernames?filter=" + params.term;
postData.actionPayload = null; postData.requestPayload = null;
return JSON.stringify(postData); return JSON.stringify(postData);
}, },
processResults: function (data, page) { processResults: function (data) {
var newData = []; var newData = [];
$.each(data, function (index, value) { $.each(data, function (index, value) {
var user = {}; var user = {};
user.username = value.username;
user.id = value.username; user.id = value.username;
user.username = value.username;
user.name = value.firstname + " " + value.lastname;
user.emailAddress = value.emailAddress;
newData.push(user); newData.push(user);
}); });
return { return {
@ -159,10 +161,10 @@ $(document).ready(function () {
* when a user clicks on "Add Role" button * when a user clicks on "Add Role" button
* on Add Role page in WSO2 MDM Console. * on Add Role page in WSO2 MDM Console.
*/ */
$("button#add-role-btn").click(function() { $("button#add-role-btn").click(function () {
var rolenameInput = $("input#rolename");
var roleName = rolenameInput.val();
var domain = $("#domain").val(); var domain = $("#domain").val();
var roleNameInput = $("input#roleName");
var roleName = roleNameInput.val();
var users = $("#users").val(); var users = $("#users").val();
var errorMsgWrapper = "#role-create-error-msg"; var errorMsgWrapper = "#role-create-error-msg";
@ -170,8 +172,8 @@ $(document).ready(function () {
if (!roleName) { if (!roleName) {
$(errorMsg).text("Role name is a required field. It cannot be empty."); $(errorMsg).text("Role name is a required field. It cannot be empty.");
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");
} else if (!inputIsValid(rolenameInput.data("regex"), roleName)) { } else if (!inputIsValid(roleNameInput.data("regex"), roleName)) {
$(errorMsg).text(rolenameInput.data("errormsg")); $(errorMsg).text(roleNameInput.data("error-msg"));
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");
} else if (!domain) { } else if (!domain) {
$(errorMsg).text("Domain is a required field. It cannot be empty."); $(errorMsg).text("Domain is a required field. It cannot be empty.");
@ -181,13 +183,11 @@ $(document).ready(function () {
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");
} else { } else {
var addRoleFormData = {}; var addRoleFormData = {};
addRoleFormData.roleName = roleName; addRoleFormData.roleName = roleName;
if (domain != "PRIMARY"){ if (domain != "PRIMARY"){
addRoleFormData.roleName = domain + "/" + roleName; addRoleFormData.roleName = domain + "/" + roleName;
} }
if (users == null){ if (users == null) {
users = []; users = [];
} }
addRoleFormData.users = users; addRoleFormData.users = users;
@ -197,37 +197,31 @@ $(document).ready(function () {
invokerUtil.post( invokerUtil.post(
addRoleAPI, addRoleAPI,
addRoleFormData, addRoleFormData,
function (data) { function (data, textStatus, jqXHR) {
data = JSON.parse(data); if (jqXHR.status == 201) {
if (data.errorMessage) {
$(errorMsg).text("Selected user store prompted an error : " + data.errorMessage);
$(errorMsgWrapper).removeClass("hidden");
} else {
// Clearing user input fields. // Clearing user input fields.
//$("input#rolename").val(""); $("input#roleName").val("");
//$("#domain").val(""); $("#domain").val("PRIMARY");
//// Refreshing with success message $("#users").val("");
//$("#role-create-form").addClass("hidden"); window.location.href = appContext + "/role/edit-permission/" + roleName;
//$("#role-created-msg").removeClass("hidden");
window.location.href = appContext + '/role/edit-permission/' + roleName;
}
}, function (data) {
if (JSON.parse(data).errorMessage.indexOf("RoleExisting") > -1) {
$(errorMsg).text("Role name : " + roleName + " already exists. Pick another role name.");
} else {
$(errorMsg).text(JSON.parse(data.responseText).errorMessage);
} }
},
function (jqXHR) {
if (jqXHR.status == 500) {
$(errorMsg).text("Either role already exists or unexpected error.");
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");
} }
}
); );
} }
}); });
$("#rolename").focus(function() { var roleNameInputElement = "#roleName";
$(roleNameInputElement).focus(function() {
clearInline["role-name"](); clearInline["role-name"]();
}); });
$("#rolename").blur(function() { $(roleNameInputElement).blur(function() {
validateInline["role-name"](); validateInline["role-name"]();
}); });
}); });

@ -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>

@ -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
@ -10,17 +10,58 @@
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* KIND, either express or implied. See the License for the * either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
var loadRoleBasedActionURL = function (action, rolename) { var loadRoleBasedActionURL = function (action, rolename) {
var href = $("#ast-container").data("app-context") + "role/" + action + "/" + rolename; var href = $("#ast-container").data("app-context") + "role/" + action + "/" + rolename;
$(location).attr('href', href); $(location).attr('href', href);
}; };
$(function () {
var sortableElem = '.wr-sortable';
$(sortableElem).sortable({
beforeStop: function () {
$(this).sortable('toArray');
}
});
$(sortableElem).disableSelection();
});
var apiBasePath = "/api/device-mgt/v1.0"; var apiBasePath = "/api/device-mgt/v1.0";
var modalPopup = ".wr-modalpopup";
var modalPopupContainer = modalPopup + " .modalpopup-container";
var modalPopupContent = modalPopup + " .modalpopup-content";
var body = "body";
$(".icon .text").res_text(0.2);
/*
* set popup maximum height function.
*/
function setPopupMaxHeight() {
$(modalPopupContent).css('max-height', ($(body).height() - ($(body).height() / 100 * 30)));
$(modalPopupContainer).css('margin-top', (-($(modalPopupContainer).height() / 2)));
}
/*
* show popup function.
*/
function showPopup() {
$(modalPopup).show();
setPopupMaxHeight();
}
/*
* hide popup function.
*/
function hidePopup() {
$(modalPopupContent).html('');
$(modalPopup).hide();
}
/** /**
* Following function would execute * Following function would execute
@ -31,103 +72,96 @@ function InitiateViewOption() {
$(location).attr('href', $(this).data("url")); $(location).attr('href', $(this).data("url"));
} }
/** function loadRoles() {
* Sorting function of roles
* listed on Role Management page in WSO2 Devicemgt Console.
*/
var loadPaginatedObjects = function (objectGridId, objectGridContainer, objectGridTemplateSrc, serviceURL, callback) {
var templateSrc = $(objectGridTemplateSrc).attr("src");
$.template(objectGridId, templateSrc, function (template) {
invokerUtil.get(serviceURL,
function (data) {
data = callback(data);
if (data.length > 0 && data != null) {
$('#ast-container').removeClass('hidden');
$('#role-listing-status').hide();
for (var i = 0; i < data.viewModel.roles.length; i++) {
data.viewModel.roles[i].adminRole = $("#role-table").data("role");
}
var content = template(data.viewModel);
$(objectGridContainer).html(content);
if (isInit) {
$('#role-grid').datatables_extended_serverside_paging();
isInit = false;
}
$("#dt-select-all").addClass("hidden");
$(".icon .text").res_text(0.2);
} else {
$('#ast-container').addClass('hidden');
$('#role-listing-status-msg').text('No roles are available to be displayed.');
$('#role-listing-status').show();
}
//$(objectGridId).datatables_extended();
}, function (message) {
$('#ast-container').addClass('hidden');
$('#role-listing-status-msg').text('Invalid search query. Try again with a valid search ' +
'query');
$('#role-listing-status').show();
});
});
};
function loadRoles(searchQuery) {
var loadingContent = $("#loading-content"); var loadingContent = $("#loading-content");
loadingContent.show(); loadingContent.show();
var dataFilter = function(data){ var dataFilter = function (data) {
data = JSON.parse(data); data = JSON.parse(data);
var objects = []; var objects = [];
$(data.roles).each(function( index ) { $(data.roles).each(function( index ) {
objects.push({name: data.roles[index], DT_RowId : "role-" + data.roles[index]}) objects.push(
{
name: data.roles[index],
DT_RowId: "role-" + data.roles[index]
}
)
}); });
json = { var json = {
"recordsTotal": data.count, "recordsTotal": data.count,
"recordsFiltered": data.count, "recordsFiltered": data.count,
"data": objects "data": objects
}; };
return JSON.stringify( json ); return JSON.stringify(json);
} };
var fnCreatedRow = function( nRow, aData, iDataIndex ) { //noinspection JSUnusedLocalSymbols
var fnCreatedRow = function (nRow, aData, iDataIndex) {
$(nRow).attr('data-type', 'selectable'); $(nRow).attr('data-type', 'selectable');
} };
//noinspection JSUnusedLocalSymbols
var columns = [ var columns = [
{ {
class: "remove-padding icon-only content-fill", class: "remove-padding icon-only content-fill",
data: null, data: null,
defaultContent: '<div class="thumbnail icon"> <i class="square-element text fw fw-user" style="font-size: 30px;"></i></div>' defaultContent: "<div class='thumbnail icon'>" +
"<i class='square-element text fw fw-bookmark' style='font-size: 30px;'></i>" +
"</div>"
}, },
{ {
class: "fade-edge remove-padding-top", class: "fade-edge",
data: "name", data: "name",
defaultContent: '' render: function (name, type, row, meta) {
return '<h4>&nbsp;&nbsp;' + name + '&nbsp;role</h4>';
}
}, },
{ {
class: "text-right content-fill text-left-on-grid-view no-wrap", class: "text-right content-fill text-left-on-grid-view no-wrap",
data: null, data: null,
render: function ( data, type, row, meta ) { render: function (data, type, row, meta) {
return '<a onclick="javascript:loadRoleBasedActionURL(\'edit\', \'' + data.name + '\')" data-role="' + data.name + return '&nbsp;' +
'" data-click-event="edit-form" class="btn padding-reduce-on-grid-view edit-role-link"><span class="fw-stack fw-lg">' + '<a onclick="javascript:loadRoleBasedActionURL(\'edit\', \'' + data.name + '\')" ' +
'<i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-user fw-stack-1x"></i>' + 'data-role="' + data.name + '" ' +
'<span class="fw-stack fw-move-right fw-move-bottom"><i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i>' + 'data-click-event="edit-form" ' +
'<i class="fw fw-circle fw-stack-2x"></i><i class="fw fw-edit fw-stack-1x fw-inverse"></i></span></span>' + 'class="btn padding-reduce-on-grid-view edit-role-link">' +
'<span class="hidden-xs hidden-on-grid-view">Edit</span></a>' + '<span class="fw-stack">' +
'<a onclick="javascript:loadRoleBasedActionURL(\'edit-permission\', \'' + data.name + '<i class="fw fw-ring fw-stack-2x"></i>' +
'\')" data-role="' + data.name + '" data-click-event="edit-form" class="btn padding-reduce-on-grid-view edit-permission-link">' + '<i class="fw fw-bookmark fw-stack-1x"></i>' +
'<span class="fw-stack fw-lg"><i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-security-policy fw-stack-1x"></i>' + '<span class="fw-stack fw-move-right fw-move-bottom">' +
'<span class="fw-stack fw-move-right fw-move-bottom"><i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i>' + '<i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i>' +
'<i class="fw fw-circle fw-stack-2x"></i><i class="fw fw-edit fw-stack-1x fw-inverse"></i></span></span>' + '<i class="fw fw-circle fw-stack-2x"></i><i class="fw fw-edit fw-stack-1x fw-inverse"></i>' +
'<span class="hidden-xs hidden-on-grid-view">Edit Permission</span></a>' + '</span>' +
'<a data-role="' + data.name + '" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-role-link">' + '</span>' +
'<span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-delete fw-stack-1x"></i></span>' + '<span class="hidden-xs hidden-on-grid-view">&nbsp;&nbsp;Edit</span>' +
'<span class="hidden-xs hidden-on-grid-view">Remove</span></a>' '</a>' +
'&nbsp;<a onclick="javascript:loadRoleBasedActionURL(\'edit-permission\', \'' + data.name + '\')" ' +
'data-role="' + data.name + '" ' +
'data-click-event="edit-form" ' +
'class="btn padding-reduce-on-grid-view edit-permission-link">' +
'<span class="fw-stack">' +
'<i class="fw fw-ring fw-stack-2x"></i>' +
'<i class="fw fw-security-policy fw-stack-1x"></i>' +
'<span class="fw-stack fw-move-right fw-move-bottom">' +
'<i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i>' +
'<i class="fw fw-circle fw-stack-2x"></i><i class="fw fw-edit fw-stack-1x fw-inverse"></i>' +
'</span>' +
'</span>' +
'<span class="hidden-xs hidden-on-grid-view">&nbsp;&nbsp;Edit Permission</span>' +
'</a>' +
'&nbsp;<a data-role="' + data.name + '" ' +
'data-click-event="remove-form" ' +
'class="btn padding-reduce-on-grid-view remove-role-link">' +
'<span class="fw-stack">' +
'<i class="fw fw-ring fw-stack-2x"></i>' +
'<i class="fw fw-delete fw-stack-1x"></i>' +
'</span>' +
'<span class="hidden-xs hidden-on-grid-view">&nbsp;&nbsp;Remove</span>' +
'</a>';
} }
} }
]; ];
@ -138,42 +172,10 @@ function loadRoles(searchQuery) {
}; };
$('#role-grid').datatables_extended_serverside_paging(null, '/api/device-mgt/v1.0/roles', dataFilter, columns, fnCreatedRow, null, options); $('#role-grid').datatables_extended_serverside_paging(null, '/api/device-mgt/v1.0/roles', dataFilter, columns, fnCreatedRow, null, options);
loadingContent.hide(); loadingContent.hide();
} }
var modalPopup = ".wr-modalpopup";
var modalPopupContainer = modalPopup + " .modalpopup-container";
var modalPopupContent = modalPopup + " .modalpopup-content";
var body = "body";
var isInit = true;
/*
* set popup maximum height function.
*/
function setPopupMaxHeight() {
$(modalPopupContent).css('max-height', ($(body).height() - ($(body).height() / 100 * 30)));
$(modalPopupContainer).css('margin-top', (-($(modalPopupContainer).height() / 2)));
}
/*
* show popup function.
*/
function showPopup() {
$(modalPopup).show();
setPopupMaxHeight();
}
/*
* hide popup function.
*/
function hidePopup() {
$(modalPopupContent).html('');
$(modalPopup).hide();
}
/** /**
* Following click function would execute * Following click function would execute
* when a user clicks on "Remove" link * when a user clicks on "Remove" link
@ -210,17 +212,6 @@ $("#role-grid").on("click", ".remove-role-link", function () {
}); });
}); });
$("#search-btn").click(function () {
var searchQuery = $("#search-by-name").val();
if (searchQuery.trim() != "") {
loadRoles(searchQuery);
} else {
loadRoles();
}
});
$(document).ready(function () { $(document).ready(function () {
$('#role-listing-status').hide();
loadRoles(); loadRoles();
isInit = true;
}); });

@ -15,8 +15,8 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
}} }}
{{unit "cdmf.unit.ui.title" pageTitle="Role Management"}}
{{unit "cdmf.unit.ui.title" pageTitle="Role Management"}}
{{unit "cdmf.unit.data-tables-extended"}} {{unit "cdmf.unit.data-tables-extended"}}
{{#zone "breadcrumbs"}} {{#zone "breadcrumbs"}}
@ -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>
@ -34,7 +35,8 @@
{{#zone "navbarActions"}} {{#zone "navbarActions"}}
<li> <li>
<a href="{{@app.context}}/roles/add-role" class="cu-btn"> <!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/role/add" class="cu-btn">
<span class="icon fw-stack"> <span class="icon fw-stack">
<i class="fw fw-add fw-stack-1x"></i> <i class="fw fw-add fw-stack-1x"></i>
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
@ -45,5 +47,114 @@
{{/zone}} {{/zone}}
{{#zone "content"}} {{#zone "content"}}
{{unit "cdmf.unit.role.listing"}} {{!
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.
}}
<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}}
<i class="fw fw-settings fw-spin fw-2x"></i>
Loading roles . . .
<br>
</div>
<div id="role-table" data-role={{adminRole}}>
<table class="table table-striped table-hover list-table display responsive nowrap data-table grid-view" id="role-grid">
<thead>
<tr class="sort-row">
<th>By Role Name</th>
</tr>
<tr class="bulk-action-row">
<th colspan="3"></th>
</tr>
</thead>
<tbody id="ast-container" data-app-context="{{appContext}}"></tbody>
</table>
</div>
<div id="content-filter-types" style="display: none">
<div class="sort-title">Sort By</div>
<div class="sort-options">
<!--suppress HtmlUnknownTag -->
<th>By Role name</th>
</div>
</div>
<div id="remove-role-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 role ?</h3>
<div class="buttons">
<a href="#" id="remove-role-yes-link" class="btn-operations">
Remove
</a>
<a href="#" id="remove-role-cancel-link" class="btn-operations">
Cancel
</a>
</div>
</div>
</div>
</div>
</div>
<div id="remove-role-success-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Done. Role was successfully removed.</h3>
<div class="buttons">
<a href="#" id="remove-role-success-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="remove-role-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-role-error-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
{{/zone}}
{{#zone "bottomJs"}}
<!--suppress HtmlUnknownTarget -->
<script id="role-listing" data-current-user="{{currentUser.username}}"
src="{{@page.publicUri}}/templates/role-listing.hbs" type="text/x-handlebars-template"></script>
{{js "js/role-listing.js"}}
{{/zone}} {{/zone}}

@ -18,8 +18,8 @@
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 response = userModule.getUsers(); var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var users = {};
context["permissions"] = userModule.getUIPermissions(); context["permissions"] = userModule.getUIPermissions();
if (userModule.isAuthorized("/permission/admin/device-mgt/roles/delete")) { if (userModule.isAuthorized("/permission/admin/device-mgt/roles/delete")) {
context["removePermitted"] = true; context["removePermitted"] = true;
@ -30,8 +30,9 @@ function onRequest(context) {
if (userModule.isAuthorized("/permission/admin/device-mgt/roles/remove")) { if (userModule.isAuthorized("/permission/admin/device-mgt/roles/remove")) {
context["removePermitted"] = true; context["removePermitted"] = true;
} }
var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"];
context["appContext"] = deviceMgtProps.appContext; context["appContext"] = deviceMgtProps["appContext"];
context["adminRole"] = deviceMgtProps.adminRole; context["adminRole"] = deviceMgtProps["adminRole"];
return context; return context;
} }

@ -32,7 +32,7 @@ $(function () {
var sortableElem = '.wr-sortable'; var sortableElem = '.wr-sortable';
$(sortableElem).sortable({ $(sortableElem).sortable({
beforeStop: function () { beforeStop: function () {
var sortedIDs = $(this).sortable('toArray'); $(this).sortable('toArray');
} }
}); });
$(sortableElem).disableSelection(); $(sortableElem).disableSelection();
@ -43,7 +43,6 @@ var modalPopup = ".wr-modalpopup";
var modalPopupContainer = modalPopup + " .modalpopup-container"; var modalPopupContainer = modalPopup + " .modalpopup-container";
var modalPopupContent = modalPopup + " .modalpopup-content"; var modalPopupContent = modalPopup + " .modalpopup-content";
var body = "body"; var body = "body";
var isInit = true;
$(".icon .text").res_text(0.2); $(".icon .text").res_text(0.2);
/* /*
@ -70,24 +69,12 @@ function hidePopup() {
$(modalPopup).hide(); $(modalPopup).hide();
} }
/*
* Function to get selected usernames.
*/
function getSelectedUsernames() {
var usernameList = [];
var userList = $("#user-grid").find('tr.DTTT_selected');
userList.each(function () {
usernameList.push($(this).data('username'));
});
return usernameList;
}
/** /**
* Following click function would execute * Following click function would execute
* when a user clicks on "Invite" link * when a user clicks on "Invite" link
* on User Management page in WSO2 MDM Console. * on User Management page in WSO2 MDM Console.
*/ */
$("a.invite-user-link").click(function () { $("a#invite-user-link").click(function () {
var usernameList = getSelectedUsernames(); var usernameList = getSelectedUsernames();
var inviteUserAPI = apiBasePath + "/users/send-invitation"; var inviteUserAPI = apiBasePath + "/users/send-invitation";
@ -123,44 +110,16 @@ $("a.invite-user-link").click(function () {
}); });
}); });
/** /*
* Following click function would execute * Function to get selected usernames.
* when a user clicks on "Remove" link
* on User Listing page in WSO2 MDM Console.
*/ */
function removeUser(uname) { function getSelectedUsernames() {
var username = uname; var usernameList = [];
var removeUserAPI = apiBasePath + "/users/" + username; var userList = $("#user-grid").find("tr.DTTT_selected");
$(modalPopupContent).html($('#remove-user-modal-content').html()); userList.each(function () {
showPopup(); usernameList.push($(this).data('username'));
$("a#remove-user-yes-link").click(function () {
invokerUtil.delete(
removeUserAPI,
function () {
$("#role-" + username).remove();
// get new user-list-count
var newUserListCount = $(".user-list > span").length;
// update user-listing-status-msg with new user-count
$("#user-listing-status-msg").text("Total number of Users found : " + newUserListCount);
// update modal-content with success message
$(modalPopupContent).html($('#remove-user-success-content').html());
$("a#remove-user-success-link").click(function () {
hidePopup();
});
},
function () {
$(modalPopupContent).html($('#remove-user-error-content').html());
$("a#remove-user-error-link").click(function () {
hidePopup();
});
}
);
});
$("a#remove-user-cancel-link").click(function () {
hidePopup();
}); });
return usernameList;
} }
/** /**
@ -168,15 +127,13 @@ function removeUser(uname) {
* when a user clicks on "Reset Password" link * when a user clicks on "Reset Password" link
* on User Listing page in WSO2 MDM Console. * on User Listing page in WSO2 MDM Console.
*/ */
function resetPassword(uname) { function resetPassword(username) {
$(modalPopupContent).html($('#reset-password-window').html()); $(modalPopupContent).html($('#reset-password-window').html());
showPopup(); showPopup();
$("a#reset-password-yes-link").click(function () { $("a#reset-password-yes-link").click(function () {
var newPassword = $("#new-password").val(); var newPassword = $("#new-password").val();
var confirmedPassword = $("#confirmed-password").val(); var confirmedPassword = $("#confirmed-password").val();
var user = uname;
var errorMsgWrapper = "#notification-error-msg"; var errorMsgWrapper = "#notification-error-msg";
var errorMsg = "#notification-error-msg span"; var errorMsg = "#notification-error-msg span";
@ -194,22 +151,24 @@ function resetPassword(uname) {
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");
} else { } else {
var resetPasswordFormData = {}; var resetPasswordFormData = {};
//resetPasswordFormData.username = user;
resetPasswordFormData.newPassword = unescape(confirmedPassword); resetPasswordFormData.newPassword = unescape(confirmedPassword);
var resetPasswordServiceURL = apiBasePath + "/admin/users/"+ user +"/credentials"; var resetPasswordServiceURL = apiBasePath + "/admin/users/"+ username +"/credentials";
invokerUtil.post( invokerUtil.post(
resetPasswordServiceURL, resetPasswordServiceURL,
resetPasswordFormData, resetPasswordFormData,
function (data, textStatus, jqXHR) { // The success callback // The success callback
function (data, textStatus, jqXHR) {
if (jqXHR.status == 200) { if (jqXHR.status == 200) {
$(modalPopupContent).html($('#reset-password-success-content').html()); $(modalPopupContent).html($('#reset-password-success-content').html());
$("a#reset-password-success-link").click(function () { $("a#reset-password-success-link").click(function () {
hidePopup(); hidePopup();
}); });
} }
}, function (jqXHR) { // The error callback },
// The error callback
function (jqXHR) {
var payload = JSON.parse(jqXHR.responseText); var payload = JSON.parse(jqXHR.responseText);
$(errorMsg).text(payload.message); $(errorMsg).text(payload.message);
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");
@ -224,15 +183,41 @@ function resetPassword(uname) {
} }
/** /**
* Following on click function would execute * Following click function would execute
* when a user type on the search field on User Listing page in * when a user clicks on "Remove" link
* WSO2 MDM Console then click on the search button. * on User Listing page in WSO2 MDM Console.
*/ */
$("#search-btn").click(function () { function removeUser(username) {
var searchQuery = $("#search-by-username").val(); var removeUserAPI = apiBasePath + "/users/" + username;
$("#ast-container").empty(); $(modalPopupContent).html($('#remove-user-modal-content').html());
loadUsers(searchQuery); showPopup();
});
$("a#remove-user-yes-link").click(function () {
invokerUtil.delete(
removeUserAPI,
function (data, textStatus, jqXHR) {
if (jqXHR.status == 200) {
$("#user-" + username).remove();
// update modal-content with success message
$(modalPopupContent).html($('#remove-user-success-content').html());
$("a#remove-user-success-link").click(function () {
hidePopup();
});
}
},
function () {
$(modalPopupContent).html($('#remove-user-error-content').html());
$("a#remove-user-error-link").click(function () {
hidePopup();
});
}
);
});
$("a#remove-user-cancel-link").click(function () {
hidePopup();
});
}
/** /**
* Following function would execute * Following function would execute
@ -248,169 +233,132 @@ function InitiateViewOption() {
} }
} }
function loadUsers(searchParam) { function loadUsers() {
var loadingContentView = "#loading-content";
$(loadingContentView).show();
$("#loading-content").show();
var dataFilter = function(data){ var dataFilter = function (data) {
data = JSON.parse(data); data = JSON.parse(data);
var objects = []; var objects = [];
$(data.users).each(function( index ) { $(data.users).each( function (index) {
objects.push({ objects.push({
filter: data.users[index].username, filter: data.users[index].username,
firstname: data.users[index].firstname ? data.users[index].firstname: '' , firstname: data.users[index].firstname ? data.users[index].firstname : "" ,
lastname: data.users[index].lastname ? data.users[index].lastname : '', lastname: data.users[index].lastname ? data.users[index].lastname : "",
emailAddress : data.users[index].emailAddress ? data.users[index].emailAddress: '', emailAddress : data.users[index].emailAddress ? data.users[index].emailAddress : "",
DT_RowId : "role-" + data.users[index].username}) DT_RowId : "user-" + data.users[index].username})
}); });
json = { var json = {
"recordsTotal": data.count, "recordsTotal": data.count,
"recordsFiltered": data.count, "recordsFiltered": data.count,
"data": objects "data": objects
}; };
return JSON.stringify( json ); return JSON.stringify(json);
} };
var fnCreatedRow = function( nRow, aData, iDataIndex ) { //noinspection JSUnusedLocalSymbols
var fnCreatedRow = function (nRow, aData, iDataIndex) {
$(nRow).attr('data-type', 'selectable'); $(nRow).attr('data-type', 'selectable');
$(nRow).attr('data-username', aData["filter"]); $(nRow).attr('data-username', aData["filter"]);
} };
//noinspection JSUnusedLocalSymbols
var columns = [ var columns = [
{ {
class: "remove-padding icon-only content-fill", class: "remove-padding icon-only content-fill",
data: null, data: null,
defaultContent: '<div class="thumbnail icon"> <i class="square-element text fw fw-user" style="font-size: 30px;"></i> </div>' defaultContent: '<div class="thumbnail icon">' +
'<i class="square-element text fw fw-user" style="font-size: 30px;"></i>' +
'</div>'
}, },
{ {
class: "fade-edge", class: "fade-edge",
data: null, data: null,
render: function ( data, type, row, meta ) { render: function (data, type, row, meta) {
return '<h4>' + data.firstname + ' ' + data.lastname + '</h4>'; if (!data.firstname && !data.lastname) {
return "";
} else if (data.firstname && data.lastname) {
return "<h4>&nbsp;&nbsp;" + data.firstname + " " + data.lastname + "</h4>";
}
} }
}, },
{ {
class: "fade-edge remove-padding-top", class: "fade-edge remove-padding-top",
data: 'filter', data: 'filter',
render: function ( filter, type, row, meta ) { render: function (filter, type, row, meta) {
return '<i class="fw-user"></i> ' + filter; return '&nbsp;&nbsp;<i class="fw-user"></i>&nbsp;&nbsp;' + filter;
} }
}, },
{ {
class: "fade-edge remove-padding-top", class: "fade-edge remove-padding-top",
data: null, data: null,
render: function ( data, type, row, meta ) { render: function (data, type, row, meta) {
return '<a href="mailto:' + data.emailAddress + ' " class="wr-list-email"> <i class="fw-mail"></i> ' + data.emailAddress + ' </a>'; if (!data.emailAddress) {
return "";
} else {
return "&nbsp;&nbsp;<a href='mailto:" + data.emailAddress + "' ><i class='fw-mail'></i>&nbsp;&nbsp;" + data.emailAddress + "</a>";
}
} }
}, },
{ {
class: "text-right content-fill text-left-on-grid-view no-wrap", class: "text-right content-fill text-left-on-grid-view no-wrap",
data: null, data: null,
render: function ( data, type, row, meta ) { render: function (data, type, row, meta) {
return '<a href="/emm/user/edit?username=' + data.filter + '" data-username="' + data.filter + return '&nbsp;<a href="/emm/user/edit?username=' + data.filter + '" data-username="' + data.filter + '" ' +
'" data-click-event="edit-form" class="btn padding-reduce-on-grid-view edit-user-link"> ' + 'data-click-event="edit-form" ' +
'<span class="fw-stack"> <i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-edit fw-stack-1x"></i>' + 'class="btn padding-reduce-on-grid-view edit-user-link"> ' +
' </span> <span class="hidden-xs hidden-on-grid-view">Edit</span> </a>' + '<span class="fw-stack"> ' +
'<i class="fw fw-ring fw-stack-2x"></i>' +
'<a href="#" data-username="' + data.filter + '" data-userid=' + data.filter + '<i class="fw fw-edit fw-stack-1x"></i>' +
' data-click-event="remove-form" onclick="javascript:removeUser(\'' + data.filter + '\')" ' + '</span>' +
'<span class="hidden-xs hidden-on-grid-view">' +
'&nbsp;&nbsp;Edit' +
'</span>' +
'</a>' +
'<a href="#" data-username="' + data.filter + '" data-userid="' + data.filter + '" ' +
'data-click-event="edit-form" ' +
'onclick="javascript:resetPassword(\'' + data.filter + '\')" ' +
'class="btn padding-reduce-on-grid-view remove-user-link">' +
'<span class="fw-stack">' +
'<i class="fw fw-ring fw-stack-2x"></i>' +
'<i class="fw fw-key fw-stack-1x"></i>' +
'</span>' +
'<span class="hidden-xs hidden-on-grid-view">' +
'&nbsp;&nbsp;Reset Password' +
'</span>' +
'</a>' +
'<a href="#" data-username="' + data.filter + '" data-userid="' + data.filter + '" ' +
'data-click-event="remove-form" ' +
'onclick="javascript:removeUser(\'' + data.filter + '\')" ' +
'class="btn padding-reduce-on-grid-view remove-user-link">' + 'class="btn padding-reduce-on-grid-view remove-user-link">' +
'<span class="fw-stack"> <i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-delete fw-stack-1x">' + '<span class="fw-stack">' +
'</i> </span> <span class="hidden-xs hidden-on-grid-view">Remove</span> </a>' + '<i class="fw fw-ring fw-stack-2x"></i>' +
'<i class="fw fw-delete fw-stack-1x"></i>' +
'<a href="#" data-username="' + data.filter + '" data-userid="' + data.filter + '</span>' +
'" data-click-event="edit-form" onclick="javascript:resetPassword(\'' + data.filter + '<span class="hidden-xs hidden-on-grid-view">' +
'\')" class="btn padding-reduce-on-grid-view remove-user-link"> <span class="fw-stack"> <i class="fw fw-ring fw-stack-2x">' + '&nbsp;&nbsp;Remove' +
'</i> <i class="fw fw-key fw-stack-1x"></i> <span class="fw-stack fw-move-right fw-move-bottom"> <i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"><' + '</span>' +
'/i> <i class="fw fw-circle fw-stack-2x"></i> <i class="fw fw-refresh fw-stack-1x fw-inverse">' + '</a>';
'</i> </span> </span> <span class="hidden-xs hidden-on-grid-view">Reset</span> </a>'
} }
} }
]; ];
var options = { var options = {
"placeholder": "Search By Username", "placeholder": "Search By Username",
"searchKey" : "filter" "searchKey" : "filter"
}; };
$('#user-grid').datatables_extended_serverside_paging(null, '/api/device-mgt/v1.0/users', dataFilter, columns, fnCreatedRow, null, options); $('#user-grid').datatables_extended_serverside_paging(null, '/api/device-mgt/v1.0/users', dataFilter, columns, fnCreatedRow, null, options);
$(loadingContentView).hide();
$("#loading-content").hide();
// $("#loading-content").show();
// var userListing = $("#user-listing");
// var userListingSrc = userListing.attr("src");
// $.template("user-listing", userListingSrc, function (template) {
// var serviceURL = apiBasePath + "/users";
// if (searchParam) {
// serviceURL = serviceURL + "?filter=" + searchParam;
// }
// var successCallback = function (data) {
// if (!data) {
// $('#ast-container').addClass('hidden');
// $('#user-listing-status-msg').text('No users are available to be displayed.');
// return;
// }
// var canRemove = $("#can-remove").val();
// var canEdit = $("#can-edit").val();
// var canResetPassword = $("#can-reset-password").val();
// data = JSON.parse(data);
// var viewModel = {};
// viewModel.users = data.users;
// for (var i = 0; i < viewModel.users.length; i++) {
// viewModel.users[i].userid = viewModel.users[i].username.replace(/[^\w\s]/gi, '');
// if (canRemove) {
// viewModel.users[i].canRemove = true;
// }
// if (canEdit) {
// viewModel.users[i].canEdit = true;
// }
// if (canResetPassword) {
// viewModel.users[i].canResetPassword = true;
// }
// viewModel.users[i].adminUser = $("#user-table").data("user");
// }
// if (data.count > 0) {
// $('#ast-container').removeClass('hidden');
// $('#user-listing-status-msg').text("");
// var content = template(viewModel);
// $("#ast-container").html(content);
// } else {
// $('#ast-container').addClass('hidden');
// $('#user-listing-status-msg').text('No users are available to be displayed.');
// }
// $("#loading-content").hide();
// if (isInit) {
// $('#user-grid').datatables_extended();
// isInit = false;
// }
// $(".icon .text").res_text(0.2);
// };
// invokerUtil.get(serviceURL,
// successCallback,
// function (message) {
// $('#ast-container').addClass('hidden');
// $('#user-listing-status-msg').
// text('Invalid search query. Try again with a valid search query');
// }
// );
// });
} }
$(document).ready(function () { $(document).ready(function () {
loadUsers(); loadUsers();
$(".viewEnabledIcon").click(function () { $(".viewEnabledIcon").click(function () {
InitiateViewOption(); InitiateViewOption();
}); });

@ -15,8 +15,8 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
}} }}
{{unit "cdmf.unit.ui.title" pageTitle="User Management"}}
{{unit "cdmf.unit.ui.title" pageTitle="User Management"}}
{{unit "cdmf.unit.data-tables-extended"}} {{unit "cdmf.unit.data-tables-extended"}}
{{#zone "breadcrumbs"}} {{#zone "breadcrumbs"}}
@ -26,6 +26,7 @@
</a> </a>
</li> </li>
<li> <li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/users"> <a href="{{@app.context}}/users">
USERS USERS
</a> </a>
@ -34,6 +35,7 @@
{{#zone "navbarActions"}} {{#zone "navbarActions"}}
<li> <li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/user/add"> <a href="{{@app.context}}/user/add">
<span class="icon fw-stack"> <span class="icon fw-stack">
<i class="fw fw-add fw-stack-1x"></i> <i class="fw fw-add fw-stack-1x"></i>
@ -64,83 +66,24 @@
<input type="hidden" id="can-reset-password" value="true"/> <input type="hidden" id="can-reset-password" value="true"/>
{{/if}} {{/if}}
<i class="fw fw-settings fw-spin fw-2x"></i> <i class="fw fw-settings fw-spin fw-2x"></i>
Loading users . . . Loading users . . .
<br> <br>
</div> </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}}> <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>-->
<table class="table table-striped table-hover list-table display responsive nowrap data-table grid-view" id="user-grid"> <table class="table table-striped table-hover list-table display responsive nowrap data-table grid-view" id="user-grid">
<thead> <thead>
<tr class="sort-row"> <tr class="sort-row">
<th>By Username</th> <th>By Username</th>
</tr> </tr>
<tr class="bulk-action-row"> <tr class="bulk-action-row">
<th colspan="5"> <th colspan="3">
<ul class="tiles"> <ul class="tiles">
<li class="square"> <li class="square">
<a href="#" data-click-event="remove-form" class="btn square-element invite-user-link" <a id="invite-user-link" href="#" data-click-event="remove-form" class="btn square-element"
data-toggle="modal" data-target="#modalDemo"> data-toggle="modal" data-target="#modalDemo">
<span class="icon fw-stack"> <span class="icon fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-invitation fw-stack-2x"></i>
<i class="fw fw-invitation fw-stack-1x"></i>
</span> </span>
Invite Selected Invite Selected
</a> </a>
@ -149,13 +92,10 @@
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody id="ast-container"> <tbody id="ast-container"></tbody>
<br class="c-both" />
</tbody>
</table> </table>
</div> </div>
<br class="c-both"/>
<div id="content-filter-types" style="display: none"> <div id="content-filter-types" style="display: none">
<div class="sort-title">Sort By</div> <div class="sort-title">Sort By</div>
<div class="sort-options"> <div class="sort-options">
@ -220,7 +160,6 @@
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-6 col-centered"> <div class="col-lg-5 col-md-6 col-centered">
<h3>Do you really want to remove this user ?</h3> <h3>Do you really want to remove this user ?</h3>
<div class="buttons"> <div class="buttons">
<a href="#" id="remove-user-yes-link" class="btn-operations"> <a href="#" id="remove-user-yes-link" class="btn-operations">
Remove Remove
@ -269,13 +208,13 @@
<div class="content"> <div class="content">
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-6 col-centered"> <div class="col-lg-5 col-md-6 col-centered">
<h3> <h2>
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-error fw-stack-1x"></i> <i class="fw fw-error fw-stack-1x"></i>
</span> </span>
Operation cannot be performed ! Operation cannot be performed !
</h3> </h2>
<h4> <h4>
Please select a user or a list of users to send invitation emails. Please select a user or a list of users to send invitation emails.
</h4> </h4>
@ -310,29 +249,28 @@
<div class="content"> <div class="content">
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-6 col-centered"> <div class="col-lg-5 col-md-6 col-centered">
<h3> <h2>
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-key fw-stack-1x"></i> <i class="fw fw-key fw-stack-1x"></i>
</span> </span>
Reset Password Reset Password
</h2>
<br> <br>
</h3>
<div id="notification-error-msg" class="alert alert-danger hidden" role="alert"> <div id="notification-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span> <i class="icon fw fw-error"></i><span></span>
</div> </div>
<h4> <h4>
Enter new password Enter new password
<br><br> <br><br>
<div> <!--suppress HtmlUnknownTag -->
<!--suppress HtmlFormInputWithoutLabel -->
<input type="password" class="form-control modal-input operationDataKeys" id="new-password" data-key="message"/> <input type="password" class="form-control modal-input operationDataKeys" id="new-password" data-key="message"/>
</div>
<br> <br>
Retype new password Retype new password
<br><br> <br><br>
<div> <!--suppress HtmlFormInputWithoutLabel -->
<input type="password" class="form-control modal-input operationDataKeys" id="confirmed-password" data-key="message"/> <input type="password" class="form-control modal-input operationDataKeys" id="confirmed-password" data-key="message"/>
</div>
<br> <br>
</h4> </h4>
<div class="buttons"> <div class="buttons">
@ -369,6 +307,7 @@
<!--Later add the navigation menu from here--> <!--Later add the navigation menu from here-->
{{/zone}} {{/zone}}
{{#zone "bottomJs"}} {{#zone "bottomJs"}}
<!--suppress HtmlUnknownTarget -->
<script id="user-listing" data-current-user="{{currentUser.username}}" <script id="user-listing" data-current-user="{{currentUser.username}}"
src="{{@page.publicUri}}/templates/listing.hbs" type="text/x-handlebars-template"></script> src="{{@page.publicUri}}/templates/listing.hbs" type="text/x-handlebars-template"></script>
{{js "js/listing.js"}} {{js "js/listing.js"}}

@ -1,116 +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.
}}
<!-- content/body -->
<div class="row">
<div class="col-md-12">
<!-- content -->
<div id="role-create-form" class="container col-centered wr-content">
<div class="wr-form">
<p class="page-sub-title">Add Role</p>
<hr />
<div class="row">
<div class="col-lg-8">
<div class="wr-steps">
<div class="col-md-6 col-xs-6">
<div class="itm-wiz itm-wiz-current" data-step="policy-platform">
<div class="wiz-no">1</div>
<div class="wiz-lbl hidden-xs"><span>Add a role</span></div>
</div>
<br class="c-both" />
</div>
<div class="col-md-6 col-xs-6">
<div class="itm-wiz" data-step="policy-profile">
<div class="wiz-no">2</div>
<div class="wiz-lbl hidden-xs"><span>Assign permissions</span></div>
</div>
<br class="c-both" />
</div>
</div>
<br /><br />
<hr />
<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">User Store Domain</label>
<div class="wr-input-control">
<select id="domain" class="form-control select">
<option>PRIMARY</option>
{{#each userStores}}
<option>{{this}}</option>
{{/each}}
</select>
</div>
<label class="wr-input-label">
Role Name *
</label>
<br>
<label class="wr-input-label">
( {{roleNameHelpText}} )
</label>
<div id="roleNameField" class="form-group wr-input-control">
<input type="text" id="rolename" data-regex="{{roleNameJSRegEx}}"
data-errormsg="{{roleNameRegExViolationErrorMsg}}" class="form-control" />
<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>
</div>
<label class="wr-input-label">
User list
</label>
<div class="wr-input-control">
<select id="users" class="form-control select2" multiple="multiple">
</select>
</div>
</div>
</div>
<br>
<button id="add-role-btn" class="wr-btn">Add 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 added successfully.</p>
<br>Please click <b>"Add Another Role"</b>, if you wish to add another role or click
<b>"View Role List"</b> to complete the process and go back to the role list.
<hr />
<button class="wr-btn" onclick="window.location.href='{{@app.context}}/roles'">
View Role List
</button>
<a href="{{@app.context}}/roles/add-role" 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 Role
</a>
</div>
</div>
<!-- /content -->
<div id="app-context" data-app-context="{{@app.context}}" class="hidden"></div>
</div>
</div>
<!-- /content/body -->
{{#zone "bottomJs"}}
{{js "js/bottomJs.js"}}
{{/zone}}

@ -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">

@ -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";
} }
//TODO: error scenario context["userStore"] = userStore;
context["roleNameJSRegEx"] = deviceMgtProps.roleValidationConfig.rolenameJSRegEx; context["roleNameJSRegEx"] = deviceMgtProps["roleValidationConfig"]["roleNameJSRegEx"];
context["roleNameHelpText"] = deviceMgtProps.roleValidationConfig.rolenameHelpMsg; context["roleNameHelpText"] = deviceMgtProps["roleValidationConfig"]["roleNameHelpMsg"];
context["roleNameRegExViolationErrorMsg"] = deviceMgtProps.roleValidationConfig.rolenameRegExViolationErrorMsg; context["roleNameRegExViolationErrorMsg"] = deviceMgtProps["roleValidationConfig"]["roleNameRegExViolationErrorMsg"];
return context;
} else {
//TODO: handle error scenario
return context; return context;
}
} }

@ -1,129 +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.
}}
<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}}
<i class="fw fw-settings fw-spin fw-2x"></i>
Loading roles . . .
<br>
</div>
<div id="role-listing-status" class="raw">
<ul style="list-style-type: none;">
<li class="message message-info">
<h4>
<i class="icon fw fw-info"></i>
<a id="role-listing-status-msg"></a>
</h4>
</li>
</ul>
</div>
<div id="role-table" data-role={{adminRole}}>
<table class="table table-striped table-hover list-table display responsive nowrap data-table row-view"
id="role-grid">
<thead>
<tr class="sort-row">
<th class="no-sort"></th>
<th>By Role Name</th>
<th class="no-sort"></th>
</tr>
<tr class="bulk-action-row">
<th colspan="3"></th>
</tr>
</thead>
<tbody id="ast-container" data-app-context="{{appContext}}">
<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">
<th>By Role name</th>
</div>
</div>
<div id="remove-role-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 role ?</h3>
<div class="buttons">
<a href="#" id="remove-role-yes-link" class="btn-operations">
Remove
</a>
<a href="#" id="remove-role-cancel-link" class="btn-operations">
Cancel
</a>
</div>
</div>
</div>
</div>
</div>
<div id="remove-role-success-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Done. Role was successfully removed.</h3>
<div class="buttons">
<a href="#" id="remove-role-success-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="remove-role-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-role-error-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
{{#zone "common-navigation"}}
<!--Later add the navigation menu from here-->
{{/zone}}
{{#zone "bottomJs"}}
<script id="role-listing" data-current-user="{{currentUser.username}}"
src="{{@unit.publicUri}}/templates/role-listing.hbs" type="text/x-handlebars-template"></script>
{{js "js/role-listing.js"}}
<script type="text/javascript">
var clientJsAppContext = "{{{@app.context}}}";
</script>
{{/zone}}

@ -16,7 +16,7 @@
under the License. under the License.
}} }}
{{#zone "topCss"}} {{#zone "topCss"}}
{{~css "css/validation-style.css"}} {{~css "css/validation-style.css" combine=false}}
{{/zone}} {{/zone}}
{{#zone "bottomJs"}} {{#zone "bottomJs"}}

@ -1,4 +1,6 @@
instructions.configure = \ instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt-cdmf);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt-cdmf);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.ui_${feature.version}/jaggeryapps/devicemgt-cdmf,target:${installFolder}/../../deployment/server/jaggeryapps/devicemgt-cdmf,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.ui_${feature.version}/jaggeryapps/devicemgt-cdmf,target:${installFolder}/../../deployment/server/jaggeryapps/devicemgt-cdmf,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/uuf-template-app);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.ui_${feature.version}/jaggeryapps/uuf-template-app,target:${installFolder}/../../deployment/server/jaggeryapps/uuf-template-app,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.ui_${feature.version}/jaggery-modules/utils/,target:${installFolder}/../../modules/utils,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.ui_${feature.version}/jaggery-modules/utils/,target:${installFolder}/../../modules/utils,overwrite:true);\
Loading…
Cancel
Save