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 35bb3cc408..65a6dc6a2e 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 @@ -69,24 +69,12 @@ function hidePopup() { $(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 * when a user clicks on "Invite" link * on User Management page in WSO2 MDM Console. */ -$("a.invite-user-link").click(function () { +$("a#invite-user-link").click(function () { var usernameList = getSelectedUsernames(); var inviteUserAPI = apiBasePath + "/users/send-invitation"; @@ -122,42 +110,16 @@ $("a.invite-user-link").click(function () { }); }); -/** - * Following click function would execute - * when a user clicks on "Remove" link - * on User Listing page in WSO2 MDM Console. +/* + * Function to get selected usernames. */ -function removeUser(uname) { - var username = uname; - var removeUserAPI = apiBasePath + "/users/" + username; - $(modalPopupContent).html($('#remove-user-modal-content').html()); - 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(); +function getSelectedUsernames() { + var usernameList = []; + var userList = $("#user-grid").find("tr.DTTT_selected"); + userList.each(function () { + usernameList.push($(this).data('username')); }); + return usernameList; } /** @@ -165,15 +127,13 @@ function removeUser(uname) { * when a user clicks on "Reset Password" link * on User Listing page in WSO2 MDM Console. */ -function resetPassword(uname) { - +function resetPassword(username) { $(modalPopupContent).html($('#reset-password-window').html()); showPopup(); $("a#reset-password-yes-link").click(function () { var newPassword = $("#new-password").val(); var confirmedPassword = $("#confirmed-password").val(); - var user = uname; var errorMsgWrapper = "#notification-error-msg"; var errorMsg = "#notification-error-msg span"; @@ -191,10 +151,9 @@ function resetPassword(uname) { $(errorMsgWrapper).removeClass("hidden"); } else { var resetPasswordFormData = {}; - //resetPasswordFormData.username = user; resetPasswordFormData.newPassword = unescape(confirmedPassword); - var resetPasswordServiceURL = apiBasePath + "/admin/users/"+ user +"/credentials"; + var resetPasswordServiceURL = apiBasePath + "/admin/users/"+ username +"/credentials"; invokerUtil.post( resetPasswordServiceURL, @@ -223,6 +182,43 @@ function resetPassword(uname) { }); } +/** + * Following click function would execute + * when a user clicks on "Remove" link + * on User Listing page in WSO2 MDM Console. + */ +function removeUser(username) { + var removeUserAPI = apiBasePath + "/users/" + username; + $(modalPopupContent).html($('#remove-user-modal-content').html()); + 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 * when a user clicks on the list item 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 5a3128a4e2..c74c4870ef 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 @@ -77,14 +77,14 @@