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 1241ba7fe6c..35bb3cc408d 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 @@ -32,7 +32,7 @@ $(function () { var sortableElem = '.wr-sortable'; $(sortableElem).sortable({ beforeStop: function () { - var sortedIDs = $(this).sortable('toArray'); + $(this).sortable('toArray'); } }); $(sortableElem).disableSelection(); @@ -43,7 +43,6 @@ var modalPopup = ".wr-modalpopup"; var modalPopupContainer = modalPopup + " .modalpopup-container"; var modalPopupContent = modalPopup + " .modalpopup-content"; var body = "body"; -var isInit = true; $(".icon .text").res_text(0.2); /* @@ -137,17 +136,15 @@ function removeUser(uname) { $("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 (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()); @@ -202,14 +199,17 @@ function resetPassword(uname) { invokerUtil.post( resetPasswordServiceURL, resetPasswordFormData, - function (data, textStatus, jqXHR) { // The success callback + // The success callback + function (data, textStatus, jqXHR) { if (jqXHR.status == 200) { $(modalPopupContent).html($('#reset-password-success-content').html()); $("a#reset-password-success-link").click(function () { hidePopup(); }); } - }, function (jqXHR) { // The error callback + }, + // The error callback + function (jqXHR) { var payload = JSON.parse(jqXHR.responseText); $(errorMsg).text(payload.message); $(errorMsgWrapper).removeClass("hidden"); @@ -223,17 +223,6 @@ function resetPassword(uname) { }); } -/** - * Following on click function would execute - * when a user type on the search field on User Listing page in - * WSO2 MDM Console then click on the search button. - */ -//$("#search-btn").click(function () { -// var searchQuery = $("#search-by-username").val(); -// $("#ast-container").empty(); -// loadUsers(searchQuery); -//}); - /** * Following function would execute * when a user clicks on the list item @@ -260,9 +249,9 @@ function loadUsers() { $(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 : '', + 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}) }); @@ -294,28 +283,36 @@ function loadUsers() { class: "fade-edge", data: null, render: function (data, type, row, meta) { - return '