diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-01-31 15:48:57 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-01-31 15:48:57 +0000 |
commit | 977c7309f8438796c3baaf09291cf3ece2916899 (patch) | |
tree | 9d5a16b67551d7d2daccbe61f0e2c9a80d88a11d /interface/js/app/stats.js | |
parent | c7bfdbfcd187cf08fa1023770a67420a64203391 (diff) | |
download | rspamd-977c7309f8438796c3baaf09291cf3ece2916899.tar.gz rspamd-977c7309f8438796c3baaf09291cf3ece2916899.zip |
[WebUI] Add graph tab
Diffstat (limited to 'interface/js/app/stats.js')
-rw-r--r-- | interface/js/app/stats.js | 98 |
1 files changed, 4 insertions, 94 deletions
diff --git a/interface/js/app/stats.js b/interface/js/app/stats.js index 51e13b385..e2ce33d0f 100644 --- a/interface/js/app/stats.js +++ b/interface/js/app/stats.js @@ -139,7 +139,7 @@ function($, d3pie, Humanize) { $(widgets).show(); } - function getChart(pie, checked_server) { + function getChart(rspamd, pie, checked_server) { var creds = JSON.parse(sessionStorage.getItem('Credentials')); if (creds && creds[checked_server]) { var data = creds[checked_server].data; @@ -169,100 +169,10 @@ function($, d3pie, Humanize) { "data" : data.reject, "value" : data.reject } ]; - return drawPie(pie, "chart", new_data); - } - } - function drawPie(obj, id, data, conf) { - if (obj) { - obj.updateProp("data.content", - data.filter(function (elt) { - return elt.value > 0; - }) - ); - } else { - obj = new d3pie(id, - $.extend({}, { - "header": { - "title": { - "text": "Rspamd filter stats", - "fontSize": 24, - "font": "open sans" - }, - "subtitle": { - "color": "#999999", - "fontSize": 12, - "font": "open sans" - }, - "titleSubtitlePadding": 9 - }, - "footer": { - "color": "#999999", - "fontSize": 10, - "font": "open sans", - "location": "bottom-left" - }, - "size": { - "canvasWidth": 600, - "canvasHeight": 400, - "pieInnerRadius": "20%", - "pieOuterRadius": "85%" - }, - "data": { - //"sortOrder": "value-desc", - "content": data.filter(function (elt) { - return elt.value > 0; - }) - }, - "labels": { - "outer": { - "hideWhenLessThanPercentage": 1, - "pieDistance": 30 - }, - "inner": { - "hideWhenLessThanPercentage": 4 - }, - "mainLabel": { - "fontSize": 14 - }, - "percentage": { - "color": "#eeeeee", - "fontSize": 14, - "decimalPlaces": 0 - }, - "lines": { - "enabled": true - }, - "truncation": { - "enabled": true - } - }, - "tooltips": { - "enabled": true, - "type": "placeholder", - "string": "{label}: {value}, {percentage}%" - }, - "effects": { - "pullOutSegmentOnClick": { - "effect": "back", - "speed": 400, - "size": 8 - }, - "load": { - "effect": "none" - } - }, - "misc": { - "gradient": { - "enabled": true, - "percentage": 100 - } - } - }, conf)); + return rspamd.drawPie(pie, "chart", new_data); } - return obj; } - // Public API var interface = { statWidgets: function(rspamd, graphs, checked_server) { @@ -311,7 +221,7 @@ function($, d3pie, Humanize) { }); sessionStorage.setItem("Credentials", JSON.stringify(to_Credentials)); displayStatWidgets(checked_server); - graphs.chart = getChart(graphs.chart, checked_server); + graphs.chart = getChart(rspamd, graphs.chart, checked_server); }, function (serv, jqXHR, textStatus, errorThrown) { var alert_status = serv.name + '_alerted'; @@ -327,4 +237,4 @@ function($, d3pie, Humanize) { return interface; } -);
\ No newline at end of file +); |