www-thermferm/archives.php

changeset 375
f707d22c72f8
parent 374
20999ef6d487
child 376
a5d215531f55
equal deleted inserted replaced
374:20999ef6d487 375:f707d22c72f8
81 $outstr .= ' <script type="text/javascript" src="jqwidgets/jqxwindow.js"></script>'.PHP_EOL; 81 $outstr .= ' <script type="text/javascript" src="jqwidgets/jqxwindow.js"></script>'.PHP_EOL;
82 $outstr .= ' <script type="text/javascript" src="jqwidgets/jqxbuttons.js"></script>'.PHP_EOL; 82 $outstr .= ' <script type="text/javascript" src="jqwidgets/jqxbuttons.js"></script>'.PHP_EOL;
83 $outstr .= ' <script type="text/javascript" src="jqwidgets/jqxchart.core.js"></script>'.PHP_EOL; 83 $outstr .= ' <script type="text/javascript" src="jqwidgets/jqxchart.core.js"></script>'.PHP_EOL;
84 $outstr .= ' <script type="text/javascript" src="jqwidgets/jqxdraw.js"></script>'.PHP_EOL; 84 $outstr .= ' <script type="text/javascript" src="jqwidgets/jqxdraw.js"></script>'.PHP_EOL;
85 $outstr .= ' <script type="text/javascript" src="jqwidgets/jqxdata.js"></script>'.PHP_EOL; 85 $outstr .= ' <script type="text/javascript" src="jqwidgets/jqxdata.js"></script>'.PHP_EOL;
86 $outstr .= ' <script type="text/javascript" src="jqwidgets/jqxdata.export.js"></script>'.PHP_EOL;
86 $outstr .= ' </head>'.PHP_EOL; 87 $outstr .= ' </head>'.PHP_EOL;
87 88
88 $outstr .= ' <body class="default">'.PHP_EOL; 89 $outstr .= ' <body class="default">'.PHP_EOL;
89 $outstr .= ' <div id="jqxWidget">'.PHP_EOL; 90 $outstr .= ' <div id="jqxWidget">'.PHP_EOL;
90 $outstr .= ' <div id="header">'.PHP_EOL; 91 $outstr .= ' <div id="header">'.PHP_EOL;
117 $outstr .= ' { name: "Cooler", type: "int" },'.PHP_EOL; 118 $outstr .= ' { name: "Cooler", type: "int" },'.PHP_EOL;
118 $outstr .= ' { name: "HeatUse", type: "int" },'.PHP_EOL; 119 $outstr .= ' { name: "HeatUse", type: "int" },'.PHP_EOL;
119 $outstr .= ' { name: "CoolUse", type: "int" },'.PHP_EOL; 120 $outstr .= ' { name: "CoolUse", type: "int" },'.PHP_EOL;
120 $outstr .= ' { name: "Room", type: "float" }'.PHP_EOL; 121 $outstr .= ' { name: "Room", type: "float" }'.PHP_EOL;
121 $outstr .= ' ],'.PHP_EOL; 122 $outstr .= ' ],'.PHP_EOL;
122 $outstr .= ' url: \'getalog.php?name='.urlencode($name).'\''.PHP_EOL; 123 $outstr .= ' url: \'getalog.php?name='.urlencode($name).'.log\''.PHP_EOL;
123 $outstr .= ' };'.PHP_EOL; 124 $outstr .= ' };'.PHP_EOL;
124 125
125 $outstr .= ' var dataAdapter = new $.jqx.dataAdapter(sourceA,'.PHP_EOL; 126 $outstr .= ' var dataAdapter = new $.jqx.dataAdapter(sourceA,'.PHP_EOL;
126 $outstr .= ' {'.PHP_EOL; 127 $outstr .= ' {'.PHP_EOL;
127 $outstr .= ' autoBind: true,'.PHP_EOL; 128 $outstr .= ' autoBind: true,'.PHP_EOL;
173 $outstr .= ' { dataField: "Target", lineWidth: 1, displayText: "Target", opacity: 0.7 },'.PHP_EOL; 174 $outstr .= ' { dataField: "Target", lineWidth: 1, displayText: "Target", opacity: 0.7 },'.PHP_EOL;
174 $outstr .= ' { dataField: "Room", lineWidth: 1, displayText: "Room", opacity: 0.5 }'.PHP_EOL; 175 $outstr .= ' { dataField: "Room", lineWidth: 1, displayText: "Room", opacity: 0.5 }'.PHP_EOL;
175 $outstr .= ' ]'.PHP_EOL; 176 $outstr .= ' ]'.PHP_EOL;
176 $outstr .= ' }]'.PHP_EOL; 177 $outstr .= ' }]'.PHP_EOL;
177 $outstr .= ' };'.PHP_EOL; 178 $outstr .= ' };'.PHP_EOL;
178 /* Direct draw for the first time */
179 $outstr .= ' $("#fermentor_chart").jqxChart(settings);'.PHP_EOL; 179 $outstr .= ' $("#fermentor_chart").jqxChart(settings);'.PHP_EOL;
180 180
181 $outstr .= ' $("#print").click(function () {'.PHP_EOL; 181 $outstr .= ' $("#print").click(function () {'.PHP_EOL;
182 $outstr .= ' var content = $("#fermentor_chart")[0].outerHTML;'.PHP_EOL; 182 $outstr .= ' var content = $("#fermentor_chart")[0].outerHTML;'.PHP_EOL;
183 $outstr .= ' var newWindow = window.open("", "", "width=750, height=400"),'.PHP_EOL; 183 $outstr .= ' var newWindow = window.open("", "", "width=750, height=400"),'.PHP_EOL;
198 $outstr .= ' $("#print").jqxButton({ width: 100, height: 25, theme: "ui-redmond" });'.PHP_EOL; 198 $outstr .= ' $("#print").jqxButton({ width: 100, height: 25, theme: "ui-redmond" });'.PHP_EOL;
199 199
200 $outstr .= ' $("#pngButton").click(function () {'.PHP_EOL; 200 $outstr .= ' $("#pngButton").click(function () {'.PHP_EOL;
201 $outstr .= ' $("#fermentor_chart").jqxChart("saveAsPNG", "Chart_'.$name.'.png", getExportServer());'.PHP_EOL; 201 $outstr .= ' $("#fermentor_chart").jqxChart("saveAsPNG", "Chart_'.$name.'.png", getExportServer());'.PHP_EOL;
202 $outstr .= ' });'.PHP_EOL; 202 $outstr .= ' });'.PHP_EOL;
203 $outstr .= ' $("#pdfButton").click(function () {'.PHP_EOL;
204 $outstr .= ' $("#fermentor_chart").jqxChart("saveAsPDF", "Chart_'.$name.'.pdf", getExportServer());'.PHP_EOL;
205 $outstr .= ' });'.PHP_EOL;
203 $outstr .= ' $("#pngButton").jqxButton({ width: 100, height: 25, theme: "ui-redmond" });'.PHP_EOL; 206 $outstr .= ' $("#pngButton").jqxButton({ width: 100, height: 25, theme: "ui-redmond" });'.PHP_EOL;
207 $outstr .= ' $("#pdfButton").jqxButton({ width: 100, height: 25, theme: "ui-redmond" });'.PHP_EOL;
204 208
205 $outstr .= ' });'.PHP_EOL; 209 $outstr .= ' });'.PHP_EOL;
206 $outstr .= ' </script>'.PHP_EOL; 210 $outstr .= ' </script>'.PHP_EOL;
207 $outstr .= ' <div id="fermentor">'.PHP_EOL; 211 $outstr .= ' <div id="fermentor">'.PHP_EOL;
208 $outstr .= ' <div id="fermentor_chart" style="width:720px; height:377px; float:left"></div>'.PHP_EOL; 212 $outstr .= ' <div id="fermentor_chart" style="width:720px; height:377px; float:left"></div>'.PHP_EOL;
209 $outstr .= ' <div style="margin-top: 2px; margin-left: 10px;">'.PHP_EOL; 213 $outstr .= ' <div style="margin-top: 2px; margin-left: 10px;">'.PHP_EOL;
210 $outstr .= ' <input style="float: left; margin-left: 15px;" id="print" type="button" value="Print Graph" />'.PHP_EOL; 214 $outstr .= ' <input style="float: left; margin-left: 15px;" id="print" type="button" value="Print Graph" />'.PHP_EOL;
211 $outstr .= ' <input style="float: left; margin-left: 15px;" id="pngButton" type="button" value="Save Graph" />'.PHP_EOL; 215 $outstr .= ' <input style="float: left; margin-left: 15px;" id="pngButton" type="button" value="Save as PNG" />'.PHP_EOL;
216 $outstr .= ' <input style="float: left; margin-left: 15px;" id="pdfButton" type="button" value="Save as PDF" />'.PHP_EOL;
212 $outstr .= ' </div>'.PHP_EOL; 217 $outstr .= ' </div>'.PHP_EOL;
213 $outstr .= ' </div> <!-- fermentor -->'.PHP_EOL; 218 $outstr .= ' </div> <!-- fermentor -->'.PHP_EOL;
214 219
215 $outstr .= ' <script type="text/javascript">'.PHP_EOL; 220 $outstr .= ' <script type="text/javascript">'.PHP_EOL;
216 $outstr .= ' $(document).ready(function () {'.PHP_EOL; 221 $outstr .= ' $(document).ready(function () {'.PHP_EOL;
227 * Download popup. The file contents is dynamic generated from 232 * Download popup. The file contents is dynamic generated from
228 * the thermferm server. 233 * the thermferm server.
229 */ 234 */
230 function archive_dl() { 235 function archive_dl() {
231 236
232 $name = urldecode($_GET['name']); 237 $name = urldecode($_GET['name']) . ".log";
233 238
234 header('Content-Type: text/plain'); 239 header('Content-Type: text/plain');
235 header('Content-Disposition: attachment; filename="'.$name.'"'); 240 header('Content-Disposition: attachment; filename="'.$name.'"');
236 241
237 $answer = send_cmd('ARCHIVE GET '.$name); 242 $answer = send_cmd('ARCHIVE GET '.$name);
252 } 257 }
253 258
254 259
255 260
256 /* 261 /*
257 * 262 * Show directory
258 */ 263 */
259 function archive_dir() { 264 function archive_dir() {
260 265
261 $answer = send_cmd("ARCHIVE DIR"); 266 $answer = send_cmd("ARCHIVE DIR");
262 $reply = explode("\r\n", $answer); 267 $reply = explode("\r\n", $answer);
278 $j = 1; 283 $j = 1;
279 while (1) { 284 while (1) {
280 if (strcmp($reply[$j], ".") == 0) 285 if (strcmp($reply[$j], ".") == 0)
281 break; 286 break;
282 $f = explode(",", $reply[$j]); 287 $f = explode(",", $reply[$j]);
288 $name = urlencode(basename($f[0], ".log"));
283 $outstr .= ' <tr class="setup">'.PHP_EOL; 289 $outstr .= ' <tr class="setup">'.PHP_EOL;
284 $outstr .= ' <td class="setup">'.$f[0].'</td>'.PHP_EOL; 290 $outstr .= ' <td class="setup">'.$f[0].'</td>'.PHP_EOL;
285 $outstr .= ' <td class="setup">'.$f[1].'</td>'.PHP_EOL; 291 $outstr .= ' <td class="setup">'.$f[1].'</td>'.PHP_EOL;
286 $outstr .= ' <td class="setup">'.$f[2].'</td>'.PHP_EOL; 292 $outstr .= ' <td class="setup">'.$f[2].'</td>'.PHP_EOL;
287 $outstr .= ' <td class="setup">'.$f[3].'</td>'.PHP_EOL; 293 $outstr .= ' <td class="setup">'.$f[3].'</td>'.PHP_EOL;
288 $outstr .= ' <td class="setup"><a href="archives.php?action=dl&amp;name='.urlencode($f[0]).'">Download</a>'; 294 $outstr .= ' <td class="setup"><a href="archives.php?action=dl&amp;name='.$name.'">Download</a>';
289 $outstr .= ' <a href="archives.php?action=view&amp;name='.urlencode($f[0]).'">View</a></td>'.PHP_EOL; 295 $outstr .= ' <a href="archives.php?action=view&amp;name='.$name.'">View</a></td>'.PHP_EOL;
290 $outstr .= ' </tr>'.PHP_EOL; 296 $outstr .= ' </tr>'.PHP_EOL;
291 $j++; 297 $j++;
292 } 298 }
293 } 299 }
294 300

mercurial