diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js
index 70e9089a5f..a93b1a48cc 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js
@@ -18,18 +18,16 @@
/**
* Returns the dynamic state to be populated by add-user page.
- *
- * @param context Object that gets updated with the dynamic state of this page to be presented
* @returns {*} A context object that returns the dynamic state of this page to be presented
*/
-function onRequest(context) {
+function onRequest() {
//var log = new Log("/app/pages/cdmf.page.user.create server-side js");
- var userModule = require("/app/modules/user.js")["userModule"];
- var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
+ var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
+ var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var page = {};
- var response = userModule.getRolesByUserStore();
+ var response = userModule.getRolesByUserStore("PRIMARY");
if (response["status"] == "success") {
page["roles"] = response["content"];
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/public/js/bottomJs.js
index 7280042d59..c254b82cc9 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/public/js/bottomJs.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/public/js/bottomJs.js
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
@@ -72,8 +72,8 @@ var disableInlineError = function (inputField, errorMsg, errorSign) {
* Validate if provided username is valid against RegEx configures.
*/
validateInline["user-name"] = function () {
- var usernameinput = $("input#username");
- if (inputIsValid(usernameinput.data("regex"), usernameinput.val())) {
+ var usernameInput = $("input#username");
+ if (inputIsValid(usernameInput.data("regex"), usernameInput.val())) {
disableInlineError("usernameInputField", "usernameEmpty", "usernameError");
} else {
enableInlineError("usernameInputField", "usernameEmpty", "usernameError");
@@ -84,9 +84,9 @@ validateInline["user-name"] = function () {
* Validate if provided first name is valid against RegEx configures.
*/
validateInline["first-name"] = function () {
- var firstnameinput = $("input#firstname");
- if (firstnameinput.val()) {
- disableInlineError("firstNameField", "fnError");
+ var firstnameInput = $("input#firstname");
+ if (firstnameInput.val()) {
+ disableInlineError("firstNameField", "fnError");
} else {
enableInlineError("firstNameField", "fnError");
}
@@ -96,8 +96,8 @@ validateInline["first-name"] = function () {
* Validate if provided last name is valid against RegEx configures.
*/
validateInline["last-name"] = function () {
- var lastnameinput = $("input#lastname");
- if (lastnameinput.val()) {
+ var lastnameInput = $("input#lastname");
+ if (lastnameInput.val()) {
disableInlineError("lastNameField", "lnError");
} else {
enableInlineError("lastNameField", "lnError");
@@ -165,9 +165,9 @@ $("#userStore").change(
function () {
var str = "";
$("select option:selected").each(function () {
- str += $(this).text() + " ";
+ str += $(this).text() + "";
});
- var getRolesAPI = deviceMgtAPIsBasePath + "/roles/"+ str;
+ var getRolesAPI = deviceMgtAPIsBasePath + "/roles?user-store=" + str + "&limit=100";
invokerUtil.get(
getRolesAPI,
@@ -188,8 +188,7 @@ $("#userStore").change(
}
);
- }
-).change();
+ }).change();
$(document).ready(function () {
$("#emailValidationText").hide();
@@ -207,7 +206,7 @@ $(document).ready(function () {
var usernameInput = $("input#username");
var firstnameInput = $("input#firstname");
var lastnameInput = $("input#lastname");
- //var charLimit = parseInt($("input#username").attr("limit"));
+ var charLimit = parseInt($("input#username").attr("limit"));
var domain = $("#userStore").val();
var username = usernameInput.val().trim();
var firstname = firstnameInput.val();
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/edit.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/edit.js
index 8f94c2902b..a8eab03731 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/edit.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/edit.js
@@ -17,10 +17,10 @@
*/
function onRequest(context) {
- var userModule = require("/app/modules/user.js").userModule;
+ var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var userName = request.getParameter("username");
var user = userModule.getUser(userName)["content"];
- var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
+ var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
if (user) {
var title;
if (user.firstname || user.lastname) {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.js
index 8b41bc8a36..4528f4cba4 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.js
@@ -17,10 +17,9 @@
*/
function onRequest(context) {
- var userModule = require("/app/modules/user.js").userModule;
+ var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var username = request.getParameter("username");
var user = userModule.getUser(username)["content"];
- var userModule = require("/app/modules/user.js")["userModule"];
var userName = request.getParameter("username");
@@ -38,7 +37,7 @@ function onRequest(context) {
if (response["status"] == "success") {
userRoles = response["content"];
}
- var deviceModule = require("/app/modules/device.js").deviceModule;
+ var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
devices = deviceModule.getDevices(userName);
}
return {"user": user, "userRoles": userRoles, "devices": devices};
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js
index b2db97ca66..abd9c2da6d 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js
@@ -1,54 +1,37 @@
/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ * 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
+ * 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
+ * "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.
*/
-var deviceMgtAPIsBasePath = "/api/device-mgt/v1.0";
-
-/**
- * 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.
- */
$(function () {
var sortableElem = '.wr-sortable';
$(sortableElem).sortable({
beforeStop: function () {
- $(this).sortable('toArray');
+ var sortedIDs = $(this).sortable('toArray');
}
});
$(sortableElem).disableSelection();
});
+var apiBasePath = "/api/device-mgt/v1.0";
var modalPopup = ".wr-modalpopup";
var modalPopupContainer = modalPopup + " .modalpopup-container";
var modalPopupContent = modalPopup + " .modalpopup-content";
var body = "body";
-//var isInit = true;
+var isInit = true;
$(".icon .text").res_text(0.2);
/*
@@ -90,11 +73,11 @@ function getSelectedUsernames() {
/**
* Following click function would execute
* when a user clicks on "Invite" link
- * on User Management page in WSO2 Devicemgt Console.
+ * on User Management page in WSO2 MDM Console.
*/
$("a.invite-user-link").click(function () {
var usernameList = getSelectedUsernames();
- var inviteUserAPI = deviceMgtAPIsBasePath + "/users/send-invitation";
+ var inviteUserAPI = apiBasePath + "/users/send-invitation";
if (usernameList.length == 0) {
$(modalPopupContent).html($("#errorUsers").html());
@@ -108,18 +91,13 @@ $("a.invite-user-link").click(function () {
invokerUtil.post(
inviteUserAPI,
usernameList,
- // success callback
- function (data, textStatus, jqXHR) {
- if (jqXHR.status == 200) {
- $(modalPopupContent).html($('#invite-user-success-content').html());
- $("a#invite-user-success-link").click(function () {
- hidePopup();
- });
- }
+ function () {
+ $(modalPopupContent).html($('#invite-user-success-content').html());
+ $("a#invite-user-success-link").click(function () {
+ hidePopup();
+ });
},
- // error callback
- function (jqXHR) {
- console.log("error in invite-user API, status code: " + jqXHR.status);
+ function () {
$(modalPopupContent).html($('#invite-user-error-content').html());
$("a#invite-user-error-link").click(function () {
hidePopup();
@@ -136,30 +114,31 @@ $("a.invite-user-link").click(function () {
/**
* Following click function would execute
* when a user clicks on "Remove" link
- * on User Listing page in WSO2 Devicemgt Console.
+ * on User Listing page in WSO2 MDM Console.
*/
-function removeUser(username) {
- var removeUserAPI = deviceMgtAPIsBasePath + "/users/" + username;
+function removeUser(uname, uid) {
+ var username = uname;
+ var userid = uid;
+ var removeUserAPI = apiBasePath + "/users/" + username;
$(modalPopupContent).html($('#remove-user-modal-content').html());
showPopup();
$("a#remove-user-yes-link").click(function () {
invokerUtil.delete(
removeUserAPI,
- // success callback
- function (data, textStatus, jqXHR) {
- if (jqXHR.status == 200) {
- // update modal-content with success message
- $(modalPopupContent).html($('#remove-user-success-content').html());
- $("a#remove-user-success-link").click(function () {
- hidePopup();
- location.reload();
- });
- }
+ function () {
+ $("#" + userid).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();
+ });
},
- // error callback
- function (jqXHR) {
- console.log("error in remove-user API, status code: " + jqXHR.status);
+ function () {
$(modalPopupContent).html($('#remove-user-error-content').html());
$("a#remove-user-error-link").click(function () {
hidePopup();
@@ -207,23 +186,19 @@ function resetPassword(uname) {
//resetPasswordFormData.username = user;
resetPasswordFormData.newPassword = unescape(confirmedPassword);
- var resetPasswordServiceURL = deviceMgtAPIsBasePath + "/admin/users/"+ user +"/credentials";
+ var resetPasswordServiceURL = apiBasePath + "/admin/users/"+ user +"/credentials";
invokerUtil.post(
resetPasswordServiceURL,
resetPasswordFormData,
- // success callback
- function (data, textStatus, jqXHR) {
+ function (data, textStatus, jqXHR) { // The success callback
if (jqXHR.status == 200) {
$(modalPopupContent).html($('#reset-password-success-content').html());
$("a#reset-password-success-link").click(function () {
hidePopup();
});
}
- },
- // error callback
- function (jqXHR) {
- console.log("error in reset-password API, status code: " + jqXHR.status);
+ }, function (jqXHR) { // The error callback
var payload = JSON.parse(jqXHR.responseText);
$(errorMsg).text(payload.message);
$(errorMsgWrapper).removeClass("hidden");
@@ -253,7 +228,7 @@ $("#search-btn").click(function () {
* when a user clicks on the list item
* initial mode and with out select mode.
*/
-function initiateViewOption() {
+function InitiateViewOption() {
if ($("#can-view").val()) {
$(location).attr('href', $(this).data("url"));
} else {
@@ -262,137 +237,172 @@ function initiateViewOption() {
}
}
-function loadUsers() {
- var loadingContentIcon = "#loading-content";
- $(loadingContentIcon).show();
+function loadUsers(searchParam) {
- var dataFilter = function (data) {
+
+ $("#loading-content").show();
+
+
+ var dataFilter = function(data){
data = JSON.parse(data);
var objects = [];
- $(data.users).each(
- function (index) {
- objects.push(
- {
- username: data.users[index].username,
- firstname: data.users[index].firstname ? data.users[index].firstname: '' ,
- lastname: data.users[index].lastname ? data.users[index].lastname : '',
- emailAddress : data.users[index].emailAddress ? data.users[index].emailAddress: '',
- DT_RowId : "user-" + data.users[index].username
- }
- )
- }
- );
+ $(data.users).each(function( index ) {
+ objects.push({
+ filter: data.users[index].username,
+ firstname: data.users[index].firstname ? data.users[index].firstname: '' ,
+ lastname: data.users[index].lastname ? data.users[index].lastname : '',
+ emailAddress : data.users[index].emailAddress ? data.users[index].emailAddress: '',
+ DT_RowId : "role-" + data.users[index].username})
+ });
- var json = {
+ json = {
"recordsTotal": data.count,
"recordsFiltered": data.count,
"data": objects
};
- return JSON.stringify(json);
- };
+ return JSON.stringify( json );
+ }
- var fnCreatedRow = function(nRow, aData, iDataIndex) {
- console.log(JSON.stringify(aData));
+ var fnCreatedRow = function( nRow, aData, iDataIndex ) {
$(nRow).attr('data-type', 'selectable');
$(nRow).attr('data-username', aData["username"]);
- };
+ }
var columns = [
{
class: "remove-padding icon-only content-fill",
data: null,
- defaultContent:
- '
' +
- '' +
- '
'
+ defaultContent: '
'
},
{
class: "fade-edge",
data: null,
- render: function (data, type, row, meta) {
+ render: function ( data, type, row, meta ) {
return '
' + data.firstname + ' ' + data.lastname + '
';
}
},
{
class: "fade-edge remove-padding-top",
- data: null,
- render: function (data, type, row, meta) {
- return '
' + data.username;
+ data: 'filter',
+ render: function ( filter, type, row, meta ) {
+ return '
' + filter;
}
},
{
class: "fade-edge remove-padding-top",
data: null,
- render: function (data, type, row, meta) {
- return '
' +
- data.emailAddress + ' ';
+ render: function ( data, type, row, meta ) {
+ return '
' + data.emailAddress + ' ';
}
},
{
class: "text-right content-fill text-left-on-grid-view no-wrap",
data: null,
- render: function (data, type, row, meta) {
- return '
' +
- '' +
- '' +
- '' +
- '' +
- ' Edit' +
- '' +
- '
' +
- '' +
- '' +
- '' +
- '' +
- ' ' +
- '' +
- ' ' +
- '' +
- '' +
- ' Reset Password' +
- '' +
- '
' +
- '' +
- '' +
- '' +
- '' +
- ' Remove ' +
- ''
+ render: function ( data, type, row, meta ) {
+ return '
' +
+ ' ' +
+ ' Edit ' +
+
+ '
' +
+ ' ' +
+ ' Remove ' +
+
+ '
' +
+ ' <' +
+ '/i> ' +
+ ' Reset '
}
}
];
- $("#user-grid").datatables_extended_serverside_paging(
- null, '/api/device-mgt/v1.0/users', dataFilter, columns, fnCreatedRow, null
- );
+
+ var options = {
+ "placeholder": "Search By Username",
+ "searchKey" : "filter"
+ };
+
+
+ $('#user-grid').datatables_extended_serverside_paging(null, '/api/device-mgt/v1.0/users', dataFilter, columns, fnCreatedRow, null, options);
$("#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 () {
loadUsers();
$(".viewEnabledIcon").click(function () {
- initiateViewOption();
+ InitiateViewOption();
});
-
if (!$("#can-invite").val()) {
$("#invite-user-button").remove();
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/users.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/users.hbs
index 560f597bbe..ae90987ece 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/users.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/users.hbs
@@ -81,31 +81,58 @@