www-thermferm/global.php

Wed, 07 Jun 2017 23:06:47 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 07 Jun 2017 23:06:47 +0200
changeset 513
a2732027afb3
parent 506
cdcd07bbee30
child 534
92b546d4a839
permissions
-rw-r--r--

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
cdcd07bbee30 New MQTT protocol
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
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
7259ee8778e9 More style updates
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
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
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
26
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
27 if (isset($_POST['action'])) {
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
28 if ($_POST['action'] == "testdata")
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
29 testdata();
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
30 } else {
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
31 edit_screen("");
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
32 }
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
33
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
34
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
35 exit;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
36
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
37
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
38 /*****************************************************************************
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
39 *
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
40 */
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
41
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
42
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
43 function global_update() {
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
44
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
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
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
58 }
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
59
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
60 unset($_POST['Name']);
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
61 unset($_POST['Port']);
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
62 unset($_POST['TempAddress']);
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
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
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
65 unset($_POST['LCDcols']);
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
66 unset($_POST['LCDrows']);
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
67 unset($_POST['key']);
506
cdcd07bbee30 New MQTT protocol
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
68 load('maintenance.php');
207
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
69 }
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
70
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
71
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
72
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
73 function test_thedata() {
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
74
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
75 if (isset($_POST['Name']) && isset($_POST['Port']) &&
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
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
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
78
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
79 if ($_POST['key'] == 'Cancel')
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
80 return 99;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
81
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
82 if (isset($_POST['LCDcols']) && (($_POST['LCDcols'] != 16) && ($_POST['LCDcols'] != 20)))
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
83 return 2;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
84
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
85 if (isset($_POST['LCDrows']) && (($_POST['LCDrows'] != 2) && ($_POST['LCDrows'] != 4)))
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
86 return 3;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
87
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
88 } else {
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
89 return 1;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
90 }
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
91
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
92 return 0;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
93 }
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
94
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
95
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
96
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
97 function testdata()
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
98 {
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
99 $result = test_thedata();
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
100 $error = '';
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
101
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
102 switch ($result) {
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
103 case 0: global_update();
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
104 return;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
105 break;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
106 case 1: $error = 'Missing data';
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
107 break;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
108 case 2: $error = 'LCD columns must be 16 or 20';
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
109 break;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
110 case 3: $error = 'LCD rows must be 2 or 4';
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
111 break;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
112 case 99:
506
cdcd07bbee30 New MQTT protocol
Michiel Broek <mbroek@mbse.eu>
parents: 397
diff changeset
113 load('maintenance.php');
207
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
114 break;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
115 }
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
116
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
117 edit_screen($error);
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
118 }
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
119
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
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
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
122 function edit_screen($error_message)
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
123 {
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
124 /*
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
125 * Get list of devices, we need it later
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
126 */
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
127 $answer = send_cmd("DEVICE LIST");
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
128 $devices = explode("\r\n", $answer);
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
129
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
130 /*
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
131 * Get current global data
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
132 */
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
133 $answer = send_cmd("GLOBAL GET");
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
134 $reply = explode("\r\n", $answer);
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
135
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
136 $outstr = build_header("ThermFerm - Global Setup");
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
137 $outstr .= ' <div id="errors">'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
138 $outstr .= ' '.$error_message.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
139 $outstr .= ' </div> <!-- errors -->'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
140 $outstr .= ' <div id="etable">'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
141 $outstr .= ' <form method="POST" action="global.php">'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
142 $outstr .= ' <table class="editor">'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
143 $outstr .= ' <tr class="trhead">'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
144 $outstr .= ' <td class="setup" colspan="2" style="text-align: center; height: 20px; padding-top: 5px;">Global Setup</td>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
145 $outstr .= ' </tr>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
146
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
147 if (startsWith($reply[0], "213")) {
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
148 $i = 1;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
149 while (1) {
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
150 if (strcmp($reply[$i], ".") == 0)
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
151 break;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
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
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
154 if ($f[0] == "NAME") {
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
155 $outstr .= ' <tr class="editor">'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
156 $outstr .= ' <td class="editname">System Name</td>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
157 $outstr .= ' <td class="editfield"><input type="text" name="Name" size="50" value="'.$f[1].'"></td>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
158 $outstr .= ' </tr>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
159 }
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
160 if ($f[0] == "PORT") {
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
161 $outstr .= ' <tr class="editor">'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
162 $outstr .= ' <td class="editname">Telnet port</td>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
163 $outstr .= ' <td class="editfield"><input type="text" name="Port" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
164 $outstr .= ' </tr>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
165 }
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
166 if ($f[0] == "TEMP_ADDRESS") {
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
167 $outstr .= ' <tr class="editor">'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
168 $outstr .= ' <td class="editname">Room temperature sensor</td>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
169 $outstr .= ' <td class="editfield"><select name="TempAddress">'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
170 $outstr .= ' <option value="">Not Assigned</option>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
171 if (startsWith($devices[0], "212")) {
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
172 $j = 1;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
173 while (1) {
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
174 if (strcmp($devices[$j], ".") == 0)
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
175 break;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
176 $g = explode(",", $devices[$j]);
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
177 if ($g[5] == "IN_ANALOG") {
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
178 ($f[1] == $g[0]) ? $se = " selected" : $se = "";
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
179 $outstr .= ' <option value="'.$g[0].'"'.$se.'>'.$g[1].' '.$g[4].'</option>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
180 }
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
181 $j++;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
182 }
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
183 }
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
184 $outstr .= ' </select></td>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
185 $outstr .= ' </tr>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
186 }
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
187 if ($f[0] == "HUM_ADDRESS") {
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
188 $outstr .= ' <tr class="editor">'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
189 $outstr .= ' <td class="editname">Room humidity sensor</td>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
190 $outstr .= ' <td class="editfield"><select name="HumAddress">'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
191 $outstr .= ' <option value="">Not Assigned</option>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
192 if (startsWith($devices[0], "212")) {
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
193 $j = 1;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
194 while (1) {
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
195 if (strcmp($devices[$j], ".") == 0)
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
196 break;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
197 $g = explode(",", $devices[$j]);
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
198 if ($g[5] == "IN_ANALOG") {
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
199 ($f[1] == $g[0]) ? $se = " selected" : $se = "";
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
200 $outstr .= ' <option value="'.$g[0].'"'.$se.'>'.$g[1].' '.$g[4].'</option>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
201 }
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
202 $j++;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
203 }
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
204 }
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
205 $outstr .= ' </select></td>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
206 $outstr .= ' </tr>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
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
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
214 if ($f[0] == "LCD_COLS") {
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
215 $outstr .= ' <tr class="editor">'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
216 $outstr .= ' <td class="editname">LCD columns</td>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
217 $outstr .= ' <td class="editfield"><input type="text" name="LCDcols" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
218 $outstr .= ' </tr>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
219 }
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
220 if ($f[0] == "LCD_ROWS") {
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
221 $outstr .= ' <tr class="editor">'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
222 $outstr .= ' <td class="editname">LCD rows</td>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
223 $outstr .= ' <td class="editfield"><input type="text" name="LCDrows" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
224 $outstr .= ' </tr>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
225 }
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
226 $i++;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
227 }
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
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
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
230 $outstr .= ' <tr class="editor">'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
231 $outstr .= ' <td class="editname"><input type="submit" value="Save" name="key"></td>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
232 $outstr .= ' <td class="editfield"><input type="submit" value="Cancel" name="key">';
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
233 $outstr .= '<input type="hidden" value="testdata" name="action">';
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
234 $outstr .= ' </tr>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
235 $outstr .= ' </table>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
236 $outstr .= ' </form>'.PHP_EOL;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
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
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
243 $outstr .= build_footer();
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
244
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
245 echo $outstr;
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
246 }
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
247
8d2ba4126519 Added global setup
Michiel Broek <mbroek@mbse.eu>
parents: 173
diff changeset
248

mercurial