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