Wed, 07 Jun 2017 23:06:47 +0200
Version 0.6.1 added support for domoticz mqtt sensors.
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | <?php |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | /***************************************************************************** |
506 | 3 | * Copyright (C) 2014-2017 |
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * Michiel Broek <mbroek at mbse dot eu> |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * This file is part of ThermFerm |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * This is free software; you can redistribute it and/or modify it |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * under the terms of the GNU General Public License as published by the |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * Free Software Foundation; either version 2, or (at your option) any |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * later version. |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * ThermFerm is distributed in the hope that it will be useful, but |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | * General Public License for more details. |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | * |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | * along with ThermFerm; see the file COPYING. If not, write to the Free |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | *****************************************************************************/ |
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | |
173 | 24 | require_once('utilities.php'); |
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | |
207 | 26 | |
27 | if (isset($_POST['action'])) { | |
28 | if ($_POST['action'] == "testdata") | |
29 | testdata(); | |
30 | } else { | |
31 | edit_screen(""); | |
32 | } | |
33 | ||
34 | ||
35 | exit; | |
36 | ||
37 | ||
38 | /***************************************************************************** | |
39 | * | |
40 | */ | |
41 | ||
42 | ||
43 | function global_update() { | |
44 | ||
45 | if ($_POST['key'] == 'Save') { | |
253
7b6abc0dd1c6
Global and profile editor use array commands
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
46 | $cmd = array("GLOBAL PUT"); |
7b6abc0dd1c6
Global and profile editor use array commands
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
47 | $cmd[] = "NAME,".$_POST['Name']; |
7b6abc0dd1c6
Global and profile editor use array commands
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
48 | $cmd[] = "PORT,".$_POST['Port']; |
7b6abc0dd1c6
Global and profile editor use array commands
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
49 | $cmd[] = "TEMP_ADDRESS,".$_POST['TempAddress']; |
7b6abc0dd1c6
Global and profile editor use array commands
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
50 | $cmd[] = "HUM_ADDRESS,".$_POST['HumAddress']; |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
51 | $cmd[] = "TEMP_HUM_IDX,".$_POST['TempHumIdx']; |
253
7b6abc0dd1c6
Global and profile editor use array commands
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
52 | if (isset($_POST['LCDcols'])) |
7b6abc0dd1c6
Global and profile editor use array commands
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
53 | $cmd[] = "LCD_COLS,".$_POST['LCDcols']; |
7b6abc0dd1c6
Global and profile editor use array commands
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
54 | if (isset($_POST['LCDrows'])) |
7b6abc0dd1c6
Global and profile editor use array commands
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
55 | $cmd[] = "LCD_ROWS,".$_POST['LCDrows']; |
7b6abc0dd1c6
Global and profile editor use array commands
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
56 | $cmd[] = "."; |
7b6abc0dd1c6
Global and profile editor use array commands
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
57 | send_array($cmd); |
207 | 58 | } |
59 | ||
60 | unset($_POST['Name']); | |
61 | unset($_POST['Port']); | |
62 | unset($_POST['TempAddress']); | |
63 | unset($_POST['HumAddress']); | |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
64 | unset($_POST['TempHumIdx']); |
207 | 65 | unset($_POST['LCDcols']); |
66 | unset($_POST['LCDrows']); | |
67 | unset($_POST['key']); | |
506 | 68 | load('maintenance.php'); |
207 | 69 | } |
70 | ||
71 | ||
72 | ||
73 | function test_thedata() { | |
74 | ||
75 | if (isset($_POST['Name']) && isset($_POST['Port']) && | |
76 | isset($_POST['TempAddress']) && isset($_POST['HumAddress']) && | |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
77 | isset($_POST['TempHumIdx']) && isset($_POST['key'])) { |
207 | 78 | |
79 | if ($_POST['key'] == 'Cancel') | |
80 | return 99; | |
81 | ||
82 | if (isset($_POST['LCDcols']) && (($_POST['LCDcols'] != 16) && ($_POST['LCDcols'] != 20))) | |
83 | return 2; | |
84 | ||
85 | if (isset($_POST['LCDrows']) && (($_POST['LCDrows'] != 2) && ($_POST['LCDrows'] != 4))) | |
86 | return 3; | |
87 | ||
88 | } else { | |
89 | return 1; | |
90 | } | |
91 | ||
92 | return 0; | |
93 | } | |
94 | ||
95 | ||
96 | ||
97 | function testdata() | |
98 | { | |
99 | $result = test_thedata(); | |
100 | $error = ''; | |
101 | ||
102 | switch ($result) { | |
103 | case 0: global_update(); | |
104 | return; | |
105 | break; | |
106 | case 1: $error = 'Missing data'; | |
107 | break; | |
108 | case 2: $error = 'LCD columns must be 16 or 20'; | |
109 | break; | |
110 | case 3: $error = 'LCD rows must be 2 or 4'; | |
111 | break; | |
112 | case 99: | |
506 | 113 | load('maintenance.php'); |
207 | 114 | break; |
115 | } | |
116 | ||
117 | edit_screen($error); | |
118 | } | |
119 | ||
120 | ||
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
121 | |
207 | 122 | function edit_screen($error_message) |
123 | { | |
124 | /* | |
125 | * Get list of devices, we need it later | |
126 | */ | |
127 | $answer = send_cmd("DEVICE LIST"); | |
128 | $devices = explode("\r\n", $answer); | |
129 | ||
130 | /* | |
131 | * Get current global data | |
132 | */ | |
133 | $answer = send_cmd("GLOBAL GET"); | |
134 | $reply = explode("\r\n", $answer); | |
135 | ||
136 | $outstr = build_header("ThermFerm - Global Setup"); | |
137 | $outstr .= ' <div id="errors">'.PHP_EOL; | |
138 | $outstr .= ' '.$error_message.PHP_EOL; | |
139 | $outstr .= ' </div> <!-- errors -->'.PHP_EOL; | |
140 | $outstr .= ' <div id="etable">'.PHP_EOL; | |
141 | $outstr .= ' <form method="POST" action="global.php">'.PHP_EOL; | |
142 | $outstr .= ' <table class="editor">'.PHP_EOL; | |
143 | $outstr .= ' <tr class="trhead">'.PHP_EOL; | |
144 | $outstr .= ' <td class="setup" colspan="2" style="text-align: center; height: 20px; padding-top: 5px;">Global Setup</td>'.PHP_EOL; | |
145 | $outstr .= ' </tr>'.PHP_EOL; | |
146 | ||
147 | if (startsWith($reply[0], "213")) { | |
148 | $i = 1; | |
149 | while (1) { | |
150 | if (strcmp($reply[$i], ".") == 0) | |
151 | break; | |
152 | $f = explode(",", $reply[$i]); | |
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
153 | |
207 | 154 | if ($f[0] == "NAME") { |
155 | $outstr .= ' <tr class="editor">'.PHP_EOL; | |
156 | $outstr .= ' <td class="editname">System Name</td>'.PHP_EOL; | |
157 | $outstr .= ' <td class="editfield"><input type="text" name="Name" size="50" value="'.$f[1].'"></td>'.PHP_EOL; | |
158 | $outstr .= ' </tr>'.PHP_EOL; | |
159 | } | |
160 | if ($f[0] == "PORT") { | |
161 | $outstr .= ' <tr class="editor">'.PHP_EOL; | |
162 | $outstr .= ' <td class="editname">Telnet port</td>'.PHP_EOL; | |
163 | $outstr .= ' <td class="editfield"><input type="text" name="Port" size="5" value="'.$f[1].'"></td>'.PHP_EOL; | |
164 | $outstr .= ' </tr>'.PHP_EOL; | |
165 | } | |
166 | if ($f[0] == "TEMP_ADDRESS") { | |
167 | $outstr .= ' <tr class="editor">'.PHP_EOL; | |
168 | $outstr .= ' <td class="editname">Room temperature sensor</td>'.PHP_EOL; | |
169 | $outstr .= ' <td class="editfield"><select name="TempAddress">'.PHP_EOL; | |
170 | $outstr .= ' <option value="">Not Assigned</option>'.PHP_EOL; | |
171 | if (startsWith($devices[0], "212")) { | |
172 | $j = 1; | |
173 | while (1) { | |
174 | if (strcmp($devices[$j], ".") == 0) | |
175 | break; | |
176 | $g = explode(",", $devices[$j]); | |
177 | if ($g[5] == "IN_ANALOG") { | |
178 | ($f[1] == $g[0]) ? $se = " selected" : $se = ""; | |
179 | $outstr .= ' <option value="'.$g[0].'"'.$se.'>'.$g[1].' '.$g[4].'</option>'.PHP_EOL; | |
180 | } | |
181 | $j++; | |
182 | } | |
183 | } | |
184 | $outstr .= ' </select></td>'.PHP_EOL; | |
185 | $outstr .= ' </tr>'.PHP_EOL; | |
186 | } | |
187 | if ($f[0] == "HUM_ADDRESS") { | |
188 | $outstr .= ' <tr class="editor">'.PHP_EOL; | |
189 | $outstr .= ' <td class="editname">Room humidity sensor</td>'.PHP_EOL; | |
190 | $outstr .= ' <td class="editfield"><select name="HumAddress">'.PHP_EOL; | |
191 | $outstr .= ' <option value="">Not Assigned</option>'.PHP_EOL; | |
192 | if (startsWith($devices[0], "212")) { | |
193 | $j = 1; | |
194 | while (1) { | |
195 | if (strcmp($devices[$j], ".") == 0) | |
196 | break; | |
197 | $g = explode(",", $devices[$j]); | |
198 | if ($g[5] == "IN_ANALOG") { | |
199 | ($f[1] == $g[0]) ? $se = " selected" : $se = ""; | |
200 | $outstr .= ' <option value="'.$g[0].'"'.$se.'>'.$g[1].' '.$g[4].'</option>'.PHP_EOL; | |
201 | } | |
202 | $j++; | |
203 | } | |
204 | } | |
205 | $outstr .= ' </select></td>'.PHP_EOL; | |
206 | $outstr .= ' </tr>'.PHP_EOL; | |
207 | } | |
513
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
208 | if ($f[0] == "TEMP_HUM_IDX") { |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
209 | $outstr .= ' <tr class="editor">'.PHP_EOL; |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
210 | $outstr .= ' <td class="editname">Temp/Humidity domoticz index</td>'.PHP_EOL; |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
211 | $outstr .= ' <td class="editfield"><input type="text" name="TempHumIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL; |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
212 | $outstr .= ' </tr>'.PHP_EOL; |
a2732027afb3
Version 0.6.1 added support for domoticz mqtt sensors.
Michiel Broek <mbroek@mbse.eu>
parents:
506
diff
changeset
|
213 | } |
207 | 214 | if ($f[0] == "LCD_COLS") { |
215 | $outstr .= ' <tr class="editor">'.PHP_EOL; | |
216 | $outstr .= ' <td class="editname">LCD columns</td>'.PHP_EOL; | |
217 | $outstr .= ' <td class="editfield"><input type="text" name="LCDcols" size="5" value="'.$f[1].'"></td>'.PHP_EOL; | |
218 | $outstr .= ' </tr>'.PHP_EOL; | |
219 | } | |
220 | if ($f[0] == "LCD_ROWS") { | |
221 | $outstr .= ' <tr class="editor">'.PHP_EOL; | |
222 | $outstr .= ' <td class="editname">LCD rows</td>'.PHP_EOL; | |
223 | $outstr .= ' <td class="editfield"><input type="text" name="LCDrows" size="5" value="'.$f[1].'"></td>'.PHP_EOL; | |
224 | $outstr .= ' </tr>'.PHP_EOL; | |
225 | } | |
226 | $i++; | |
227 | } | |
228 | } | |
134
f05601490415
Redesigned the web interface, one single app is too slow. The main dashboard will be a shiny ajax driven page, the setup pages will be simple and php only. Keep It Simple, Stupid.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
229 | |
207 | 230 | $outstr .= ' <tr class="editor">'.PHP_EOL; |
231 | $outstr .= ' <td class="editname"><input type="submit" value="Save" name="key"></td>'.PHP_EOL; | |
232 | $outstr .= ' <td class="editfield"><input type="submit" value="Cancel" name="key">'; | |
233 | $outstr .= '<input type="hidden" value="testdata" name="action">'; | |
234 | $outstr .= ' </tr>'.PHP_EOL; | |
235 | $outstr .= ' </table>'.PHP_EOL; | |
236 | $outstr .= ' </form>'.PHP_EOL; | |
237 | $outstr .= ' </div> <!-- etable -->'.PHP_EOL; | |
397
00ca08f5a6f8
Fermentation profiles now have a low and high temperature setting so that you can use a temperture window. Each profile step can now set for beer or air temperature reference. The logfiles have an extra temperature field for this. Bumped to version 0.4.2.
Michiel Broek <mbroek@mbse.eu>
parents:
253
diff
changeset
|
238 | $outstr .= ' <script type="text/javascript">'.PHP_EOL; |
00ca08f5a6f8
Fermentation profiles now have a low and high temperature setting so that you can use a temperture window. Each profile step can now set for beer or air temperature reference. The logfiles have an extra temperature field for this. Bumped to version 0.4.2.
Michiel Broek <mbroek@mbse.eu>
parents:
253
diff
changeset
|
239 | $outstr .= ' $(document).ready(function () {'.PHP_EOL; |
00ca08f5a6f8
Fermentation profiles now have a low and high temperature setting so that you can use a temperture window. Each profile step can now set for beer or air temperature reference. The logfiles have an extra temperature field for this. Bumped to version 0.4.2.
Michiel Broek <mbroek@mbse.eu>
parents:
253
diff
changeset
|
240 | $outstr .= ' $("#maintenance").jqxButton({ width: 150, height: 25, theme: \'ui-redmond\' });'.PHP_EOL; |
00ca08f5a6f8
Fermentation profiles now have a low and high temperature setting so that you can use a temperture window. Each profile step can now set for beer or air temperature reference. The logfiles have an extra temperature field for this. Bumped to version 0.4.2.
Michiel Broek <mbroek@mbse.eu>
parents:
253
diff
changeset
|
241 | $outstr .= ' });'.PHP_EOL; |
00ca08f5a6f8
Fermentation profiles now have a low and high temperature setting so that you can use a temperture window. Each profile step can now set for beer or air temperature reference. The logfiles have an extra temperature field for this. Bumped to version 0.4.2.
Michiel Broek <mbroek@mbse.eu>
parents:
253
diff
changeset
|
242 | $outstr .= ' </script>'.PHP_EOL; |
207 | 243 | $outstr .= build_footer(); |
244 | ||
245 | echo $outstr; | |
246 | } | |
247 | ||
248 |