From 4451b7406f7df8049e833bc43966dae6c6e6387e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= Date: Sun, 20 May 2018 23:30:17 +0200 Subject: [PATCH] [Web] Show minimal Rspamd action graph in Rspamd history tab --- data/web/js/debug.js | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/data/web/js/debug.js b/data/web/js/debug.js index 4ffcc044..81387429 100644 --- a/data/web/js/debug.js +++ b/data/web/js/debug.js @@ -346,6 +346,40 @@ jQuery(function($){ } } }); + $.ajax({ + url: '/api/v1/get/rspamd/actions', + success: function(data){ + var total = 0; + $(data).map(function(){total += this[1];}) + rspamd_labels = $.makeArray($(data).map(function(){return "
" + this[0] + " (" + this[1] + ") " + Math.round(this[1]/total * 100) + "%
";})); + window.rspamd_donut = $.jqplot('rspamd_donut', [data], + { + seriesDefaults: { + renderer: jQuery.jqplot.DonutRenderer, + rendererOptions: { + showDataLabels: true, + dataLabels: rspamd_labels, + dataLabelThreshold: 1, + sliceMargin: 5, + totalLabel: true + }, + shadow: false, + seriesColors: ['#FF4136', '#75CAEB', '#FF851B', '#FF851B', '#28B62C'] + }, + legend: { + show:false, + }, + grid: { + drawGridLines: true, + gridLineColor: '#efefef', + background: '#ffffff', + borderWidth: 0, + shadow: false, + } + } + ); + } + }); } function process_table_data(data, table) { @@ -499,5 +533,11 @@ jQuery(function($){ draw_api_logs(); draw_netfilter_logs(); draw_rspamd_history(); - + $(window).resize(function () { + var timer; + clearTimeout(timer); + timer = setTimeout(function () { + rspamd_donut.replot({}); + }, 500); + }); });