www/js/set_devices.js

Fri, 03 May 2024 14:14:01 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 03 May 2024 14:14:01 +0200
changeset 717
22dd7ab614e5
parent 714
24749c296a50
permissions
-rw-r--r--

Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.

685
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /*****************************************************************************
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * Copyright (C) 2024
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * Michiel Broek <mbroek at mbse dot eu>
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * This file is part of mbsePi-apps
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 *
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * This is free software; you can redistribute it and/or modify it
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * under the terms of the GNU General Public License as published by the
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * Free Software Foundation; either version 2, or (at your option) any
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * later version.
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 *
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * BrewCloud is distributed in the hope that it will be useful, but
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * General Public License for more details.
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 *
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 * along with ThermFerm; see the file COPYING. If not, write to the Free
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 *****************************************************************************/
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23
686
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
24 function createDelElements() {
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
25 $('#eventWindow').jqxWindow({
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
26 theme: theme,
703
344470c6bb1c Fermenter editor layout is ready. Load record done. Add and Delete a new fermenter is done.
Michiel Broek <mbroek@mbse.eu>
parents: 701
diff changeset
27 position: { x: 430, y: 210 },
344470c6bb1c Fermenter editor layout is ready. Load record done. Add and Delete a new fermenter is done.
Michiel Broek <mbroek@mbse.eu>
parents: 701
diff changeset
28 width: 420,
686
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
29 height: 175,
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
30 resizable: false,
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
31 isModal: true,
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
32 modalOpacity: 0.4,
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
33 okButton: $('#delOk'),
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
34 cancelButton: $('#delCancel'),
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
35 initContent: function() {
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
36 $('#delOk').jqxButton({ template: 'danger', width: '65px', theme: theme });
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
37 $('#delCancel').jqxButton({ template: 'success', width: '65px', theme: theme });
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
38 $('#delCancel').focus();
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
39 }
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
40 });
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
41 $('#eventWindow').jqxWindow('hide');
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
42 }
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
43
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
44
699
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
45 function createAddElements() {
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
46 $('#addWindow').jqxWindow({
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
47 theme: theme,
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
48 position: { x: 400, y: 210 },
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
49 width: 480,
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
50 height: 180,
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
51 resizable: false,
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
52 isModal: true,
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
53 modalOpacity: 0.4,
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
54 okButton: $('#addOk'),
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
55 cancelButton: $('#addCancel'),
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
56 initContent: function() {
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
57 $('#addType').jqxDropDownList({
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
58 theme: theme,
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
59 source: DeviceTypeAdapter,
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
60 valueMember: 'mno',
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
61 displayMember: 'en',
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
62 width: 180,
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
63 height: 30,
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
64 autoDropDownHeight: true
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
65 });
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
66 $("#addType").jqxDropDownList('disableItem', "W1" ); /* These are auto created, so disable. */
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
67 $("#addType").jqxDropDownList('disableItem', "GPIO" );
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
68 $("#addType").jqxDropDownList('disableItem', "SIM" );
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
69 $('#addOk').jqxButton({ template: 'success', width: '65px', theme: theme });
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
70 $('#addCancel').jqxButton({ template: 'primary', width: '65px', theme: theme });
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
71 $('#addCancel').focus();
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
72 }
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
73 });
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
74 $('#addWindow').jqxWindow('hide');
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
75 }
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
76
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
77
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
78
685
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 $(document).ready(function() {
686
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
80 var dataRecord = {},
714
24749c296a50 Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.
Michiel Broek <mbroek@mbse.eu>
parents: 712
diff changeset
81 url = 'dbdevices.php',
686
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
82 source = {
685
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83 datatype: 'json',
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 cache: false,
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 datafields: [
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 { name: 'uuid', type: 'string' },
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 { name: 'type', type: 'string' },
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 { name: 'address', type: 'string' },
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 { name: 'subdevice', type: 'int' },
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 { name: 'inuse', type: 'int' },
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 { name: 'description', type: 'string' },
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 { name: 'direction', type: 'string' },
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 { name: 'value', type: 'int' },
687
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
94 { name: 'offset', type: 'int' },
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
95 { name: 'present', type: 'string' },
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
96 { name: 'gpiopin', type: 'int' },
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
97 { name: 'comment', type: 'string' },
685
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 { name: 'timestamp', type: 'int' }
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 ],
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 id: 'uuid',
699
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
101 url: url
685
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 },
686
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
103 dataAdapter = new $.jqx.dataAdapter(source),
687
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
104 editrow = -1,
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
105 tzoffset = (new Date()).getTimezoneOffset() * 60000; //offset in milliseconds
686
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
106
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
107 // initialize the input fields.
699
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
108 $('#dev_uuid').jqxInput({ theme: theme, width: 360, height: 23 });
687
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
109 $('#dev_description').jqxInput({ theme: theme, width: 800, height: 23 });
686
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
110 $('#dev_type').jqxDropDownList({
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
111 theme: theme,
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
112 source: DeviceTypeAdapter,
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
113 valueMember: 'mno',
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
114 displayMember: 'en',
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
115 width: 180,
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
116 height: 23,
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
117 autoDropDownHeight: true
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
118 });
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
119 $('#dev_direction').jqxDropDownList({
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
120 theme: theme,
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
121 source: DeviceDirectionAdapter,
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
122 valueMember: 'mno',
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
123 displayMember: 'en',
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
124 width: 180,
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
125 height: 23,
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
126 autoDropDownHeight: true
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
127 });
687
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
128 $('#dev_value').jqxNumberInput(Spin0dec);
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
129 $('#dev_offset').jqxNumberInput(Spin0dec);
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
130 $('#dev_address').jqxInput({ theme: theme, width: 200, height: 23 });
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
131 $('#dev_subdevice').jqxNumberInput(SubInt);
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
132 $('#dev_present').jqxDropDownList({
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
133 theme: theme,
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
134 source: DevicePresentAdapter,
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
135 valueMember: 'mno',
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
136 displayMember: 'en',
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
137 width: 180,
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
138 height: 23,
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
139 autoDropDownHeight: true
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
140 });
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
141 $('#dev_gpiopin').jqxNumberInput(GPIOInt);
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
142 $('#dev_inuse').jqxNumberInput(Show0dec);
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
143 $('#dev_timestamp').jqxInput({ theme: theme, width: 200, height: 23 });
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
144 $('#dev_comment').jqxInput({ theme: theme, width: 800, height: 23 });
685
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
146 // initialize jqxGrid
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147 $('#jqxgrid').jqxGrid({
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 width: 1280,
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 height: 630,
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150 source: dataAdapter,
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 theme: theme,
686
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
152 showstatusbar: true,
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
153 renderstatusbar: function(statusbar) {
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
154 var rowCount = $("#jqxgrid").jqxGrid('getrows').length;
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
155 statusbar.append('<div style="float: left; margin: 8px; color: orange !important;">Total items: ' + rowCount + '</div>');
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
156 var container, addButton, impButton;
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
157 container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>');
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
158 addButton = $('<div style="float: right; margin-right: 15px;"><img style="position: relative; margin-top: 2px;" ' +
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
159 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -4px;">Nieuw</span></div>');
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
160 container.append(addButton);
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
161 statusbar.append(container);
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
162 addButton.jqxButton({ theme: theme, width: 90, height: 17 });
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
163 // add new row.
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
164 addButton.click(function(event) {
699
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
165 $('#addType').val('NA');
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
166 $('#addWindow').jqxWindow('open');
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
167 $('#addOk').click(function() {
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
168 if ($('#addType').val() != 'NA') {
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
169 console.log('Add type ' + $('#addType').val());
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
170 var data,
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
171 data = 'add=true&type=' + $('#addType').val();
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
172 console.log(data);
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
173 $.ajax({
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
174 dataType: 'json',
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
175 url: url,
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
176 cache: false,
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
177 data: data,
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
178 type: 'POST',
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
179 success: function(data) {
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
180 if (data.error) {
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
181 console.log('add: ' + data.msg);
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
182 alert('Error: ' + data.msg);
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
183 } else {
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
184 console.log('add: success');
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
185 }
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
186 },
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
187 error: function(jqXHR, textStatus, errorThrown) {
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
188 }
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
189 });
700
942af738157c Added device delete
Michiel Broek <mbroek@mbse.eu>
parents: 699
diff changeset
190 $('#jqxgrid').jqxGrid('updatebounddata');
699
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
191 } else {
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
192 console.log('Add wrong type');
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
193 }
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
194 });
686
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
195 });
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
196 },
685
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
197 columns: [
712
93a87fe230cc Log marking device missing if a onewire devices goes away. Fixes in fermenters display. Added Present and Inuse columns in devices list.
Michiel Broek <mbroek@mbse.eu>
parents: 703
diff changeset
198 { text: 'Address', datafield: 'address', width: 180 },
93a87fe230cc Log marking device missing if a onewire devices goes away. Fixes in fermenters display. Added Present and Inuse columns in devices list.
Michiel Broek <mbroek@mbse.eu>
parents: 703
diff changeset
199 { text: 'Sub', datafield: 'subdevice', width: 50 },
93a87fe230cc Log marking device missing if a onewire devices goes away. Fixes in fermenters display. Added Present and Inuse columns in devices list.
Michiel Broek <mbroek@mbse.eu>
parents: 703
diff changeset
200 { text: 'Present', datafield: 'present', width: 80 },
700
942af738157c Added device delete
Michiel Broek <mbroek@mbse.eu>
parents: 699
diff changeset
201 { text: 'Type', datafield: 'type', width: 100 },
712
93a87fe230cc Log marking device missing if a onewire devices goes away. Fixes in fermenters display. Added Present and Inuse columns in devices list.
Michiel Broek <mbroek@mbse.eu>
parents: 703
diff changeset
202 { text: 'Direction', datafield: 'direction', width: 110 },
685
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
203 { text: 'Value', datafield: 'value', width: 80 },
712
93a87fe230cc Log marking device missing if a onewire devices goes away. Fixes in fermenters display. Added Present and Inuse columns in devices list.
Michiel Broek <mbroek@mbse.eu>
parents: 703
diff changeset
204 { text: 'Used', datafield: 'inuse', width: 60 },
685
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
205 { text: 'Description', datafield: 'description' },
712
93a87fe230cc Log marking device missing if a onewire devices goes away. Fixes in fermenters display. Added Present and Inuse columns in devices list.
Michiel Broek <mbroek@mbse.eu>
parents: 703
diff changeset
206 { text: 'Last change', datafield: 'timestamp', width: 190,
685
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) {
687
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
208 var date = new Date((value * 1000) - tzoffset).toISOString().slice(0, 19).replace("T", " ");
685
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + date + '</span>';
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
210 }
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 },
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212 { text: '', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: function() {
686
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
213 return 'Edit';
685
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 }, buttonclick: function(row) {
686
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
215 // open the popup window when the user clicks a button.
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
216 editrow = row;
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
217 $('#popupWindow').jqxWindow({ position: { x: 110, y: 15 } });
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
218 dataRecord = $('#jqxgrid').jqxGrid('getrowdata', editrow);
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
219 $('#dev_uuid').val(dataRecord.uuid);
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
220 $('#dev_description').val(dataRecord.description);
687
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
221 $('#dev_type').val(dataRecord.type);
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
222 $('#dev_direction').val(dataRecord.direction);
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
223 $('#dev_value').val(dataRecord.value);
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
224 $('#dev_offset').val(dataRecord.offset);
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
225 $('#dev_address').val(dataRecord.address);
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
226 $('#dev_subdevice').val(dataRecord.subdevice);
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
227 $('#dev_present').val(dataRecord.present);
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
228 $('#dev_gpiopin').val(dataRecord.gpiopin);
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
229 $('#dev_inuse').val(dataRecord.inuse);
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
230 var date = new Date((dataRecord.timestamp * 1000) - tzoffset).toISOString().slice(0, 19).replace("T", " ");
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
231 $('#dev_timestamp').val(date);
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
232 $('#dev_comment').val(dataRecord.comment);
686
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
233 // show the popup window.
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
234 $('#popupWindow').jqxWindow('open');
685
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
235 }
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
236 }
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
237 ],
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
238 });
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
239
686
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
240 // initialize the popup window and buttons.
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
241 $('#popupWindow').jqxWindow({
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
242 width: 1050,
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
243 height: 625,
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
244 resizable: false,
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
245 theme: theme,
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
246 isModal: true,
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
247 autoOpen: false,
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
248 cancelButton: $('#Cancel'),
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
249 modalOpacity: 0.40
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
250 });
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
251 $('#popupWindow').on('open', function() {
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
252 $('#dev_description').jqxInput('selectAll');
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
253 });
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
254 $('#Delete').jqxButton({ template: 'danger', width: '90px', theme: theme });
687
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
255 $('#Delete').click(function() {
717
22dd7ab614e5 Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
256 // Open a popup to confirm this action.
22dd7ab614e5 Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
257 $('#eventWindow').jqxWindow('open');
22dd7ab614e5 Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
258 $('#delOk').click(function() {
22dd7ab614e5 Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
259 // var data,
22dd7ab614e5 Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
260 var data = 'del=true&uuid=' + $('#dev_uuid').val();
22dd7ab614e5 Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
261 $.ajax({
22dd7ab614e5 Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
262 dataType: 'json',
22dd7ab614e5 Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
263 url: url,
22dd7ab614e5 Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
264 cache: false,
22dd7ab614e5 Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
265 data: data,
22dd7ab614e5 Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
266 type: 'POST',
22dd7ab614e5 Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
267 success: function(data) {
22dd7ab614e5 Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
268 if (data.error) {
22dd7ab614e5 Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
269 console.log('del: ' + data.msg);
22dd7ab614e5 Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
270 alert('Error: ' + data.msg);
22dd7ab614e5 Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
271 } else {
22dd7ab614e5 Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
272 console.log('del: success');
22dd7ab614e5 Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
273 }
22dd7ab614e5 Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
274 },
22dd7ab614e5 Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
275 error: function(jqXHR, textStatus, errorThrown) {}
687
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
276 });
717
22dd7ab614e5 Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
277 $('#jqxgrid').jqxGrid('updatebounddata');
22dd7ab614e5 Add new fermenter adds dummy yeast temperatures. Periodic thermferm unit logging adds the unit alias name. Added Green LED hide color. Moved getglobal.php to dbglobal.php. Adjusted several record types in global and fermenter javascript records so there is less guesswork. Only display control leds and switches for defined equipment.
Michiel Broek <mbroek@mbse.eu>
parents: 714
diff changeset
278 });
687
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
279 $('#popupWindow').jqxWindow('hide');
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
280 });
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
281 $('#Cancel').jqxButton({ template: 'primary', width: '90px', theme: theme });
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
282 $('#Save').jqxButton({ template: 'success', width: '90px', theme: theme });
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
283 $('#Save').click(function() {
701
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
284 var data,
687
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
285 row = {
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
286 uuid: dataRecord.uuid,
701
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
287 type: $('#dev_type').val(),
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
288 direction: $('#dev_direction').val(),
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
289 value: parseInt($('#dev_value').jqxNumberInput('decimal')),
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
290 offset: parseInt($('#dev_offset').jqxNumberInput('decimal')),
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
291 present: $('#dev_present').val(),
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
292 address: $('#dev_address').val(),
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
293 subdevice: parseInt($('#dev_subdevice').jqxNumberInput('decimal')),
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
294 gpiopin: parseInt($('#dev_gpiopin').jqxNumberInput('val')),
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
295 description: $('#dev_description').val(),
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
296 comment: $('#dev_comment').val()
687
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
297 };
701
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
298 data = 'update=true&' + $.param(row);
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
299 console.log(data);
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
300 $.ajax({
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
301 dataType: 'json',
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
302 url: url,
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
303 cache: false,
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
304 data: data,
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
305 type: 'POST',
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
306 success: function(data) {
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
307 if (data.error) {
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
308 console.log('update: ' + data.msg);
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
309 alert('Error: ' + data.msg);
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
310 } else {
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
311 console.log('update: success');
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
312 }
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
313 },
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
314 error: function(jqXHR, textStatus, errorThrown) {}
e50a5003c7ac Device Save implemented.
Michiel Broek <mbroek@mbse.eu>
parents: 700
diff changeset
315 });
687
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
316 $('#popupWindow').jqxWindow('hide');
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
317 });
f5d05b420732 Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents: 686
diff changeset
318 createDelElements();
699
35382668a140 Added Add new device.
Michiel Broek <mbroek@mbse.eu>
parents: 689
diff changeset
319 createAddElements();
686
372b2442a30f More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents: 685
diff changeset
320
685
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
321 websocket.onmessage = function(evt) {
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
322 var msg = evt.data;
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
323 var obj = JSON.parse(msg);
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
324
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
325 if (obj.ping) {
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
326 websocket.send('{"pong":' + obj.ping + '}');
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
327 }
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
328
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
329 if (obj.type == 'device') {
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
330 // Use the message to trigger update.
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
331 $('#jqxgrid').jqxGrid('updatebounddata');
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
332 }
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
333 }
819553a2b97e Devices list grid added.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
334 });

mercurial