changeset 13:63b9f41c3008

made the charts a bit more modular - can now define the div_name and the script name in the .conf data
author sean
date Wed, 05 Aug 2015 12:37:33 +0200
parents 50f4c64834cb
children 3a9cb396905f
files dash.conf modules/roundup_cc/__init__.py modules/roundup_cc/graph.html views/hello_template.tpl
diffstat 4 files changed, 20 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/dash.conf	Tue Aug 04 16:00:07 2015 +0200
+++ b/dash.conf	Wed Aug 05 12:37:33 2015 +0200
@@ -44,6 +44,12 @@
 #   status: (up / down) [required]
 #     ONLY FOR DEBUGGING PURPOSE - WILL BE REMOVED LATER
 #     simulates up and down events for mon-type-tiles
+#
+#   div_name: (identifier) [required for d3js-types]
+#
+#   script: (name of a script without extension) [required for d3js-types0]
+#
+
 
 [tile1]
 type=mon
@@ -62,4 +68,5 @@
 
 [tile4]
 type=d3js
-status=display_issues_techintern
+div_name=techintern
+script=display_issues_techintern
--- a/modules/roundup_cc/__init__.py	Tue Aug 04 16:00:07 2015 +0200
+++ b/modules/roundup_cc/__init__.py	Wed Aug 05 12:37:33 2015 +0200
@@ -23,10 +23,10 @@
 
 # PATH = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
 
-def make_chart(chart_data_file):
+def make_chart(chart_data_file, target_div_name):
+    mod = importlib.import_module("roundup_cc." + chart_data_file)
 
-    mod = importlib.import_module("roundup_cc." + chart_data_file)
-    return mod.get_chart()
+    return mod.get_chart(target_div_name)
 
     # test = exec(open(PATH + "/" + chart_data_file+'.py').read())
 
--- a/modules/roundup_cc/graph.html	Tue Aug 04 16:00:07 2015 +0200
+++ b/modules/roundup_cc/graph.html	Wed Aug 05 12:37:33 2015 +0200
@@ -95,6 +95,8 @@
 	// 	makeChart();
 	// };
 
+	var d3jsInjectionTarget="X";
+
 	var critical=[];
 	var urgent=[];
 	var bug=[];
@@ -264,7 +266,7 @@
 
 
 	//draw the chart
-	function makeChart(){
+	function makeChart(div_name){
 
 		//declaration
 		var sizeOfSystemBorders = 20;
@@ -320,7 +322,7 @@
 			.orient("left");
 
 
-		var svg = d3.select(".chart")
+		var svg = d3.select("." + d3jsInjectionTarget)
 			.append("svg")
 			.attr("class", "svg")
 			// .attr("width", width)
--- a/views/hello_template.tpl	Tue Aug 04 16:00:07 2015 +0200
+++ b/views/hello_template.tpl	Wed Aug 05 12:37:33 2015 +0200
@@ -182,11 +182,11 @@
         <%
             for tile in tiles :
             type = ""
-            text = ""
+            tile_content = ""
             status = ""
             if tile["type"] == "mon" :
                 type = "statusmon"
-                text = tile["source"]
+                tile_content = tile["source"]
                 if tile["status"] == "up" :
                     status = "active"
                 elif tile["status"] == "down" :
@@ -194,13 +194,13 @@
                 end
             elif tile["type"] == "d3js" :
                 type = "chart"
-                status = ""
-                text = roundup_cc.make_chart(tile["status"])
+                status = "techintern"
+                tile_content = roundup_cc.make_chart(tile["script"], tile["div_name"])
             end
         %>
 
         <div class = "tile {{type}} {{status}}">
-            {{!text}}
+            {{!tile_content}}
         </div>
 
         % end
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)