Module: check_mk
Branch: master
Commit: a2935764e8815fb9de34beb6a02fe2c84a8701d0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a2935764e8815f…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Sep 7 11:05:51 2016 +0200
Replaced wrong repr() data handover of data from python to JS with json
---
web/htdocs/js/checkmk.js | 2 --
web/htdocs/js/prediction.js | 7 -------
web/htdocs/prediction.py | 23 +++++++++++++++--------
3 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index 83470d4..4690d0b 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -2823,8 +2823,6 @@ function show_hover_menu(event, code)
document.body.appendChild(g_hover_menu);
}
g_hover_menu.innerHTML = code;
- // TOOD: Hier weitermachen. Der <javascript...create_graph()> kommt korrekt
an.
- // Aber wird irgendwie nicht ausgeführt, denn das Menü bleibt unsichtbar.
executeJSbyObject(g_hover_menu);
// Change cursor to "hand" when displaying hover menu
diff --git a/web/htdocs/js/prediction.js b/web/htdocs/js/prediction.js
index f0284fc..9b6a7f0 100644
--- a/web/htdocs/js/prediction.js
+++ b/web/htdocs/js/prediction.js
@@ -37,8 +37,6 @@ var right_border = 50;
var top_border = 40;
var bottom_border = 50;
-var None = null; // make us compatible with Python repr()
-
function create_graph(cid, ft, ut, vmi, vma)
{
// Keep important data as global variables, needed by
@@ -54,11 +52,6 @@ function create_graph(cid, ft, ut, vmi, vma)
height = canvas.height;
netto_width = width - left_border - right_border;
netto_height = height - top_border - bottom_border;
-
- // Point background and coordinates
- // var c = canvas.getContext('2d');
- // c.fillStyle="#eeeeee";
- // c.fillRect(0, 0, width, height);
}
function arrow_up(c, cx, cy, length, size, color)
diff --git a/web/htdocs/prediction.py b/web/htdocs/prediction.py
index d0e1d11..1b37350 100644
--- a/web/htdocs/prediction.py
+++ b/web/htdocs/prediction.py
@@ -32,6 +32,12 @@ import config
import sites
from lib import *
+try:
+ import simplejson as json
+except ImportError:
+ import json
+
+
graph_size = 2000, 700
@@ -133,7 +139,6 @@ def page_graph():
render_curve(swapped["upper_crit"], "#f0b0b0", square=True)
render_curve(swapped["average"], "#000000")
render_curve(swapped["average"], "#000000")
- # render_curve(stack(swapped["average"], swapped["stdev"], -1),
"#008040")
# Try to get current RRD data and render it also
from_time, until_time = timegroup["range"]
@@ -326,21 +331,23 @@ def create_graph(name, size, range, v_range, legend):
name, range[0], range[1], v_range[0], v_range[1]))
def render_coordinates(v_scala, t_scala):
- html.javascript('render_coordinates(%r, %r);' % (v_scala, t_scala))
+ html.javascript('render_coordinates(%s, %s);' % (json.dumps(v_scala),
json.dumps(t_scala)))
def render_curve(points, color, width=1, square=False):
- html.javascript('render_curve(%r, %r, %d, %d);' % (
- points, color, width, square and 1 or 0))
+ html.javascript('render_curve(%s, %s, %d, %d);' % (
+ json.dumps(points), json.dumps(color), width, square and 1 or 0))
def render_point(t, v, color):
- html.javascript('render_point(%r, %r, %r);' % (t, v, color))
+ html.javascript('render_point(%s, %s, %s);' % (json.dumps(t), json.dumps(v),
json.dumps(color)))
def render_area(points, color, alpha=1.0):
- html.javascript('render_area(%r, %r, %f);' % (points, color, alpha))
+ html.javascript('render_area(%s, %s, %f);' % (json.dumps(points),
json.dumps(color), alpha))
def render_area_reverse(points, color, alpha=1.0):
- html.javascript('render_area_reverse(%r, %r, %f);' % (points, color, alpha))
+ html.javascript('render_area_reverse(%s, %s, %f);' %
+ (json.dumps(points), json.dumps(color), alpha))
def render_dual_area(lower_points, upper_points, color, alpha=1.0):
- html.javascript('render_dual_area(%r, %r, %r, %f);' % (lower_points,
upper_points, color, alpha))
+ html.javascript('render_dual_area(%s, %s, %s, %f);' %
+ (json.dumps(lower_points), json.dumps(upper_points), json.dumps(color), alpha))