Fri, 19 Apr 2024 20:56:55 +0200
Create global_json() for all and expanded the data to the complete setup. Added design for the global setup.
685 | 1 | /***************************************************************************** |
2 | * Copyright (C) 2024 | |
3 | * | |
4 | * Michiel Broek <mbroek at mbse dot eu> | |
5 | * | |
6 | * This file is part of mbsePi-apps | |
7 | * | |
8 | * This is free software; you can redistribute it and/or modify it | |
9 | * under the terms of the GNU General Public License as published by the | |
10 | * Free Software Foundation; either version 2, or (at your option) any | |
11 | * later version. | |
12 | * | |
13 | * BrewCloud is distributed in the hope that it will be useful, but | |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | * General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with ThermFerm; see the file COPYING. If not, write to the Free | |
20 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
21 | *****************************************************************************/ | |
22 | ||
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, |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
27 | position: { x: 490, y: 210 }, |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
28 | width: 300, |
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 | |
685 | 45 | $(document).ready(function() { |
686
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
46 | var dataRecord = {}, |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
47 | source = { |
685 | 48 | datatype: 'json', |
49 | cache: false, | |
50 | datafields: [ | |
51 | { name: 'uuid', type: 'string' }, | |
52 | { name: 'type', type: 'string' }, | |
53 | { name: 'address', type: 'string' }, | |
54 | { name: 'subdevice', type: 'int' }, | |
55 | { name: 'inuse', type: 'int' }, | |
56 | { name: 'description', type: 'string' }, | |
57 | { name: 'direction', type: 'string' }, | |
58 | { name: 'value', type: 'int' }, | |
687
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
59 | { name: 'offset', type: 'int' }, |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
60 | { name: 'present', type: 'string' }, |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
61 | { name: 'gpiopin', type: 'int' }, |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
62 | { name: 'comment', type: 'string' }, |
685 | 63 | { name: 'timestamp', type: 'int' } |
64 | ], | |
65 | id: 'uuid', | |
66 | url: 'getdevices.php' | |
67 | }, | |
686
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
68 | dataAdapter = new $.jqx.dataAdapter(source), |
687
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
69 | editrow = -1, |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
70 | 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
|
71 | |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
72 | // initialize the input fields. |
687
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
73 | $('#dev_uuid').jqxInput({ theme: theme, width: 480, height: 23 }); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
74 | $('#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
|
75 | $('#dev_type').jqxDropDownList({ |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
76 | theme: theme, |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
77 | source: DeviceTypeAdapter, |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
78 | valueMember: 'mno', |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
79 | displayMember: 'en', |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
80 | width: 180, |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
81 | height: 23, |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
82 | autoDropDownHeight: true |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
83 | }); |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
84 | $('#dev_direction').jqxDropDownList({ |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
85 | theme: theme, |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
86 | source: DeviceDirectionAdapter, |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
87 | valueMember: 'mno', |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
88 | displayMember: 'en', |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
89 | width: 180, |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
90 | height: 23, |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
91 | autoDropDownHeight: true |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
92 | }); |
687
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
93 | $('#dev_value').jqxNumberInput(Spin0dec); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
94 | $('#dev_offset').jqxNumberInput(Spin0dec); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
95 | $('#dev_address').jqxInput({ theme: theme, width: 200, height: 23 }); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
96 | $('#dev_subdevice').jqxNumberInput(SubInt); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
97 | $('#dev_present').jqxDropDownList({ |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
98 | theme: theme, |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
99 | source: DevicePresentAdapter, |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
100 | valueMember: 'mno', |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
101 | displayMember: 'en', |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
102 | width: 180, |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
103 | height: 23, |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
104 | autoDropDownHeight: true |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
105 | }); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
106 | $('#dev_gpiopin').jqxNumberInput(GPIOInt); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
107 | $('#dev_inuse').jqxNumberInput(Show0dec); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
108 | $('#dev_timestamp').jqxInput({ theme: theme, width: 200, height: 23 }); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
109 | $('#dev_comment').jqxInput({ theme: theme, width: 800, height: 23 }); |
685 | 110 | |
111 | // initialize jqxGrid | |
112 | $('#jqxgrid').jqxGrid({ | |
113 | width: 1280, | |
114 | height: 630, | |
115 | source: dataAdapter, | |
116 | theme: theme, | |
686
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
117 | showstatusbar: true, |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
118 | renderstatusbar: function(statusbar) { |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
119 | var rowCount = $("#jqxgrid").jqxGrid('getrows').length; |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
120 | 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
|
121 | var container, addButton, impButton; |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
122 | 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
|
123 | 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
|
124 | '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
|
125 | container.append(addButton); |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
126 | statusbar.append(container); |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
127 | 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
|
128 | // add new row. |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
129 | addButton.click(function(event) { |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
130 | editrow = -1; |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
131 | $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } }); |
689
f94b525f7563
Create global_json() for all and expanded the data to the complete setup. Added design for the global setup.
Michiel Broek <mbroek@mbse.eu>
parents:
687
diff
changeset
|
132 | $('#dev_uuid').val(''); |
f94b525f7563
Create global_json() for all and expanded the data to the complete setup. Added design for the global setup.
Michiel Broek <mbroek@mbse.eu>
parents:
687
diff
changeset
|
133 | $('#dev_description').val(''); |
f94b525f7563
Create global_json() for all and expanded the data to the complete setup. Added design for the global setup.
Michiel Broek <mbroek@mbse.eu>
parents:
687
diff
changeset
|
134 | $('#dev_type').val('NA'); |
f94b525f7563
Create global_json() for all and expanded the data to the complete setup. Added design for the global setup.
Michiel Broek <mbroek@mbse.eu>
parents:
687
diff
changeset
|
135 | $('#dev_direction').val('UNDEF'); |
f94b525f7563
Create global_json() for all and expanded the data to the complete setup. Added design for the global setup.
Michiel Broek <mbroek@mbse.eu>
parents:
687
diff
changeset
|
136 | $('#dev_value').val(0); |
f94b525f7563
Create global_json() for all and expanded the data to the complete setup. Added design for the global setup.
Michiel Broek <mbroek@mbse.eu>
parents:
687
diff
changeset
|
137 | $('#dev_offset').val(0); |
f94b525f7563
Create global_json() for all and expanded the data to the complete setup. Added design for the global setup.
Michiel Broek <mbroek@mbse.eu>
parents:
687
diff
changeset
|
138 | $('#dev_address').val(''); |
f94b525f7563
Create global_json() for all and expanded the data to the complete setup. Added design for the global setup.
Michiel Broek <mbroek@mbse.eu>
parents:
687
diff
changeset
|
139 | $('#dev_subdevice').val(0); |
f94b525f7563
Create global_json() for all and expanded the data to the complete setup. Added design for the global setup.
Michiel Broek <mbroek@mbse.eu>
parents:
687
diff
changeset
|
140 | $('#dev_present').val('UNDEF'); |
f94b525f7563
Create global_json() for all and expanded the data to the complete setup. Added design for the global setup.
Michiel Broek <mbroek@mbse.eu>
parents:
687
diff
changeset
|
141 | $('#dev_gpiopin').val(-1); |
f94b525f7563
Create global_json() for all and expanded the data to the complete setup. Added design for the global setup.
Michiel Broek <mbroek@mbse.eu>
parents:
687
diff
changeset
|
142 | $('#dev_inuse').val(0); |
f94b525f7563
Create global_json() for all and expanded the data to the complete setup. Added design for the global setup.
Michiel Broek <mbroek@mbse.eu>
parents:
687
diff
changeset
|
143 | var now = new Date(); |
f94b525f7563
Create global_json() for all and expanded the data to the complete setup. Added design for the global setup.
Michiel Broek <mbroek@mbse.eu>
parents:
687
diff
changeset
|
144 | var date = new Date(now - tzoffset).toISOString().slice(0, 19).replace("T", " "); |
f94b525f7563
Create global_json() for all and expanded the data to the complete setup. Added design for the global setup.
Michiel Broek <mbroek@mbse.eu>
parents:
687
diff
changeset
|
145 | $('#dev_timestamp').val(date); |
f94b525f7563
Create global_json() for all and expanded the data to the complete setup. Added design for the global setup.
Michiel Broek <mbroek@mbse.eu>
parents:
687
diff
changeset
|
146 | $('#dev_comment').val(''); |
686
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
147 | |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
148 | $('#popupWindow').jqxWindow('open'); |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
149 | }); |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
150 | }, |
685 | 151 | columns: [ |
152 | { text: 'Address', datafield: 'address', width: 200 }, | |
153 | { text: 'Subdevice', datafield: 'subdevice', width: 100 }, | |
154 | { text: 'Direction', datafield: 'direction', width: 120 }, | |
155 | { text: 'Value', datafield: 'value', width: 80 }, | |
156 | { text: 'Description', datafield: 'description' }, | |
157 | { text: 'Last change', datafield: 'timestamp', width: 200, | |
158 | cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { | |
687
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
159 | var date = new Date((value * 1000) - tzoffset).toISOString().slice(0, 19).replace("T", " "); |
685 | 160 | return '<span style="margin: 3px; margin-top: 6px; float: left;">' + date + '</span>'; |
161 | } | |
162 | }, | |
163 | { 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
|
164 | return 'Edit'; |
685 | 165 | }, buttonclick: function(row) { |
686
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
166 | // 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
|
167 | editrow = row; |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
168 | $('#popupWindow').jqxWindow({ position: { x: 110, y: 15 } }); |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
169 | dataRecord = $('#jqxgrid').jqxGrid('getrowdata', editrow); |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
170 | $('#dev_uuid').val(dataRecord.uuid); |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
171 | $('#dev_description').val(dataRecord.description); |
687
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
172 | $('#dev_type').val(dataRecord.type); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
173 | $('#dev_direction').val(dataRecord.direction); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
174 | $('#dev_value').val(dataRecord.value); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
175 | $('#dev_offset').val(dataRecord.offset); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
176 | $('#dev_address').val(dataRecord.address); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
177 | $('#dev_subdevice').val(dataRecord.subdevice); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
178 | $('#dev_present').val(dataRecord.present); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
179 | $('#dev_gpiopin').val(dataRecord.gpiopin); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
180 | $('#dev_inuse').val(dataRecord.inuse); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
181 | 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
|
182 | $('#dev_timestamp').val(date); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
183 | $('#dev_comment').val(dataRecord.comment); |
686
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
184 | // show the popup window. |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
185 | $('#popupWindow').jqxWindow('open'); |
685 | 186 | } |
187 | } | |
188 | ], | |
189 | }); | |
190 | ||
686
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
191 | // initialize the popup window and buttons. |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
192 | $('#popupWindow').jqxWindow({ |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
193 | width: 1050, |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
194 | height: 625, |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
195 | resizable: false, |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
196 | theme: theme, |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
197 | isModal: true, |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
198 | autoOpen: false, |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
199 | cancelButton: $('#Cancel'), |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
200 | modalOpacity: 0.40 |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
201 | }); |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
202 | $('#popupWindow').on('open', function() { |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
203 | $('#dev_description').jqxInput('selectAll'); |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
204 | }); |
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
205 | $('#Delete').jqxButton({ template: 'danger', width: '90px', theme: theme }); |
687
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
206 | $('#Delete').click(function() { |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
207 | if (editrow >= 0) { |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
208 | // Open a popup to confirm this action. |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
209 | $('#eventWindow').jqxWindow('open'); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
210 | $('#delOk').click(function() { |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
211 | var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
212 | $('#jqxgrid').jqxGrid('deleterow', rowID); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
213 | }); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
214 | } |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
215 | $('#popupWindow').jqxWindow('hide'); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
216 | }); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
217 | $('#Cancel').jqxButton({ template: 'primary', width: '90px', theme: theme }); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
218 | $('#Save').jqxButton({ template: 'success', width: '90px', theme: theme }); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
219 | $('#Save').click(function() { |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
220 | var row, rowID = -1; |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
221 | if (editrow >= 0) { |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
222 | rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
223 | } |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
224 | row = { |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
225 | uuid: dataRecord.uuid, |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
226 | type: $('#type').val() |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
227 | }; |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
228 | if (editrow >= 0) { |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
229 | $('#jqxgrid').jqxGrid('updaterow', rowID, row); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
230 | } else { |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
231 | $('#jqxgrid').jqxGrid('addrow', null, row); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
232 | } |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
233 | $('#popupWindow').jqxWindow('hide'); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
234 | }); |
f5d05b420732
Devices edit popup layout ready.
Michiel Broek <mbroek@mbse.eu>
parents:
686
diff
changeset
|
235 | createDelElements(); |
686
372b2442a30f
More work for devices list and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
685
diff
changeset
|
236 | |
685 | 237 | websocket.onmessage = function(evt) { |
238 | var msg = evt.data; | |
239 | var obj = JSON.parse(msg); | |
240 | ||
241 | if (obj.ping) { | |
242 | websocket.send('{"pong":' + obj.ping + '}'); | |
243 | } | |
244 | ||
245 | if (obj.type == 'device') { | |
246 | // Use the message to trigger update. | |
247 | $('#jqxgrid').jqxGrid('updatebounddata'); | |
248 | } | |
249 | } | |
250 | }); |