diff --git a/Targets/Nutups/Nutups-Custom.pm b/Targets/Nutups/Nutups-Custom.pm index 00f5bfe..090d007 100644 --- a/Targets/Nutups/Nutups-Custom.pm +++ b/Targets/Nutups/Nutups-Custom.pm @@ -180,8 +180,22 @@ sub create_link{ return $link; } -sub get_model_options{ - return []; -} +sub get_model_options { + # Execute the RPM command and capture the output + my @output = qx{rpm -ql nut | grep /usr/sbin}; + + # Check for errors + if ($? != 0) { + warn "Error executing command: $!"; + return ['Error occurred']; + } + + # Remove "/usr/sbin" from the front of each line + s{^/usr/sbin}{} for @output; + + # Trim whitespace from each element and return the array + chomp(@output); # Remove newline characters from each line + return ["fred","Art"] #@output; # Return the array of modified output lines +} 1; \ No newline at end of file diff --git a/Targets/Nutups/_nut_CONFIG.html.ep b/Targets/Nutups/_nut_CONFIG.html.ep index ea0b580..b84e179 100644 --- a/Targets/Nutups/_nut_CONFIG.html.ep +++ b/Targets/Nutups/_nut_CONFIG.html.ep @@ -85,16 +85,16 @@

%=l('nut_UPS_Model') - % my @UPS_Model_options = ; + % my @UPS_Model_options = $c->get_model_options(); % param 'UPS_Model' => $nut_data->{UPS_Model} unless param 'UPS_Model'; - %= select_field 'UPS_Model' => @UPS_Model_options, class => 'input', id => 'UPS_Model_select' + %= select_field 'UPS_Model' => \@UPS_Model_options, class => 'input', id => 'UPS_Model_select'

%=l('nut_UPS_Device') % param 'UPS_Device' => $nut_data->{UPS_Device} unless param 'UPS_Device'; - %= text_field 'UPS_Device', size => '50', class => 'textinput UPS_Device' , pattern=>'.*' , placeholder=>'UPS_Device' + %= text_field 'UPS_Device', size => '50', class => 'textinput UPS_Device' , pattern=>'.*' , placeholder=>'auto (for usb)'

@@ -122,12 +122,13 @@ % param 'UPS_gen_Model' => $nut_data->{UPS_gen_Model} unless param 'UPS_gen_Model'; %= text_field 'UPS_gen_Model', size => '50', class => 'textinput UPS_gen_Model' , pattern=>'.*' , placeholder=>'UPS_gen_Model'

- +
+ %= submit_button l('nut_Save'), class => 'action subm12' - + %# Probably finally by a submit. diff --git a/Targets/Nutups/nutups.js b/Targets/Nutups/nutups.js index d5d9390..7721de1 100644 --- a/Targets/Nutups/nutups.js +++ b/Targets/Nutups/nutups.js @@ -1,7 +1,4 @@ -// -//Generated by: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-01-20 16:09:58 -// -$(document).ready(function() { + $(document).ready(function() { function toggleUPSClasses() { var selectedOption = $('#Nutmode_select').val(); $('.masterups').toggle(selectedOption === 'netclient'); // Show/Hide masterups based on Net Client @@ -12,9 +9,20 @@ $(document).ready(function() { $('.slaveups input').prop('disabled', selectedOption !== 'netserver'); } - // Event listener for the select change - $('#Nutmode_select').change(toggleUPSClasses); + function toggleGenerics() { + var upsModelValue = $('#UPS_Model_select').val().toLowerCase(); // Get the current value from UPS_Model + var isGenericUps = upsModelValue === 'genericups'; // Check if it's 'genericups' - // Set the initial state + // Show/Hide generics section and enable/disable inputs + $('.generics').toggle(isGenericUps); + $('.generics input').prop('disabled', !isGenericUps); // Enable/Disable inputs based on the value + } + + // Event listener for the selections + $('#Nutmode_select').change(toggleUPSClasses); + $('#UPS_Model_select').change(toggleGenerics); // Listen for changes in the UPS_Model dropdown + + // Set the initial state based on current selections + toggleGenerics(); toggleUPSClasses(); -}); \ No newline at end of file + }); \ No newline at end of file