v7.2.5.0: Refactor execution of group changes in user settings

This commit streamlines the way user group data is handled, both in scripts and server-side logic. The group settings URL has been simplified and the logic for updating user groups also has been optimized. Eliminated unnecessary checks in the user.py module, and updated the routing logic for group data to utilize a single route with HTTP GET and PUT methods. Removed unsuccessful group changing errors.
This commit is contained in:
Aidaho
2024-05-15 21:35:38 +03:00
parent 88471af613
commit c56d105ef5
4 changed files with 20 additions and 30 deletions

View File

@@ -941,7 +941,7 @@ $( function() {
$('#disable_alerting').prop('checked', true).checkboxradio('refresh');
}
$.ajax({
url: "/app/user/group/current",
url: "/app/user/group",
success: function (data) {
if (data.indexOf('danger') != '-1') {
$("#ajax").html(data);
@@ -1184,21 +1184,20 @@ createHistroy();
listHistroy();
function changeCurrentGroupF() {
Cookies.remove('group');
Cookies.set('group', $('#newCurrentGroup').val(), {expires: 365, path: '/', samesite: 'strict', secure: 'true'});
$.ajax({
url: "/app/user/group/change",
url: "/app/user/group",
data: {
changeUserCurrentGroupId: $('#newCurrentGroup').val(),
changeUserGroupsUser: Cookies.get('uuid'),
token: $('#token').val()
group: $('#newCurrentGroup').val(),
uuid: Cookies.get('uuid')
},
type: "POST",
type: "PUT",
success: function (data) {
if (data.indexOf('error: ') != '-1') {
toastr.error(data);
} else {
toastr.clear();
Cookies.remove('group');
Cookies.set('group', $('#newCurrentGroup').val(), {expires: 365, path: '/', samesite: 'strict', secure: 'true'});
location.reload();
}
}