34 { name: 'os' }, |
35 { name: 'os' }, |
35 { name: 'os_version' }, |
36 { name: 'os_version' }, |
36 { name: 'FW' }, |
37 { name: 'FW' }, |
37 { name: 'server_port', type: 'int' }, |
38 { name: 'server_port', type: 'int' }, |
38 { name: 'websocket_port', type: 'int' }, |
39 { name: 'websocket_port', type: 'int' }, |
|
40 { name: 'nextunit', type: 'int' }, |
39 { name: 'thb_temp_uuid', map: 'THB>temperature>uuid' }, |
41 { name: 'thb_temp_uuid', map: 'THB>temperature>uuid' }, |
40 { name: 'temp_uuid', map: 'THB>temperature>uuid' }, |
42 { name: 'temp_uuid', map: 'THB>temperature>uuid' }, |
41 { name: 'temp_state', map: 'THB>temperature>state' }, |
43 { name: 'temp_state', map: 'THB>temperature>state' }, |
42 { name: 'temp_value', map: 'THB>temperature>value', type: 'int' }, |
44 { name: 'temp_value', map: 'THB>temperature>value', type: 'int' }, |
43 { name: 'hum_uuid', map: 'THB>humidity>uuid' }, |
45 { name: 'hum_uuid', map: 'THB>humidity>uuid' }, |
47 { name: 'lcd_address', map: 'LCD>address' }, |
49 { name: 'lcd_address', map: 'LCD>address' }, |
48 { name: 'lcd_cols', map: 'LCD>cols', type: 'int' }, |
50 { name: 'lcd_cols', map: 'LCD>cols', type: 'int' }, |
49 { name: 'lcd_rows', map: 'LCD>rows', type: 'int' }, |
51 { name: 'lcd_rows', map: 'LCD>rows', type: 'int' }, |
50 { name: 'mqtt_host', map: 'MQTT>host' }, |
52 { name: 'mqtt_host', map: 'MQTT>host' }, |
51 { name: 'mqtt_port', map: 'MQTT>port', type: 'int' }, |
53 { name: 'mqtt_port', map: 'MQTT>port', type: 'int' }, |
52 { name: 'mqtt_username', map: 'MQTT_username' }, |
54 { name: 'mqtt_username', map: 'MQTT>username' }, |
53 { name: 'mqtt_password', map: 'MQTT_password' } |
55 { name: 'mqtt_password', map: 'MQTT>password' } |
54 ], |
56 ], |
55 id: 'name', |
57 id: 'name', |
56 url: 'getglobal.php' |
58 url: url |
57 }, |
59 }, |
58 globalData = new $.jqx.dataAdapter(globalSource, { |
60 globalData = new $.jqx.dataAdapter(globalSource, { |
59 loadComplete: function(records) { |
61 loadComplete: function(records) { |
60 global = globalData.records[0]; |
62 global = globalData.records[0]; |
61 updateScreen(); |
63 $('#name').val(global.name); |
|
64 $('#uuid').val(global.uuid); |
|
65 $('#node').val(global.node); |
|
66 $('#os').val(global.os + ' ' + global.os_version); |
|
67 $('#FW').val(global.FW); |
|
68 $('#server_port').val(global.server_port); |
|
69 $('#websocket_port').val(global.websocket_port); |
|
70 $('#nextunit').val(global.nextunit); |
|
71 $('#temp_uuid').val(global.temp_uuid); |
|
72 $('#temp_state').val(global.temp_state); |
|
73 $('#temp_value').val(global.temp_value / 1000.0); |
|
74 $('#hum_uuid').val(global.hum_uuid); |
|
75 $('#hum_state').val(global.hum_state); |
|
76 $('#hum_value').val(global.hum_value / 1000.0); |
|
77 $('#temp_hum_idx').val(global.temp_hum_idx); |
|
78 $('#lcd_address').val(global.lcd_address); |
|
79 $('#lcd_cols').val(global.lcd_cols); |
|
80 $('#lcd_rows').val(global.lcd_rows) |
|
81 $('#mqtt_host').val(global.mqtt_host); |
|
82 $('#mqtt_port').val(global.mqtt_port); |
|
83 $('#mqtt_username').val(global.mqtt_username); |
|
84 $('#mqtt_password').val(global.mqtt_password); |
62 } |
85 } |
63 }), |
86 }); |
64 tzoffset = (new Date()).getTimezoneOffset() * 60000; //offset in milliseconds |
|
65 |
|
66 function updateScreen() { |
|
67 $('#name').val(global.name); |
|
68 $('#uuid').val(global.uuid); |
|
69 $('#node').val(global.node); |
|
70 $('#os').val(global.os + ' ' + global.os_version); |
|
71 $('#FW').val(global.FW); |
|
72 $('#server_port').val(global.server_port); |
|
73 $('#websocket_port').val(global.websocket_port); |
|
74 $('#temp_uuid').val(global.temp_uuid); |
|
75 $('#temp_state').val(global.temp_state); |
|
76 $('#temp_value').val(global.temp_value / 1000.0); |
|
77 $('#hum_uuid').val(global.hum_uuid); |
|
78 $('#hum_state').val(global.hum_state); |
|
79 $('#hum_value').val(global.hum_value / 1000.0); |
|
80 $('#temp_hum_idx').val(global.temp_hum_idx); |
|
81 $('#lcd_address').val(global.lcd_address); |
|
82 $('#lcd_cols').val(global.lcd_cols); |
|
83 $('#lcd_rows').val(global.lcd_rows) |
|
84 $('#mqtt_host').val(global.mqtt_host); |
|
85 $('#mqtt_port').val(global.mqtt_port); |
|
86 $('#mqtt_username').val(global.mqtt_username); |
|
87 $('#mqtt_password').val(global.mqtt_password); |
|
88 } |
|
89 |
87 |
90 // initialize the input fields. |
88 // initialize the input fields. |
91 $('#name').jqxInput({ theme: theme, width: 240, height: 23 }); |
89 $('#name').jqxInput({ theme: theme, width: 240, height: 23 }); |
92 $('#uuid').jqxInput({ theme: theme, width: 480, height: 23 }); |
90 $('#uuid').jqxInput({ theme: theme, width: 360, height: 23 }); |
93 $('#node').jqxInput({ theme: theme, width: 240, height: 23 }); |
91 $('#node').jqxInput({ theme: theme, width: 240, height: 23 }); |
94 $('#os').jqxInput({ theme: theme, width: 240, height: 23 }); |
92 $('#os').jqxInput({ theme: theme, width: 240, height: 23 }); |
95 $('#FW').jqxInput({ theme: theme, width: 120, height: 23 }); |
93 $('#FW').jqxInput({ theme: theme, width: 120, height: 23 }); |
96 $('#server_port').jqxNumberInput(Spin0dec); |
94 $('#server_port').jqxNumberInput(Show0dec); |
97 $('#websocket_port').jqxNumberInput(Spin0dec); |
95 $('#websocket_port').jqxNumberInput(Show0dec); |
|
96 $('#nextunit').jqxNumberInput(Show0dec); |
98 $('#temp_uuid').jqxDropDownList({ |
97 $('#temp_uuid').jqxDropDownList({ |
99 theme: theme, |
98 theme: theme, |
100 source: tempsensorlist, |
99 source: tempsensorlist, |
101 valueMember: 'uuid', |
100 valueMember: 'uuid', |
102 displayMember: 'name', |
101 displayMember: 'name', |
116 autoDropDownHeight: true |
115 autoDropDownHeight: true |
117 }); |
116 }); |
118 $('#hum_state').jqxInput({ theme: theme, width: 120, height: 23 }); |
117 $('#hum_state').jqxInput({ theme: theme, width: 120, height: 23 }); |
119 $('#hum_value').jqxNumberInput(Show1dec); |
118 $('#hum_value').jqxNumberInput(Show1dec); |
120 $('#temp_hum_idx').jqxNumberInput(Spin0dec); |
119 $('#temp_hum_idx').jqxNumberInput(Spin0dec); |
121 |
|
122 $('#lcd_address').jqxNumberInput(Spin0dec); |
120 $('#lcd_address').jqxNumberInput(Spin0dec); |
123 $('#lcd_cols').jqxNumberInput(GPIOInt); |
121 $('#lcd_cols').jqxNumberInput(GPIOInt); |
124 $('#lcd_rows').jqxNumberInput(GPIOInt); |
122 $('#lcd_rows').jqxNumberInput(GPIOInt); |
125 |
|
126 $('#mqtt_host').jqxInput({ theme: theme, width: 240, height: 23 }); |
123 $('#mqtt_host').jqxInput({ theme: theme, width: 240, height: 23 }); |
127 $('#mqtt_port').jqxNumberInput(Spin0dec); |
124 $('#mqtt_port').jqxNumberInput(Spin0dec); |
128 $('#mqtt_username').jqxInput({ theme: theme, width: 240, height: 23 }); |
125 $('#mqtt_username').jqxInput({ theme: theme, width: 240, height: 23 }); |
129 $('#mqtt_password').jqxInput({ theme: theme, width: 240, height: 23 }); |
126 $('#mqtt_password').jqxPasswordInput({ placeHolder: "Enter Password", showPasswordIcon: true, theme: theme, width: 240, height: 23 }); |
130 |
127 |
131 globalData.dataBind(); |
128 globalData.dataBind(); |
132 |
129 |
133 |
130 |
134 $('#Save').jqxButton({ template: 'success', width: '90px', theme: theme }); |
131 $('#Save').jqxButton({ template: 'success', width: '90px', theme: theme }); |
135 $('#Save').click(function() { |
132 $('#Save').click(function() { |
136 var row, rowID = -1; |
133 var data, |
137 if (editrow >= 0) { |
|
138 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
|
139 } |
|
140 row = { |
134 row = { |
141 uuid: dataRecord.uuid, |
135 name: $('#name').val(), |
142 type: $('#type').val() |
136 port: parseInt($('#server_port').jqxNumberInput('decimal')), |
|
137 temp_uuid: $('#temp_uuid').val(), |
|
138 hum_uuid: $('#hum_uuid').val(), |
|
139 temp_hum_idx: $('#temp_hum_idx').val(), |
|
140 lcd_address: parseInt($('#lcd_address').jqxNumberInput('decimal')), |
|
141 lcd_cols: parseInt($('#lcd_cols').jqxNumberInput('decimal')), |
|
142 lcd_rows: parseInt($('#lcd_rows').jqxNumberInput('decimal')), |
|
143 mqtt_host: $('#mqtt_host').val(), |
|
144 mqtt_port: parseInt($('#mqtt_port').jqxNumberInput('decimal')), |
|
145 mqtt_user: $('#mqtt_username').val(), |
|
146 mqtt_pass: $('#mqtt_password').val(), |
|
147 websocket_port: parseInt($('#websocket_port').jqxNumberInput('decimal')) |
143 }; |
148 }; |
144 // $('#jqxgrid').jqxGrid('updaterow', rowID, row); |
149 data = 'update=true&' + $.param(row); |
|
150 $.ajax({ |
|
151 dataType: 'json', |
|
152 url: url, |
|
153 cache: false, |
|
154 data: data, |
|
155 type: 'POST', |
|
156 success: function(data) { |
|
157 if (data.error) { |
|
158 console.log('update: ' + data.msg); |
|
159 alert('Fout: ' + data.msg); |
|
160 } else { |
|
161 console.log('update: success'); |
|
162 } |
|
163 }, |
|
164 error: function(jqXHR, textStatus, errorThrown) { |
|
165 } |
|
166 }); |
145 }); |
167 }); |
146 |
168 |
147 websocket.onmessage = function(evt) { |
169 websocket.onmessage = function(evt) { |
148 var msg = evt.data; |
170 var msg = evt.data; |
149 var obj = JSON.parse(msg); |
171 var obj = JSON.parse(msg); |