www/js/set_devices.js

changeset 701
e50a5003c7ac
parent 700
942af738157c
child 703
344470c6bb1c
equal deleted inserted replaced
700:942af738157c 701:e50a5003c7ac
253 $('#Delete').click(function() { 253 $('#Delete').click(function() {
254 if (editrow >= 0) { 254 if (editrow >= 0) {
255 // Open a popup to confirm this action. 255 // Open a popup to confirm this action.
256 $('#eventWindow').jqxWindow('open'); 256 $('#eventWindow').jqxWindow('open');
257 $('#delOk').click(function() { 257 $('#delOk').click(function() {
258 console.log('Del ' + $('#dev_uuid').val());
259 var data, 258 var data,
260 data = 'del=true&uuid=' + $('#dev_uuid').val(); 259 data = 'del=true&uuid=' + $('#dev_uuid').val();
261 console.log(data);
262 $.ajax({ 260 $.ajax({
263 dataType: 'json', 261 dataType: 'json',
264 url: url, 262 url: url,
265 cache: false, 263 cache: false,
266 data: data, 264 data: data,
274 } 272 }
275 }, 273 },
276 error: function(jqXHR, textStatus, errorThrown) {} 274 error: function(jqXHR, textStatus, errorThrown) {}
277 }); 275 });
278 $('#jqxgrid').jqxGrid('updatebounddata'); 276 $('#jqxgrid').jqxGrid('updatebounddata');
279 // var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
280 // $('#jqxgrid').jqxGrid('deleterow', rowID);
281 }); 277 });
282 } 278 }
283 $('#popupWindow').jqxWindow('hide'); 279 $('#popupWindow').jqxWindow('hide');
284 }); 280 });
285 $('#Cancel').jqxButton({ template: 'primary', width: '90px', theme: theme }); 281 $('#Cancel').jqxButton({ template: 'primary', width: '90px', theme: theme });
286 $('#Save').jqxButton({ template: 'success', width: '90px', theme: theme }); 282 $('#Save').jqxButton({ template: 'success', width: '90px', theme: theme });
287 $('#Save').click(function() { 283 $('#Save').click(function() {
288 var row, rowID = -1; 284 var data,
289 if (editrow >= 0) {
290 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
291 }
292 row = { 285 row = {
293 uuid: dataRecord.uuid, 286 uuid: dataRecord.uuid,
294 type: $('#type').val() 287 type: $('#dev_type').val(),
288 direction: $('#dev_direction').val(),
289 value: parseInt($('#dev_value').jqxNumberInput('decimal')),
290 offset: parseInt($('#dev_offset').jqxNumberInput('decimal')),
291 present: $('#dev_present').val(),
292 address: $('#dev_address').val(),
293 subdevice: parseInt($('#dev_subdevice').jqxNumberInput('decimal')),
294 gpiopin: parseInt($('#dev_gpiopin').jqxNumberInput('val')),
295 description: $('#dev_description').val(),
296 comment: $('#dev_comment').val()
295 }; 297 };
296 if (editrow >= 0) { 298 data = 'update=true&' + $.param(row);
297 $('#jqxgrid').jqxGrid('updaterow', rowID, row); 299 console.log(data);
298 } else { 300 $.ajax({
299 $('#jqxgrid').jqxGrid('addrow', null, row); 301 dataType: 'json',
300 } 302 url: url,
303 cache: false,
304 data: data,
305 type: 'POST',
306 success: function(data) {
307 if (data.error) {
308 console.log('update: ' + data.msg);
309 alert('Error: ' + data.msg);
310 } else {
311 console.log('update: success');
312 }
313 },
314 error: function(jqXHR, textStatus, errorThrown) {}
315 });
301 $('#popupWindow').jqxWindow('hide'); 316 $('#popupWindow').jqxWindow('hide');
302 }); 317 });
303 createDelElements(); 318 createDelElements();
304 createAddElements(); 319 createAddElements();
305 320

mercurial