# HG changeset patch # User Michiel Broek # Date 1713894605 -7200 # Node ID 942af738157cd1d29709a0462fd85914f76005dc # Parent 35382668a14086f24b358279978555613627ef0d Added device delete diff -r 35382668a140 -r 942af738157c www/getdevices.php --- a/www/getdevices.php Tue Apr 23 16:52:13 2024 +0200 +++ b/www/getdevices.php Tue Apr 23 19:50:05 2024 +0200 @@ -68,6 +68,14 @@ } else if (isset($_POST['del'])) { + $answer = send_cmd("DEVICE DEL " . $_POST['uuid']); + $arr = explode("\r\n", $answer); + if (! startsWith($arr[0], "211")) { + $response['error'] = true; + $response['msg'] = $arr[0]; + } + exit(json_encode($response)); + } else { $answer = send_cmd("DEVICE JSON"); diff -r 35382668a140 -r 942af738157c www/js/set_devices.js --- a/www/js/set_devices.js Tue Apr 23 16:52:13 2024 +0200 +++ b/www/js/set_devices.js Tue Apr 23 19:50:05 2024 +0200 @@ -187,6 +187,7 @@ error: function(jqXHR, textStatus, errorThrown) { } }); + $('#jqxgrid').jqxGrid('updatebounddata'); } else { console.log('Add wrong type'); } @@ -195,7 +196,8 @@ }, columns: [ { text: 'Address', datafield: 'address', width: 200 }, - { text: 'Subdevice', datafield: 'subdevice', width: 100 }, + { text: 'Sub', datafield: 'subdevice', width: 60 }, + { text: 'Type', datafield: 'type', width: 100 }, { text: 'Direction', datafield: 'direction', width: 120 }, { text: 'Value', datafield: 'value', width: 80 }, { text: 'Description', datafield: 'description' }, @@ -253,8 +255,29 @@ // Open a popup to confirm this action. $('#eventWindow').jqxWindow('open'); $('#delOk').click(function() { - var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); - $('#jqxgrid').jqxGrid('deleterow', rowID); + console.log('Del ' + $('#dev_uuid').val()); + var data, + data = 'del=true&uuid=' + $('#dev_uuid').val(); + console.log(data); + $.ajax({ + dataType: 'json', + url: url, + cache: false, + data: data, + type: 'POST', + success: function(data) { + if (data.error) { + console.log('del: ' + data.msg); + alert('Error: ' + data.msg); + } else { + console.log('del: success'); + } + }, + error: function(jqXHR, textStatus, errorThrown) {} + }); + $('#jqxgrid').jqxGrid('updatebounddata'); +// var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); +// $('#jqxgrid').jqxGrid('deleterow', rowID); }); } $('#popupWindow').jqxWindow('hide');