Wed, 14 Jul 2021 20:51:45 +0200
In product editor calculate fermentables before the first IBU calculation. In recipe editor changed to the new water calculations like in the product editor.
181
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /***************************************************************************** |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
573
diff
changeset
|
2 | * Copyright (C) 2019-2020 |
181
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * Michiel Broek <mbroek at mbse dot eu> |
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * |
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * This file is part of BMS |
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * |
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * This is free software; you can redistribute it and/or modify it |
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * under the terms of the GNU General Public License as published by the |
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * Free Software Foundation; either version 2, or (at your option) any |
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * later version. |
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * |
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * Brewery Management System istributed in the hope that it will be useful, but |
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | * General Public License for more details. |
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | * |
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
19 | * along with ThermFerm; see the file COPYING. If not, write to the Free |
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | *****************************************************************************/ |
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | |
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | |
526 | 24 | $(document).ready(function() { |
181
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | |
695
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
26 | var record = {}, |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
27 | url = 'getnode.php?uuid="' + my_uuid + '"', |
526 | 28 | source = { |
29 | datatype: 'json', | |
30 | datafields: [ | |
31 | { name: 'record', type: 'int' }, | |
32 | { name: 'uuid', type: 'string' }, | |
33 | { name: 'node', type: 'string' }, | |
572
7a03181d29a3
Version 0.3.27 More code for iSpindels. All online/offline data in the database is now handles as integers. Nodes timeout use the configured interval time from the nodes.
Michiel Broek <mbroek@mbse.eu>
parents:
526
diff
changeset
|
34 | { name: 'online', type: 'int' }, |
526 | 35 | { name: 'group_id', type: 'string' }, |
36 | { name: 'hardwaremake', type: 'string' }, | |
37 | { name: 'hardwaremodel', type: 'string' }, | |
38 | { name: 'os', type: 'string' }, | |
39 | { name: 'os_version', type: 'string' }, | |
40 | { name: 'firmware', type: 'string' }, | |
41 | { name: 'firstseen', type: 'string' }, | |
42 | { name: 'lastseen', type: 'string' }, | |
43 | { name: 'temperature', type: 'float' }, | |
44 | { name: 'humidity', type: 'float' }, | |
45 | { name: 'barometer', type: 'float' }, | |
46 | { name: 'gps_latitude', type: 'float' }, | |
47 | { name: 'gps_longitude', type: 'float' }, | |
48 | { name: 'gps_altitude', type: 'float' }, | |
49 | { name: 'net_address', type: 'string' }, | |
50 | { name: 'net_ifname', type: 'string' }, | |
703
faeede125639
Version 0.3.35 Added nodes database net_ssid field.
Michiel Broek <mbroek@mbse.eu>
parents:
695
diff
changeset
|
51 | { name: 'net_ssid', type: 'string' }, |
578
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
573
diff
changeset
|
52 | { name: 'net_rssi', type: 'int' }, |
e75ce5bbda73
Changed the interface from the iSpindels to be the same as other devices. A webpage converts each call to two standard MQTT messages. The nodes MQTT message extended with an interval parameter. iSpindels now have a generated uuid made up from the chipid.
Michiel Broek <mbroek@mbse.eu>
parents:
573
diff
changeset
|
53 | { name: 'up_interval', type: 'int' } |
526 | 54 | ], |
55 | id: 'record', | |
56 | url: url | |
57 | }, | |
58 | dataAdapter = new $.jqx.dataAdapter(source, { | |
59 | loadComplete: function(records) { | |
695
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
60 | record = dataAdapter.records[0]; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
61 | updateScreen(); |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
62 | } |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
63 | }); |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
64 | |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
65 | function updateScreen() { |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
66 | var oline = (record.online) ? 'On-line' : 'Off-line', |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
67 | html = '<div id="node_table">'; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
68 | html += '<table style="width: 100%; padding: 10px;">'; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
69 | html += '<tr><th colspan=2>Systeem overzicht</th></tr>'; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
70 | html += '<tr><td>Uuid</td><td>' + record.uuid + '</td></tr>'; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
71 | html += '<tr><td>Systeem</td><td>' + record.node + '</td></tr>'; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
72 | html += '<tr><td>Online</td><td>' + oline + '</td></tr>'; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
73 | html += '<tr><td>Type</td><td>' + record.group_id + '</td></tr>'; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
74 | html += '<tr><td>Eerst gezien</td><td>' + record.firstseen + '</td></tr>'; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
75 | html += '<tr><td>Laatst gezien</td><td>' + record.lastseen + '</td></tr>'; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
76 | if (record.online) { |
526 | 77 | html += '<tr><td>Hardware maker</td><td>' + record.hardwaremake + '</td></tr>'; |
78 | html += '<tr><td>Hardware model</td><td>' + record.hardwaremodel + '</td></tr>'; | |
79 | html += '<tr><td>OS</td><td>' + record.os + ' versie: ' + record.os_version + '</td></tr>'; | |
80 | html += '<tr><td>Firmware</td><td>' + record.firmware + '</td></tr>'; | |
695
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
81 | |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
82 | if (record.temperature > 0) |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
83 | html += '<tr><td>Temperatuur</td><td>' + record.temperature.toFixed(1) + '°C</td></tr>'; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
84 | if (record.humidity > 0) |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
85 | html += '<tr><td>Vochtigheid</td><td>' + record.humidity.toFixed(1) + '%</td></tr>'; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
86 | if (record.barometer > 0) |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
87 | html += '<tr><td>Luchtdruk</td><td>' + record.barometer.toFixed(0) + '</td></tr>'; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
88 | if ((record.gps_latitude != 0) && (record.gps_longitude != 0)) |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
89 | html += '<tr><td>GPS</td><td>' + record.gps_latitude + ' ' + record.gps_longitude + ' ' + record.gps_altitude + '</td></tr>'; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
90 | html += '<tr><td>Netwerk</td><td>' + record.net_ifname + ' ' + record.net_address + '</td></tr>'; |
703
faeede125639
Version 0.3.35 Added nodes database net_ssid field.
Michiel Broek <mbroek@mbse.eu>
parents:
695
diff
changeset
|
91 | if (record.net_ssid) |
faeede125639
Version 0.3.35 Added nodes database net_ssid field.
Michiel Broek <mbroek@mbse.eu>
parents:
695
diff
changeset
|
92 | html += '<tr><td>WiFi SSID</td><td>' + record.net_ssid + '</td></tr>'; |
695
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
93 | if (record.net_rssi < 0) |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
94 | html += '<tr><td>WiFi signaal</td><td>' + record.net_rssi + '</td></tr>'; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
95 | html += '<tr><td>Update interval</td><td>' + record.up_interval + ' sec.</td></tr>'; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
96 | } |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
97 | html += '</<table>'; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
98 | html += '</div>'; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
99 | $('#ContentPanel').html(html); |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
100 | } |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
101 | |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
102 | // Get the data. |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
103 | dataAdapter.dataBind(); |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
104 | |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
105 | websocket.onmessage = function(evt) { |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
106 | var msg = evt.data; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
107 | var obj = JSON.parse(msg); |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
108 | if (! obj.device && obj.node == record.node) { |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
109 | record.online = obj.online; |
526 | 110 | if (record.online) { |
695
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
111 | record.group_id = obj.group_id; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
112 | record.lastseen = obj.lastseen; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
113 | if (obj.hardwaremake) |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
114 | record.harwaremake = obj.hardwaremake; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
115 | if (obj.hardwaremodel) |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
116 | record.hardwaremodel = obj.hardwaremodel; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
117 | if (obj.os) |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
118 | record.os = obj.os; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
119 | if (obj.os_version) |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
120 | record.os_version = obj.os_version; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
121 | if (obj.firmware) |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
122 | record.firmware = obj.firmware; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
123 | if (obj.temperature) |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
124 | record.temperature = obj.temperature; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
125 | if (obj.humidity) |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
126 | record.humidity = obj.humidity; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
127 | record.net_ifname = obj.net_ifname; |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
128 | record.net_address = obj.net_address; |
703
faeede125639
Version 0.3.35 Added nodes database net_ssid field.
Michiel Broek <mbroek@mbse.eu>
parents:
695
diff
changeset
|
129 | if (obj.net_ssid) |
faeede125639
Version 0.3.35 Added nodes database net_ssid field.
Michiel Broek <mbroek@mbse.eu>
parents:
695
diff
changeset
|
130 | record.net_ssid = obj.net_ssid; |
695
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
131 | if (obj.net_rssi) |
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
132 | record.net_rssi = obj.net_rssi; |
526 | 133 | } |
695
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
134 | updateScreen(); |
526 | 135 | } |
695
cfe232710027
Monitor nodes now uses websockets instead of polling.
Michiel Broek <mbroek@mbse.eu>
parents:
578
diff
changeset
|
136 | } |
181
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
137 | }); |
db4e62482d0b
Moved javascript out of mon_node.php
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
138 |