--- a/www/js/set_simulators.js Wed May 01 14:38:37 2024 +0200 +++ b/www/js/set_simulators.js Thu May 02 15:49:16 2024 +0200 @@ -110,6 +110,12 @@ { name: 'light_address', map: 'light>address' }, { name: 'light_present', map: 'light>present' }, { name: 'light_power', map: 'light>power', type: 'int' }, + { name: 'door_address', map: 'door>address' }, + { name: 'door_present', map: 'door>present' }, + { name: 'door_value', map: 'door>value', type: 'int' }, + { name: 'psu_address', map: 'psu>address' }, + { name: 'psu_present', map: 'psu>present' }, + { name: 'psu_value', map: 'psu>value', type: 'int' }, { name: 'frigo_isolation', type: 'float' }, { name: 'timestamp', type: 'int' } ], @@ -121,7 +127,7 @@ tzoffset = (new Date()).getTimezoneOffset() * 60000; //offset in milliseconds // initialize the input fields. - $('#name').jqxInput({ theme: theme, width: 180, height: 23 }); + $('#name').jqxInput({ theme: theme, width: 240, height: 23 }); $('#simno').jqxNumberInput(Show0dec); $('#uuid').jqxInput({ theme: theme, width: 360, height: 23 }); $('#room_temperature,#room_humidity').jqxNumberInput(Perc1dec); @@ -129,9 +135,9 @@ $('#frigo_isolation').jqxNumberInput(Spin3dec); $('#timestamp').jqxInput({ theme: theme, width: 180, height: 23 }); - $('#air_address,#beer_address,#beer_address2,#chiller_address,#cooler_address,#heater_address,#fan_address,#light_address').jqxInput({ theme: theme, width: 180, height: 23 }); + $('#air_address,#beer_address,#beer_address2,#chiller_address,#cooler_address,#heater_address,#fan_address,#light_address,#door_address,#psu_address').jqxInput({ theme: theme, width: 180, height: 23 }); $('#air_temperature,#beer_temperature,#beer_temperature2,#chiller_temperature').jqxNumberInput(Show4dec); - $('#air_present,#beer_present,#beer_present2,#chiller_present,#cooler_present,#heater_present,#fan_present,#light_present').jqxDropDownList({ + $('#air_present,#beer_present,#beer_present2,#chiller_present,#cooler_present,#heater_present,#fan_present,#light_present,#door_present,#psu_present').jqxDropDownList({ theme: theme, source: DevicePresentAdapter, valueMember: 'mno', @@ -144,6 +150,8 @@ $('#cooler_temp,#heater_temp').jqxNumberInput(Spin1dec); $('#cooler_time,#heater_time').jqxNumberInput(PosInt); $('#cooler_size,#heater_size').jqxNumberInput(Spin4dec); + $('#door_value').jqxSwitchButton({ height: 23, width: 100, theme: theme }); + $('#psu_value').jqxSwitchButton({ height: 23, width: 100, theme: theme }); // initialize jqxGrid $('#jqxgrid').jqxGrid({ @@ -250,6 +258,12 @@ $('#light_address').val(dataRecord.light_address); $('#light_power').val(dataRecord.light_power); $('#light_present').val(dataRecord.light_present); + $('#door_address').val(dataRecord.door_address); + $('#door_value').val(dataRecord.door_value); + $('#door_present').val(dataRecord.door_present); + $('#psu_address').val(dataRecord.psu_address); + $('#psu_value').val(dataRecord.psu_value); + $('#psu_present').val(dataRecord.psu_present); var date = new Date((dataRecord.timestamp * 1000) - tzoffset).toISOString().slice(0, 19).replace("T", " "); $('#timestamp').val(date); // show the popup window. @@ -275,31 +289,29 @@ }); $('#Delete').jqxButton({ template: 'danger', width: '90px', theme: theme }); $('#Delete').click(function() { - if (editrow >= 0) { - // Open a popup to confirm this action. - $('#eventWindow').jqxWindow('open'); - $('#delOk').click(function() { - var data, - data = 'del=true&uuid=' + $('#dev_uuid').val(); - $.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'); + // Open a popup to confirm this action. + $('#eventWindow').jqxWindow('open'); + $('#delOk').click(function() { + var data, + data = 'del=true&uuid=' + $('#uuid').val(); + $.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'); + }); $('#popupWindow').jqxWindow('hide'); }); $('#Cancel').jqxButton({ template: 'primary', width: '90px', theme: theme }); @@ -331,6 +343,10 @@ fan_power: parseInt($('#fan_power').jqxNumberInput('decimal')), light_present: $('#light_present').val(), light_power: parseInt($('#light_power').jqxNumberInput('decimal')), + door_present: $('#door_present').val(), + door_value: $('#door_value').val(), + psu_present: $('#psu_present').val(), + psu_value: $('#psu_value').val(), frigo_isolation: parseFloat($('#frigo_isolation').jqxNumberInput('decimal')) }; data = 'update=true&' + $.param(row);