Get config panel working for nutups
This commit is contained in:
parent
51a59b9696
commit
e717237726
@ -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;
|
@ -85,16 +85,16 @@
|
||||
<p><span class=label>
|
||||
%=l('nut_UPS_Model')
|
||||
</span><span class=data>
|
||||
% 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'
|
||||
<br></span> </p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('nut_UPS_Device')
|
||||
</span><span class=data>
|
||||
% 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)'
|
||||
<br></span></p>
|
||||
|
||||
<div class=generics>
|
||||
@ -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'
|
||||
<br></span></p>
|
||||
|
||||
</div>
|
||||
|
||||
<span class='data'>
|
||||
%= submit_button l('nut_Save'), class => 'action subm12'
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
%# Probably finally by a submit.
|
||||
|
@ -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();
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user