Fixing issue: user-list not getting updated upon user-removal

4.x.x
dilanua 8 years ago
parent 74658d1e85
commit b636738be3

@ -17,14 +17,14 @@
*/ */
/* /*
* This module contains user and roles related functionality * This module contains user and roles related functionality.
*/ */
var userModule = function () { var userModule = function () {
var log = new Log("/app/modules/user.js"); var log = new Log("/app/modules/user.js");
var constants = require("/app/modules/constants.js"); var constants = require("/app/modules/constants.js");
var utility = require("/app/modules/utility.js")["utility"]; var utility = require("/app/modules/utility.js")["utility"];
var devicemgtProps = require('/app/conf/devicemgt-props.js').config(); var devicemgtProps = require("/app/conf/devicemgt-props.js").config();
var serviceInvokers = require("/app/modules/backend-service-invoker.js").backendServiceInvoker; var serviceInvokers = require("/app/modules/backend-service-invoker.js").backendServiceInvoker;
/* Initializing user manager */ /* Initializing user manager */

@ -138,9 +138,7 @@ $("a.invite-user-link").click(function () {
* when a user clicks on "Remove" link * when a user clicks on "Remove" link
* on User Listing page in WSO2 Devicemgt Console. * on User Listing page in WSO2 Devicemgt Console.
*/ */
function removeUser(uname, uid) { function removeUser(username) {
var username = uname;
var userId = uid;
var removeUserAPI = deviceMgtAPIsBasePath + "/users/" + username; var removeUserAPI = deviceMgtAPIsBasePath + "/users/" + username;
$(modalPopupContent).html($('#remove-user-modal-content').html()); $(modalPopupContent).html($('#remove-user-modal-content').html());
showPopup(); showPopup();
@ -148,21 +146,18 @@ function removeUser(uname, uid) {
$("a#remove-user-yes-link").click(function () { $("a#remove-user-yes-link").click(function () {
invokerUtil.delete( invokerUtil.delete(
removeUserAPI, removeUserAPI,
// success callback
function (data, textStatus, jqXHR) { function (data, textStatus, jqXHR) {
if (jqXHR.status == 200) { if (jqXHR.status == 200) {
$("#" + 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 // update modal-content with success message
$(modalPopupContent).html($('#remove-user-success-content').html()); $(modalPopupContent).html($('#remove-user-success-content').html());
$("a#remove-user-success-link").click(function () { $("a#remove-user-success-link").click(function () {
hidePopup(); hidePopup();
location.reload();
}); });
} }
}, },
// The error callback // error callback
function (jqXHR) { function (jqXHR) {
console.log("error in remove-user API, status code: " + jqXHR.status); console.log("error in remove-user API, status code: " + jqXHR.status);
$(modalPopupContent).html($('#remove-user-error-content').html()); $(modalPopupContent).html($('#remove-user-error-content').html());
@ -282,7 +277,7 @@ function loadUsers() {
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})
}); });
var json = { var json = {
@ -360,7 +355,7 @@ function loadUsers() {
]; ];
$('#user-grid').datatables_extended_serverside_paging(null, '/api/device-mgt/v1.0/users', dataFilter, columns, fnCreatedRow, null); $("#user-grid").datatables_extended_serverside_paging(null, '/api/device-mgt/v1.0/users', dataFilter, columns, fnCreatedRow, null);
$("#loading-content").hide(); $("#loading-content").hide();
} }

Loading…
Cancel
Save