annotate views/bottledash_view.tpl @ 16:f89ad628f831

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