Skip to content

Commit

Permalink
Merge pull request #2595 from phili67/userlist-update
Browse files Browse the repository at this point in the history
userlist update to suppress : $.ajax
  • Loading branch information
phili67 committed Apr 11, 2024
2 parents 86c7f4f + 997c842 commit 163783c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 35 deletions.
64 changes: 30 additions & 34 deletions src/skin/js/user/UserList.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$(function() {
$(function () {

$(".check_all").on('click', function () {
var state = this.checked;
Expand Down Expand Up @@ -42,8 +42,8 @@ $(function() {
window.CRM.APIRequest({
method: 'POST',
path: 'users/applyrole',
data: JSON.stringify({"userID": userID, "roleID": roleID})
},function (data) {
data: JSON.stringify({ "userID": userID, "roleID": roleID })
}, function (data) {
if (data.success == true) {
// à terminer !!!
$('.role' + data.userID).html(data.roleName);
Expand All @@ -64,8 +64,8 @@ $(function() {
window.CRM.APIRequest({
method: 'POST',
path: 'users/webdavKey',
data: JSON.stringify({"userID": userID})
},function (data) {
data: JSON.stringify({ "userID": userID })
}, function (data) {
if (data.status == 'success') {
var message = i18next.t("The WebDav Key is") + " : ";
if (data.token != null) {
Expand Down Expand Up @@ -96,8 +96,8 @@ $(function() {
window.CRM.APIRequest({
method: 'POST',
path: 'users/lockunlock',
data: JSON.stringify({"userID": userID})
},function (data) {
data: JSON.stringify({ "userID": userID })
}, function (data) {
if (data.success == true) {
if (lock == false) {
content.removeClass('fa-unlock');
Expand Down Expand Up @@ -146,7 +146,7 @@ $(function() {
window.CRM.APIRequest({
method: "DELETE",
path: "users/" + userId
},function (data) {
}, function (data) {
if (data.status == "success")
$("#row-" + userId).remove();
});
Expand All @@ -155,7 +155,7 @@ $(function() {
});
});

$("#user-listing-table tbody").on('click', '.restUserLoginCount', function () {
$("#user-listing-table tbody").on('click', '.resetUserLoginCount', function () {
var userId = $(this).data('id');
var userName = $(this).data('name');
var parentTd = $(this).parent();
Expand All @@ -166,12 +166,10 @@ $(function() {
i18next.t("Please confirm reset failed login count") + ": <b>" + userName + "</b></p>",
callback: function (result) {
if (result) {
$.ajax({
method: "POST",
url: window.CRM.root + "/api/users/" + userId + "/login/reset",
dataType: "json",
encode: true,
}).done(function (data) {
window.CRM.APIRequest({
method: 'POST',
path: 'users/' + userId + "/login/reset"
}, function (data) {
if (data.status == "success")
parentTd.html('0');
window.CRM.showGlobalMessage(i18next.t("Reset failed login count for") + ' ' + userName + ' ' + i18next.t('done.'), "info");
Expand All @@ -191,12 +189,10 @@ $(function() {
i18next.t("Please confirm the password reset of this user") + ": <b>" + userName + "</b></p>",
callback: function (result) {
if (result) {
$.ajax({
method: "POST",
url: window.CRM.root + "/api/users/" + userId + "/password/reset",
dataType: "json",
encode: true,
}).done(function (data) {
window.CRM.APIRequest({
method: 'POST',
path: 'users/' + userId + "/password/reset"
}, function (data) {
if (data.status == "success")
window.CRM.showGlobalMessage(i18next.t("Password reset for") + userName, "info");
});
Expand All @@ -205,13 +201,13 @@ $(function() {
});
});

$('#user-listing-table tbody').on('click', '.control-account', function() {
$('#user-listing-table tbody').on('click', '.control-account', function () {
var userId = $(this).data("userid");
window.CRM.APIRequest({
method: 'POST',
path: 'users/controlAccount',
data: JSON.stringify({"userID": userId})
},function (data) {
data: JSON.stringify({ "userID": userId })
}, function (data) {
if (data.success) {
window.location = window.CRM.root;
}
Expand All @@ -225,49 +221,49 @@ $(function() {
title: i18next.t("Two factors authentications"),
message: '<p><ul>' +
'<li>' +
i18next.t("Delete") + " : " + i18next.t("to remove two-factor authentication") +
i18next.t("Delete") + " : " + i18next.t("to remove two-factor authentication") +
'</li>' +
'<li>' +
i18next.t("Pending") + " : " + i18next.t("Gives the user 60 seconds to log in with their recovery codes. The user will then have to delete or simply rescan the QR-code in the OTP Management application.") +
i18next.t("Pending") + " : " + i18next.t("Gives the user 60 seconds to log in with their recovery codes. The user will then have to delete or simply rescan the QR-code in the OTP Management application.") +
'</li>' +
'</ul>' +
'</p>',
buttons: [
{
label: '<i class="fas fa-times"></i> ' + i18next.t("Close"),
className: "btn btn-secondary",
callback: function() {
callback: function () {
}
},
{
label: '<i class="fas fa-trash-alt"></i> ' + i18next.t("Delete"),
className: "btn btn-danger",
callback: function() {
callback: function () {
window.CRM.APIRequest({
method: 'POST',
path: 'users/2fa/remove',
data: JSON.stringify({"userID": userID})
},function (data) {
data: JSON.stringify({ "userID": userID })
}, function (data) {
location.reload();
});
}
},
{
label: '<i class="fas fa-clock"></i> ' + i18next.t("Pending"),
className: "btn btn-primary",
callback: function() {
callback: function () {
window.CRM.APIRequest({
method: 'POST',
path: 'users/2fa/pending',
data: JSON.stringify({"userID": userID})
},function (data) {
data: JSON.stringify({ "userID": userID })
}, function (data) {
i18next.t("The user has 60 seconds to use his recovery codes.");
});
}
}
],
show: false,
onEscape: function() {
onEscape: function () {
modal.modal("hide");
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/v2/templates/user/userlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class="far fa-trash-alt" aria-hidden="true" style="color:red"></i></a>
}
if ($user->getFailedLogins() > 0) {
?>
<a href="#" class="restUserLoginCount" data-id="<?= $user->getId() ?>" data-name="<?= $user->getPerson()->getFullName() ?>"
<a href="#" class="resetUserLoginCount" data-id="<?= $user->getId() ?>" data-name="<?= $user->getPerson()->getFullName() ?>"
data-toggle="tooltip" data-placement="bottom" title="" data-original-title="<?= _("Reset failed login") ?>"><i
class="fas fa-eraser" aria-hidden="true"></i></a>
<?php
Expand Down

0 comments on commit 163783c

Please sign in to comment.