v7.3.1.0: Improve error handling and streamline data formatting

This update reviews and adjusts multiple code segments across the project. The improvements are mainly focused on error handling with more informative exceptions and error messages. Additionally, data formatting and retrieval have been streamlined, mainly regarding JSON data preparation and use in several functions, which should expedite the data processing and enhance the code maintainability. Minor changes were also done on the front-end logic for error handling and improved user interaction.
This commit is contained in:
Aidaho
2024-06-19 20:52:24 +03:00
parent 6b24e8d39e
commit 811255ba0b
19 changed files with 202 additions and 218 deletions

View File

@@ -109,26 +109,29 @@ $( function() {
event.preventDefault();
});
$("#nettools_portscanner_form").on("click", ":submit", function (e) {
let port_server = $('#nettools_portscanner_server').val();
$('#ajax-nettools').html('');
if ($('#nettools_portscanner_server').val() == '') {
if (port_server == '') {
toastr.warning('Enter an address');
return false;
}
$.ajax({
url: "/app/portscanner/scan/" + $('#nettools_portscanner_server').val(),
url: "/app/portscanner/scan",
data: JSON.stringify({'ip': port_server}),
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (data) {
data = data.replace(/\s+/g, ' ');
if (data.indexOf('danger') != '-1' || data.indexOf('unique') != '-1' || data.indexOf('error:') != '-1') {
toastr.error(data);
if (data.status === 'failed') {
toastr.error(data.error);
} else {
toastr.clear();
$("#show_scans_ports_body").html(data);
$("#show_scans_ports_body").html(data.data);
$("#show_scans_ports").dialog({
resizable: false,
height: "auto",
width: 360,
modal: true,
title: "{{lang.words.opened|title()}} {{lang.words.ports}}",
title: "Opened ports",
buttons: [{
text: close_word,
click: function () {