aboutsummaryrefslogtreecommitdiffstats
path: root/src/webui.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2013-01-06 22:08:28 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2013-01-06 22:08:28 +0400
commit3b45a8488797628fae81d8c953974924a817bb49 (patch)
tree62c5eb99610cf3f084e5deef5b2e6d0ecdde7230 /src/webui.c
parent3cc84c59169c991f0d550b63a23cd6ffc6626b56 (diff)
downloadrspamd-3b45a8488797628fae81d8c953974924a817bb49.tar.gz
rspamd-3b45a8488797628fae81d8c953974924a817bb49.zip
Add colors to graphs.
Diffstat (limited to 'src/webui.c')
-rw-r--r--src/webui.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/webui.c b/src/webui.c
index 98e83b5ab..85661948e 100644
--- a/src/webui.c
+++ b/src/webui.c
@@ -67,6 +67,13 @@
#define PATH_GET_MAP "/getmap"
#define PATH_GRAPH "/graph"
+/* Graph colors */
+#define COLOR_CLEAN "#58A458"
+#define COLOR_PROBABLE_SPAM "#D67E7E"
+#define COLOR_GREYLIST "#A0A0A0"
+#define COLOR_REJECT "#CB4B4B"
+#define COLOR_TOTAL "#9440ED"
+
gpointer init_webui_worker (void);
void start_webui_worker (struct rspamd_worker *worker);
@@ -565,12 +572,12 @@ http_handle_graph (struct evhttp_request *req, gpointer arg)
}
/* Trailer */
- evbuffer_add (evb, "[", 1);
+ evbuffer_add_printf (evb, "{\"series\": [");
/* XXX: simple and stupid set */
seed = g_random_int ();
for (i = 0; i < 100; i ++, seed ++) {
- vals[0][i] = (sin (seed * 0.1 * M_PI_2) + 1) * 40.;
+ vals[0][i] = fabs ((sin (seed * 0.1 * M_PI_2) + 1) * 40. + ((gint)(g_random_int () % 2) - 1));
vals[1][i] = vals[0][i] * 0.5;
vals[2][i] = vals[0][i] * 0.1;
vals[3][i] = vals[0][i] * 0.3;
@@ -617,9 +624,10 @@ http_handle_graph (struct evhttp_request *req, gpointer arg)
for (i = 0; i < 100; i ++, t += 60) {
evbuffer_add_printf (evb, "[%llu,%.2f%s", (long long unsigned)t * 1000, vals[4][i], i == 99 ? "]" : "],");
}
- evbuffer_add (evb, "]}", 2);
+ evbuffer_add (evb, "]},", 2);
- evbuffer_add (evb, "]" CRLF, 3);
+ evbuffer_add_printf (evb, "],\"colors\":[\"" COLOR_CLEAN "\", \"" COLOR_PROBABLE_SPAM "\", \""
+ COLOR_GREYLIST "\", \"" COLOR_REJECT "\", \"" COLOR_TOTAL "\"]}" CRLF);
evhttp_add_header (req->output_headers, "Connection", "close");
http_calculate_content_length (evb, req);