From d19ddc23ebddbc13d84158a2d3a7a1f426f4d8a6 Mon Sep 17 00:00:00 2001 From: Pavel Loginov Date: Sun, 26 Jul 2020 18:35:45 +0200 Subject: [PATCH] v4.4.0.0 Changelog: https://haproxy-wi.org/changelog.py#4_4 --- inc/metrics.js | 10 +++-- inc/overview.js | 93 ++++++++++++++++++++++++++++++++--------------- inc/runtimeapi.js | 15 ++++---- index.html | 2 + 4 files changed, 79 insertions(+), 41 deletions(-) diff --git a/inc/metrics.js b/inc/metrics.js index 57feb706..d34fc535 100644 --- a/inc/metrics.js +++ b/inc/metrics.js @@ -146,8 +146,12 @@ function loadMetrics() { $('#table_metrics').html('') }, type: "POST", - success: function (data) { - $( "#table_metrics" ).html( data ); + success: function (data) { + if (data.indexOf('error') != '-1') { + toastr.error(data); + } else { + $("#table_metrics").html(data); + } } }); } @@ -166,7 +170,6 @@ function getChartDataHapWiRam(ip) { success: function (result) { var data = []; data.push(result.chartData.rams); - renderChartHapWiRam(data); } }); @@ -227,7 +230,6 @@ function getChartDataHapWiCpu(ip) { success: function (result) { var data = []; data.push(result.chartData.cpus); - renderChartHapWiCpu(data); } }); diff --git a/inc/overview.js b/inc/overview.js index e43b9803..6a72d109 100644 --- a/inc/overview.js +++ b/inc/overview.js @@ -24,8 +24,12 @@ function showHapserversCallBack(serv, hostnamea, service) { }, type: "POST", success: function( data ) { - $("#"+hostnamea).empty(); - $("#"+hostnamea).html(data); + if (data.indexOf('error') != '-1') { + toastr.error(data); + } else { + $("#" + hostnamea).empty(); + $("#" + hostnamea).html(data); + } } } ); } @@ -43,8 +47,12 @@ function overviewHapserverBackends(serv, hostnamea, service) { }, type: "POST", success: function( data ) { - $("#top-"+hostnamea).empty(); - $("#top-"+hostnamea).html(data); + if (data.indexOf('error') != '-1') { + toastr.error(data); + } else { + $("#top-" + hostnamea).empty(); + $("#top-" + hostnamea).html(data); + } } } ); } @@ -69,8 +77,12 @@ function showOverviewCallBack(serv, hostnamea) { }, type: "POST", success: function( data ) { - $("#"+hostnamea).empty(); - $("#"+hostnamea).html(data); + if (data.indexOf('error') != '-1') { + toastr.error(data); + } else { + $("#" + hostnamea).empty(); + $("#" + hostnamea).html(data); + } } } ); } @@ -88,21 +100,25 @@ function showOverviewServer(name,ip,id, service) { }, type: "POST", success: function( data ) { - $("#ajax-server-"+id).empty(); - $("#ajax-server-"+id).css('display', 'block'); - $("#ajax-server-"+id).css('background-color', '#fbfbfb'); - $("#ajax-server-"+id).css('border', '1px solid #A4C7F5'); - $(".ajax-server").css('display', 'block'); - $(".div-server").css('clear', 'both'); - $(".div-pannel").css('clear', 'both'); - $(".div-pannel").css('display', 'block'); - $(".div-pannel").css('padding-top', '10px'); - $(".div-pannel").css('height', '70px'); - $("#div-pannel-"+id).insertBefore('#up-pannel') - $("#ajax-server-"+id).html(data); - $.getScript("/inc/fontawesome.min.js") - getChartDataHapWiRam() - getChartDataHapWiCpu() + if (data.indexOf('error') != '-1') { + toastr.error(data); + } else { + $("#ajax-server-" + id).empty(); + $("#ajax-server-" + id).css('display', 'block'); + $("#ajax-server-" + id).css('background-color', '#fbfbfb'); + $("#ajax-server-" + id).css('border', '1px solid #A4C7F5'); + $(".ajax-server").css('display', 'block'); + $(".div-server").css('clear', 'both'); + $(".div-pannel").css('clear', 'both'); + $(".div-pannel").css('display', 'block'); + $(".div-pannel").css('padding-top', '10px'); + $(".div-pannel").css('height', '70px'); + $("#div-pannel-" + id).insertBefore('#up-pannel') + $("#ajax-server-" + id).html(data); + $.getScript("/inc/fontawesome.min.js") + getChartDataHapWiRam() + getChartDataHapWiCpu() + } } } ); @@ -119,7 +135,7 @@ function ajaxActionServers(action, id) { success: function( data ) { data = data.replace(/\s+/g,' '); if( data == 'Bad config, check please ' ) { - alert(data); + toastr.error(data); } else { if (cur_url[0] == "hapservers.py") { location.reload() @@ -171,7 +187,7 @@ function ajaxActionWafServers(action, id) { success: function( data ) { data = data.replace(/\s+/g,' '); if( data == 'Bad config, check please ' ) { - alert(data); + toastr.error(data); } else { setTimeout(showOverviewWaf(ip, hostnamea), 2000) } @@ -290,11 +306,7 @@ function updateHapWIServer(id) { success: function( data ) { data = data.replace(/\s+/g,' '); if (data.indexOf('error') != '-1') { - $("#ajax-servers").append(data); - $('#errorMess').click(function() { - $('#error').remove(); - $('.alert-danger').remove(); - }); + toastr.error(data); } else { $('.alert-danger').remove(); $("#server-"+id).addClass( "update", 1000 ); @@ -317,4 +329,27 @@ function change_pos(pos, id) { console.log(w.data_error); } } ); -} \ No newline at end of file +} +function showBytes(serv) { + $.ajax( { + url: "options.py", + data: { + showBytes: serv, + token: $('#token').val() + }, + type: "POST", + beforeSend: function() { + $("#show_bin_bout").html(''); + $("#sessions").html(''); + }, + success: function( data ) { + data = data.replace(/\s+/g,' '); + if (data.indexOf('error') != '-1') { + toastr.error(data); + } else { + $("#bin_bout").html(data); + $.getScript("/inc/fontawesome.min.js") + } + } + } ); +} diff --git a/inc/runtimeapi.js b/inc/runtimeapi.js index 4b198655..c7b03b49 100644 --- a/inc/runtimeapi.js +++ b/inc/runtimeapi.js @@ -67,9 +67,9 @@ $( function() { success: function( data ) { data = data.replace(/\s+/g,' '); if (data.indexOf('error') != '-1') { - $("#ajaxmaxconn").html('
'+data+'
'); + toastr.error(data); } else { - $("#ajaxmaxconn").html('
'+data+'
'); + toastr.success(data); } } } ); @@ -182,9 +182,9 @@ $( function() { success: function( data ) { data = data.replace(/\s+/g,' '); if (data.indexOf('error') != '-1') { - $("#ajaxip").html('
'+data+'
'); + toastr.error(data); } else { - $("#ajaxip").html('
'+data+'
'); + toastr.success(data); } } } ); @@ -202,7 +202,7 @@ $( function() { success: function( data ) { data = data.replace(/\s+/g,''); if (data.indexOf('error') != '-1') { - alert(data) + toastr.error(data); } else { var value = data.split(',') $('#table_select').find('option').remove(); @@ -245,8 +245,7 @@ $( function() { }); }); function deleteTableEntry(id, table, ip) { - console.log(table) - console.log(ip) + $(id).parent().parent().css("background-color", "#f2dede"); $.ajax( { url: "options.py", data: { @@ -258,7 +257,7 @@ function deleteTableEntry(id, table, ip) { type: "POST", success: function( data ) { if (data.indexOf('error') != '-1') { - alert(data); + toastr.error(data); } else { $(id).parent().parent().remove() } diff --git a/index.html b/index.html index 5cdb535a..99b9e485 100644 --- a/index.html +++ b/index.html @@ -38,6 +38,8 @@ + +