Mercurial > bottledash
annotate views/bottledash_view.tpl @ 20:1a13a4ecf931
can not recive post-requests wich should deliver if a server is up or down. Updated after a refresh of the webpage, wich will automatically done after 5 seconds
author | sean |
---|---|
date | Wed, 12 Aug 2015 13:45:58 +0200 |
parents | be6a1aaec717 |
children | f730dd0bcf85 |
rev | line source |
---|---|
16 | 1 <!-- This tempalte is a part of bottledash |
2 author: sean engelhardt >sean.engelhardt@intevation.de | |
3 License: GNU GPL >= v2. See LICENSE for details. --> | |
4 | |
5 <% | |
6 import math, os, sys, subprocess, html.parser | |
7 from datetime import date | |
8 | |
9 PATH = os.path.abspath(os.path.dirname(sys.argv[0])) | |
10 sys.path.append(PATH + "/modules") | |
11 import web_view | |
12 | |
13 ################# | |
14 # settings # | |
15 ################# | |
16 | |
17 show_top_bar = settings["show_top_bar"] | |
18 | |
19 ################# | |
20 # date and time # | |
21 ################# | |
22 | |
23 today = date.today() | |
24 weekday = ("Montag", "Dienstag", "Mittwoch", "Donnerstag", | |
25 "Freitag", "Samstag", "Sonntag")[today.weekday()] | |
26 month_name = ("Januar", "Februar", "März", "Aprill", "Mai", | |
27 "Juni", "Juli", "August", "September", "Oktober", | |
28 "November", "Dezember")[today.month-1] | |
29 | |
19
be6a1aaec717
added the post listener, write logs if someone sends a post
sean
parents:
16
diff
changeset
|
30 number_of_rows = 2 |
16 | 31 |
32 ################# | |
33 # viewport size # | |
34 ################# | |
35 vp_size = "17px" | |
36 #if len(tiles) <= 2: | |
37 # vp_size = "6vw" | |
38 #elif len(tiles) >2 and len(tiles) <=4 : | |
39 # vp_size = "5vw" | |
40 #elif len(tiles) >4 and len(tiles) <=6 : | |
41 # vp_size = "4vw" | |
42 #elif len(tiles) >6 and len(tiles) <=8 : | |
43 # vp_size = "3vw" | |
44 #end | |
45 %> | |
20
1a13a4ecf931
can not recive post-requests wich should deliver if a server is up or down. Updated after a refresh of the webpage, wich will automatically done after 5 seconds
sean
parents:
19
diff
changeset
|
46 <meta http-equiv="refresh" content="5" /> |
16 | 47 <script type="text/javascript"> |
48 | |
49 var global_width; | |
50 var global_height; | |
51 var tile_width; | |
52 var tile_height; | |
53 | |
54 var tiles = document.getElementsByClassName("tile"); | |
55 var border_width = 1; | |
56 var space_between_tiles = 8; | |
57 | |
58 var space_lr_borders; | |
59 var space_lr_margin; | |
60 | |
61 function calc_tile_with(){ | |
62 var tiles_per_row = Math.floor(tiles.length / {{number_of_rows}}); | |
63 var distance = (space_between_tiles*2) + (border_width*2); | |
64 var tile_width = ((global_width / tiles_per_row ) - distance); | |
65 return tile_width; | |
66 } | |
67 | |
68 function calc_tile_height(){ | |
69 var distance = (space_between_tiles*2) + (border_width*2); | |
70 var tile_height = ((global_height / {{number_of_rows}} ) - distance); | |
71 return tile_height; | |
72 } | |
73 | |
74 function resize_content(){ | |
75 global_width = document.getElementById("content").clientWidth; | |
76 global_height = document.getElementById("content").clientHeight; | |
77 | |
78 | |
79 tile_width = calc_tile_with(); | |
80 tile_height = calc_tile_height(); | |
81 | |
82 for(var tile = 0; tile < tiles.length; tile++){ | |
83 tiles[tile].style.width= tile_width + 'px'; | |
84 tiles[tile].style.height= tile_height + 'px'; | |
85 } | |
86 } | |
87 | |
88 window.onresize = function(){ | |
89 resize_content(); | |
90 } | |
91 | |
92 document.addEventListener("DOMContentLoaded", function(event) { | |
93 resize_content(); | |
94 }); | |
95 | |
96 </script> | |
97 | |
98 <style> | |
99 *{ | |
100 margin: 0 auto; | |
101 padding: 0 auto; | |
102 font-family: "Lucida Console", Monaco, monospace; | |
103 } | |
104 | |
105 body { | |
106 overflow: hidden; | |
107 } | |
108 | |
109 #wrapper{ | |
110 background-color: #F2F2F2; | |
111 color: black; | |
112 min-width: 100%; | |
113 min-height: 100%; | |
114 } | |
115 | |
116 #topbar{ | |
117 min-width: auto; | |
118 padding-left: 8px; | |
119 padding-top: 8px; | |
120 padding-bottom: 8px; | |
121 /*height: 5%;*/ | |
122 font-family: Arial, Helvetica, sans-serif; | |
123 } | |
124 | |
125 #content{ | |
126 min-width: 100%; | |
127 % if show_top_bar == "True": | |
128 height: 95%; | |
129 % else : | |
130 height: 100%; | |
131 %end | |
132 } | |
133 | |
134 .tile{ | |
135 float: left; | |
136 margin: 8px; | |
137 background-color: #FFFFFF; | |
138 border: 1px solid #999999; | |
139 border: none; | |
140 text-align:center; | |
141 vertical-align: middle; | |
142 } | |
143 | |
144 .clear{ | |
145 height: 0px; | |
146 clear: both; | |
147 } | |
148 | |
149 /*tiles types*/ | |
150 | |
151 .statusmon{ | |
152 color: white; | |
153 font-size: {{vp_size}}; | |
154 } | |
155 | |
156 .chart{ | |
157 font-size: {{vp_size}}; | |
158 } | |
159 | |
160 .active{ | |
161 border: 1px solid #00cc00; | |
162 background-color: #009900; | |
163 } | |
164 | |
165 .dead{ | |
166 border: 1px solid #cc0000; | |
167 background-color: #990000; | |
168 } | |
169 | |
170 </style> | |
171 | |
172 <div id = "wrapper"> | |
173 % if show_top_bar == "True" : | |
174 <div id = "topbar"> | |
175 <b>{{weekday}}</b> {{today.day}}. {{month_name}} | |
176 </div> | |
177 % end | |
178 | |
179 <div id = "content"> | |
180 <% | |
181 for tile in tiles : | |
182 type = "" | |
183 tile_content = "" | |
184 status = "" | |
20
1a13a4ecf931
can not recive post-requests wich should deliver if a server is up or down. Updated after a refresh of the webpage, wich will automatically done after 5 seconds
sean
parents:
19
diff
changeset
|
185 |
16 | 186 if tile["type"] == "mon" : |
187 type = "statusmon" | |
188 tile_content = tile["source"] | |
189 if tile["status"] == "up" : | |
190 status = "active" | |
20
1a13a4ecf931
can not recive post-requests wich should deliver if a server is up or down. Updated after a refresh of the webpage, wich will automatically done after 5 seconds
sean
parents:
19
diff
changeset
|
191 else : |
16 | 192 status = "dead" |
193 end | |
20
1a13a4ecf931
can not recive post-requests wich should deliver if a server is up or down. Updated after a refresh of the webpage, wich will automatically done after 5 seconds
sean
parents:
19
diff
changeset
|
194 |
16 | 195 elif tile["type"] == "d3js" : |
196 type = "chart" | |
197 status = tile["div_name"] | |
198 tile_content = web_view.make_chart(tile["script"], tile["div_name"]) | |
199 end | |
200 %> | |
201 | |
202 <div class = "tile {{type}} {{status}}"> | |
203 {{!tile_content}} | |
204 </div> | |
205 | |
206 % end | |
207 | |
208 </div> | |
209 </div> |