v7.3.2.0: Refactor javascript code and update error handling in API

This commit includes two major changes. Javascript code in udp.js has been refactored to fix the sequence of operations. We have moved the getScript function inside the bracket to ensure smoother operation. Also, error handling in api_funct.py has been simplified and made more consistent by passing json.loads instead of raw strings to install_service method, and by directly setting 'e' as a value in case of exceptions. A minor style change has also been added on ha_cluster.html.
pull/390/head
Aidaho 2024-07-10 09:57:11 +03:00
parent 9a193e43f9
commit 508f7d4cc1
3 changed files with 8 additions and 8 deletions

View File

@ -862,25 +862,25 @@ def create_ha_cluster():
try:
json_loads['cluster_id'] = cluster_id
json_dump = json.dumps(json_loads)
service_mod.install_service('keepalived', json_dump)
service_mod.install_service('keepalived', json.loads(json_dump))
except Exception as e:
data['status'].setdefault('keepalived', f'error: {e}')
data['status'].setdefault('keepalived', f'{e}')
else:
data['status'].setdefault('keepalived', 'done')
if json_loads['services']['haproxy']['enabled']:
try:
service_mod.install_service('haproxy', body)
service_mod.install_service('haproxy', json.loads(body))
except Exception as e:
data['status'].setdefault('haproxy', f'error: {e}')
data['status'].setdefault('haproxy', f'{e}')
else:
data['status'].setdefault('haproxy', 'done')
if json_loads['services']['nginx']['enabled']:
try:
service_mod.install_service('nginx', body)
service_mod.install_service('nginx', json.loads(body))
except Exception as e:
data['status'].setdefault('nginx', f'error: {e}')
data['status'].setdefault('nginx', f'{e}')
else:
data['status'].setdefault('nginx', 'done')

View File

@ -346,10 +346,10 @@ function getUDPListener(listener_id, new_listener=false) {
$('#listener-' + listener_id).replaceWith(data);
}
$('#listener-'+listener_id).removeClass('animated-background');
$.getScript(awesome);
}
}
});
$.getScript(awesome);
}
function confirmDeleteListener(listener_id) {
$("#dialog-confirm").dialog({

View File

@ -110,7 +110,7 @@
</td>
</tr>
<tr>
<td class="help_cursor">
<td class="padding20 help_cursor">
<span title="{{lang.ha_page.use_src_help}}">{{ lang.ha_page.use_src }}</span>
</td>
<td class="help_cursor">