[Web] Fix initial drawing of Rspamd plot
parent
777e469958
commit
7c1795c497
|
@ -346,13 +346,15 @@ jQuery(function($){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
function plot_rspamd() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/api/v1/get/rspamd/actions',
|
url: '/api/v1/get/rspamd/actions',
|
||||||
success: function(data){
|
success: function(data){
|
||||||
var total = 0;
|
var total = 0;
|
||||||
$(data).map(function(){total += this[1];})
|
$(data).map(function(){total += this[1];})
|
||||||
rspamd_labels = $.makeArray($(data).map(function(){return "<h5>" + this[0] + " (" + this[1] + ") " + Math.round(this[1]/total * 100) + "%</h5>";}));
|
rspamd_labels = $.makeArray($(data).map(function(){return "<h5>" + this[0] + " (" + this[1] + ") " + Math.round(this[1]/total * 100) + "%</h5>";}));
|
||||||
window.rspamd_donut = $.jqplot('rspamd_donut', [data],
|
rspamd_donut = $.jqplot('rspamd_donut', [data],
|
||||||
{
|
{
|
||||||
seriesDefaults: {
|
seriesDefaults: {
|
||||||
renderer: jQuery.jqplot.DonutRenderer,
|
renderer: jQuery.jqplot.DonutRenderer,
|
||||||
|
@ -378,11 +380,9 @@ jQuery(function($){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
window.rspamd_donut.replot({});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function process_table_data(data, table) {
|
function process_table_data(data, table) {
|
||||||
if (table == 'rspamd_history') {
|
if (table == 'rspamd_history') {
|
||||||
$.each(data, function (i, item) {
|
$.each(data, function (i, item) {
|
||||||
|
@ -538,7 +538,15 @@ jQuery(function($){
|
||||||
var timer;
|
var timer;
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
timer = setTimeout(function () {
|
timer = setTimeout(function () {
|
||||||
rspamd_donut.replot({});
|
if (typeof rspamd_donut !== 'undefined') {
|
||||||
|
rspamd_donut.replot({});
|
||||||
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
});
|
});
|
||||||
|
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||||
|
var target = $(e.target).attr("href");
|
||||||
|
if ((target == '#tab-rspamd-history')) {
|
||||||
|
plot_rspamd();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue