From 4879197f2459334fa6e39136776d8ab2a51f98c2 Mon Sep 17 00:00:00 2001 From: Anna Stakhova Date: Tue, 10 Jan 2017 16:35:11 +0000 Subject: [PATCH] [WebUI] clusters for the chart --- interface/js/rspamd.js | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/interface/js/rspamd.js b/interface/js/rspamd.js index be757ce4d6..883722a447 100644 --- a/interface/js/rspamd.js +++ b/interface/js/rspamd.js @@ -492,6 +492,7 @@ $(document).on('click', 'input:radio[name="clusterName"]', function (e) { checked_server = this.value; statWidgets(); + getChart(); }); // @opem modal with target form enabled @@ -516,21 +517,32 @@ $('#modalBody form').hide(); }); +// function getChart() { +// $.ajax({ +// dataType: 'json', +// type: 'GET', +// url: 'pie', +// jsonp: false, +// beforeSend: function (xhr) { +// xhr.setRequestHeader('Password', getPassword()); +// }, +// success: function (data) { +// console.log(data); +// pie = drawPie(pie, "chart", data); +// } +// }); +// } + function getChart() { - $.ajax({ - dataType: 'json', - type: 'GET', - url: 'pie', - jsonp: false, - beforeSend: function (xhr) { - xhr.setRequestHeader('Password', getPassword()); - }, - success: function (data) { - pie = drawPie(pie, "chart", data); - } - }); + var data = JSON.parse(sessionStorage.getItem('Credentials'))[checked_server].data; + var new_data = [{"color":"#66cc00","label":"Clean","data":data.clean,"value":data.clean}, + {"color":"#cc9966","label":"Temporary rejected","data":data.learned,"value":data.learned}, + {"color":"#FFD700","label":"Probable spam","data":data.probable,"value":data.probable}, + {"color":"#436EEE","label":"Greylisted","data":data.greylist,"value":data.greylist}, + {"color":"#FF0000","label":"Rejected","data":data.rejected,"value":data.rejected}]; + pie = drawPie(pie, "chart", new_data); } - + function drawPie(obj, id, data, conf) { if (obj) { obj.updateProp("data.content", -- 2.47.3