Updating User Listing UI

This commit is contained in:
dilanua 2016-09-01 22:30:49 +05:30
parent 687efa97b1
commit 677385920e
2 changed files with 80 additions and 85 deletions

View File

@ -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,13 +110,84 @@ $("a.invite-user-link").click(function () {
});
});
/*
* 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 "Reset Password" link
* on User Listing page in WSO2 MDM Console.
*/
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 errorMsgWrapper = "#notification-error-msg";
var errorMsg = "#notification-error-msg span";
if (!newPassword) {
$(errorMsg).text("New password is a required field. It cannot be empty.");
$(errorMsgWrapper).removeClass("hidden");
} else if (!confirmedPassword) {
$(errorMsg).text("Retyping the new password is required.");
$(errorMsgWrapper).removeClass("hidden");
} else if (confirmedPassword != newPassword) {
$(errorMsg).text("New password doesn't match the confirmation.");
$(errorMsgWrapper).removeClass("hidden");
} else if (!inputIsValid(/^[\S]{5,30}$/, confirmedPassword)) {
$(errorMsg).text("Password should be minimum 5 characters long, should not include any whitespaces.");
$(errorMsgWrapper).removeClass("hidden");
} else {
var resetPasswordFormData = {};
resetPasswordFormData.newPassword = unescape(confirmedPassword);
var resetPasswordServiceURL = apiBasePath + "/admin/users/"+ username +"/credentials";
invokerUtil.post(
resetPasswordServiceURL,
resetPasswordFormData,
// 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();
});
}
},
// The error callback
function (jqXHR) {
var payload = JSON.parse(jqXHR.responseText);
$(errorMsg).text(payload.message);
$(errorMsgWrapper).removeClass("hidden");
}
);
}
});
$("a#reset-password-cancel-link").click(function () {
hidePopup();
});
}
/**
* Following click function would execute
* when a user clicks on "Remove" link
* on User Listing page in WSO2 MDM Console.
*/
function removeUser(uname) {
var username = uname;
function removeUser(username) {
var removeUserAPI = apiBasePath + "/users/" + username;
$(modalPopupContent).html($('#remove-user-modal-content').html());
showPopup();
@ -160,69 +219,6 @@ function removeUser(uname) {
});
}
/**
* Following click function would execute
* when a user clicks on "Reset Password" link
* on User Listing page in WSO2 MDM Console.
*/
function resetPassword(uname) {
$(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";
if (!newPassword) {
$(errorMsg).text("New password is a required field. It cannot be empty.");
$(errorMsgWrapper).removeClass("hidden");
} else if (!confirmedPassword) {
$(errorMsg).text("Retyping the new password is required.");
$(errorMsgWrapper).removeClass("hidden");
} else if (confirmedPassword != newPassword) {
$(errorMsg).text("New password doesn't match the confirmation.");
$(errorMsgWrapper).removeClass("hidden");
} else if (!inputIsValid(/^[\S]{5,30}$/, confirmedPassword)) {
$(errorMsg).text("Password should be minimum 5 characters long, should not include any whitespaces.");
$(errorMsgWrapper).removeClass("hidden");
} else {
var resetPasswordFormData = {};
//resetPasswordFormData.username = user;
resetPasswordFormData.newPassword = unescape(confirmedPassword);
var resetPasswordServiceURL = apiBasePath + "/admin/users/"+ user +"/credentials";
invokerUtil.post(
resetPasswordServiceURL,
resetPasswordFormData,
// 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();
});
}
},
// The error callback
function (jqXHR) {
var payload = JSON.parse(jqXHR.responseText);
$(errorMsg).text(payload.message);
$(errorMsgWrapper).removeClass("hidden");
}
);
}
});
$("a#reset-password-cancel-link").click(function () {
hidePopup();
});
}
/**
* Following function would execute
* when a user clicks on the list item

View File

@ -77,10 +77,10 @@
<th>By Username</th>
</tr>
<tr class="bulk-action-row">
<th colspan="5">
<th colspan="3">
<ul class="tiles">
<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">
<span class="icon fw-stack">
<i class="fw fw-invitation fw-stack-2x"></i>
@ -92,8 +92,7 @@
</th>
</tr>
</thead>
<tbody id="ast-container">
</tbody>
<tbody id="ast-container"></tbody>
</table>
</div>