From 73563a047e862a6c2fc81808f41817ddc84f58e1 Mon Sep 17 00:00:00 2001 From: Aidaho Date: Fri, 5 Apr 2024 20:21:42 +0300 Subject: [PATCH] v7.2.2.0: Update error handling in waf.js and fix favicon and script paths Refactored error handling in the waf.js file to simplify and reduce conditional checks. Also updated the paths for favicon images and included scripts to ensure accurate addressing, enhancing the consistency and reliability of the application's behavior. --- app/static/images/favicon/browserconfig.xml | 2 +- app/static/images/favicon/manifest.json | 10 +++++----- app/static/js/waf.js | 15 +++++---------- app/templates/waf.html | 3 ++- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/app/static/images/favicon/browserconfig.xml b/app/static/images/favicon/browserconfig.xml index 2a691896..917bab94 100644 --- a/app/static/images/favicon/browserconfig.xml +++ b/app/static/images/favicon/browserconfig.xml @@ -1,2 +1,2 @@ -#ffffff \ No newline at end of file +#ffffff \ No newline at end of file diff --git a/app/static/images/favicon/manifest.json b/app/static/images/favicon/manifest.json index 34479cd8..0b3adef6 100644 --- a/app/static/images/favicon/manifest.json +++ b/app/static/images/favicon/manifest.json @@ -8,31 +8,31 @@ "density": "0.75" }, { - "src": "\/inc\/images\/favicon\/android-icon-48x48.png", + "src": "\/app\/static\/images\/favicon\/android-icon-48x48.png", "sizes": "48x48", "type": "image\/png", "density": "1.0" }, { - "src": "\/inc\/images\/favicon\/android-icon-72x72.png", + "src": "\/app\/static\/images\/favicon\/android-icon-72x72.png", "sizes": "72x72", "type": "image\/png", "density": "1.5" }, { - "src": "\/inc\/images\/favicon\/android-icon-96x96.png", + "src": "\/app\/static\/images\/favicon\/android-icon-96x96.png", "sizes": "96x96", "type": "image\/png", "density": "2.0" }, { - "src": "\/inc\/images\/favicon\/android-icon-144x144.png", + "src": "\/app\/static\/images\/favicon\/android-icon-144x144.png", "sizes": "144x144", "type": "image\/png", "density": "3.0" }, { - "src": "\/inc\/images\/favicon\/android-icon-192x192.png", + "src": "\/app\/static\/images\/favicon\/android-icon-192x192.png", "sizes": "192x192", "type": "image\/png", "density": "4.0" diff --git a/app/static/js/waf.js b/app/static/js/waf.js index 7e4cf18c..34f024d4 100644 --- a/app/static/js/waf.js +++ b/app/static/js/waf.js @@ -55,12 +55,11 @@ function installWaf(ip1) { url: "/app/install/waf/" + service + "/" + ip1, type: "POST", success: function (data) { - if (data.indexOf('error:') != '-1' || data.indexOf('Failed') != '-1' || data.indexOf('fatal') != '-1') { - toastr.error(data); - } else if (data.indexOf('Info') != '-1') { - toastr.clear(); - toastr.info(data); - } else { + try { + if (data.indexOf('error:') != '-1') { + toastr.error(data); + } + } catch (e) { toastr.clear(); parseAnsibleJsonOutput(data, `${service} WAF`, false); showOverviewWaf(ip, hostnamea); @@ -75,10 +74,6 @@ function changeWafMode(id) { var service = cur_url[1]; $.ajax({ url: "/app/waf/" + service + "/mode/" + server_hostname + "/" + waf_mode, - // data: { - // token: $('#token').val() - // }, - // type: "POST", success: function (data) { toastr.info('Do not forget restart WAF service'); $('#' + server_hostname + '-select-line').addClass("update", 1000); diff --git a/app/templates/waf.html b/app/templates/waf.html index cb9fada9..167539d9 100644 --- a/app/templates/waf.html +++ b/app/templates/waf.html @@ -2,7 +2,8 @@ {% block title %}{{title}}{% endblock %} {% block h2 %}{{title}}{% endblock %} {% block content %} - + + {% if manage_rules == '1' %} {% from 'include/input_macros.html' import input, checkbox %}