* Mon Mar 03 2025 Brian Read <brianr@koozali.org> 11.0.0-6.sme
- Add in SM2 NutUPS configuration and status panel [SME: 12949]
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
.ups-status-page {
|
||||
font-family: Arial, sans-serif;
|
||||
line-height: 1.6;
|
||||
color: #333;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.ups-status-page h1 {
|
||||
color: #2c3e50;
|
||||
}
|
||||
|
||||
.ups-status-page .grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.ups-status-page .card {
|
||||
background: #f9f9f9;
|
||||
border-radius: 5px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.ups-status-page h2 {
|
||||
color: #3498db;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.ups-status-page table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.ups-status-page td {
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.ups-status-page td:first-child {
|
||||
font-weight: bold;
|
||||
}
|
69
root/usr/share/smanager/themes/default/public/css/nutups.css
Normal file
69
root/usr/share/smanager/themes/default/public/css/nutups.css
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
Generated by: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-01-20 16:09:58
|
||||
*/
|
||||
.Nutups-panel {}
|
||||
.name {}
|
||||
.rout {}
|
||||
.grou1 {}
|
||||
.link1 {}
|
||||
.endg1 {}
|
||||
.subh1 {}
|
||||
.para1 {}
|
||||
.text1 {}
|
||||
.name {}
|
||||
.rout {}
|
||||
.subh2 {}
|
||||
.sele1 {}
|
||||
.sele2 {}
|
||||
.grou2 {}
|
||||
.subh3 {}
|
||||
.text3 {}
|
||||
.pass4 {}
|
||||
.endg2 {}
|
||||
.grou3 {}
|
||||
.subh4 {}
|
||||
.text5 {}
|
||||
.pass6 {}
|
||||
.endg3 {}
|
||||
.text7 {}
|
||||
.text8 {}
|
||||
.subh5 {}
|
||||
.text9 {}
|
||||
.text10 {}
|
||||
.text11 {}
|
||||
.subm12 {}
|
||||
.inline-buttons {
|
||||
display: flex; /* Use flexbox to arrange items horizontally */
|
||||
gap: 10px; /* Optional: Add space between buttons */
|
||||
}
|
||||
|
||||
.inline-buttons .link {
|
||||
/* Additional styling can be added here if needed */
|
||||
}
|
||||
|
||||
|
||||
.inline-buttons .link {
|
||||
display: inline-block; /* Keep links as inline-block for button shape */
|
||||
padding: 7px 14px; /* Adjusted padding to approximate 70% of the original */
|
||||
margin: 0; /* Remove margin */
|
||||
background-color: #efefef; /* Light gray background color */
|
||||
color: black; /* Text color */
|
||||
text-decoration: none; /* Remove underline */
|
||||
border: 2px solid #bbb; /* Thin, light gray border */
|
||||
border-radius: 3px; /* Slightly rounded corners */
|
||||
font-size: 11.2px; /* Adjusted font size to approximate 70% of the original */
|
||||
text-align: center; /* Center the text */
|
||||
cursor: pointer; /* Pointer cursor on hover */ }
|
||||
|
||||
/* Hover and active effects for better interaction */
|
||||
.inline-buttons .link:hover {
|
||||
background-color: #d9d9d9; /* Darker shade on hover */
|
||||
}
|
||||
|
||||
.inline-buttons .link:active {
|
||||
background-color: #c0c0c0; /* Even darker shade on click */
|
||||
}
|
||||
|
||||
span .label {
|
||||
padding-top:13em;
|
||||
}
|
28
root/usr/share/smanager/themes/default/public/js/nutups.js
Normal file
28
root/usr/share/smanager/themes/default/public/js/nutups.js
Normal file
@@ -0,0 +1,28 @@
|
||||
$(document).ready(function() {
|
||||
function toggleUPSClasses() {
|
||||
var selectedOption = $('#Nutmode_select').val();
|
||||
$('.masterups').toggle(selectedOption === 'netserver' || selectedOption === 'standalone'); // Show/Hide masterups based on Net Server or Standalone
|
||||
$('.slaveups').toggle(selectedOption === 'netclient'); // Show/Hide slaveups based on Net Client
|
||||
|
||||
// Enable/Disable inputs based on the selected option
|
||||
$('.masterups input').prop('disabled', !(selectedOption === 'netserver' || selectedOption === 'standalone'));
|
||||
$('.slaveups input').prop('disabled', selectedOption !== 'netclient');
|
||||
}
|
||||
|
||||
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'
|
||||
|
||||
// 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();
|
||||
});
|
@@ -0,0 +1,60 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-01-20 16:21:33
|
||||
%#
|
||||
% layout 'default', title => "Sme server 2 - NutUPS configuration", share_dir => './';
|
||||
%# css specific to this panel:
|
||||
% content_for 'module' => begin
|
||||
%= stylesheet '/css/nutups.css'
|
||||
%= javascript '/js/nutups.js'
|
||||
<div id="module" class="module Nutups-panel">
|
||||
|
||||
% if (config->{debug} == 1) {
|
||||
<pre>
|
||||
%= dumper $c->current_route
|
||||
%= dumper $nut_data->{trt}
|
||||
</pre>
|
||||
% }
|
||||
|
||||
<h1><%=$title%></h1>
|
||||
|
||||
% if ( stash('modul')) {
|
||||
%= $c->render_to_string(inline => stash('modul') );
|
||||
% }
|
||||
|
||||
%if ($c->stash('first')) {
|
||||
<br><p>
|
||||
%=$c->render_to_string(inline =>$c->l($c->stash('first')))
|
||||
</p>
|
||||
|
||||
%} elsif ($c->stash('success')) {
|
||||
<div class='success '>
|
||||
<h2><%=$c->l('nut_Status_Report') %></h2><p>
|
||||
%= $c->l($c->stash('success'));
|
||||
</p>
|
||||
</div>
|
||||
<br />
|
||||
|
||||
%} elsif ($c->stash('error')) {
|
||||
<div class='sme-error'>
|
||||
<h2><%=$c->l('nut_Error_Status_Report') %></h2><p>
|
||||
%= $c->l($c->stash('error'));
|
||||
</p>
|
||||
</div>
|
||||
<br />
|
||||
%}
|
||||
|
||||
%#Routing to partials according to trt parameter.
|
||||
%#This ought to be cascading if/then/elsif, but is easier to just stack the if/then's rather like a case statement'
|
||||
|
||||
% if ($nut_data->{trt} eq "STATUS") {
|
||||
%= include 'partials/_nut_STATUS'
|
||||
%}
|
||||
|
||||
% if ($nut_data->{trt} eq "CONFIG") {
|
||||
%= include 'partials/_nut_CONFIG'
|
||||
%}
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
%end
|
@@ -0,0 +1,124 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-01-20 16:21:33
|
||||
%#
|
||||
<div id="Nutups-CONFIG" class="partial Nutups-CONFIG">
|
||||
<script>
|
||||
window.onload = function() {
|
||||
SelectInput();
|
||||
};
|
||||
</script>
|
||||
% if (config->{debug} == 1) {
|
||||
<pre>
|
||||
%= dumper $nut_data
|
||||
</pre>
|
||||
% }
|
||||
% my $btn = l('nut_APPLY');
|
||||
%= form_for "nutupsu" => (method => 'POST') => begin
|
||||
% param 'trt' => $nut_data->{trt} unless param 'trt';
|
||||
%= hidden_field 'trt' => $nut_data->{trt}
|
||||
%# Inputs etc in here.
|
||||
|
||||
<h2 class='subh2'><%=l('nut_Manage_Nutups-config_settings:')%></h2>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('nut_Nut_status')
|
||||
</span><span class=data>
|
||||
%# my @status_options = [['Disabled' => 'disabled'], ['Enabled' => 'enabled']];
|
||||
%# param 'status' => $nut_data->{status} unless param 'status';
|
||||
|
||||
% my @status_options = selected_field([['Disabled' => 'disabled'], ['Enabled' => 'enabled']], $nut_data->{status});
|
||||
%= select_field 'status' => @status_options, class => 'input', id => 'status_select'
|
||||
<br></span> </p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('nut_Nut_mode')
|
||||
</span><span class=data>
|
||||
% my @Nutmode_options = [['Standalone' => 'standalone'], ['Net Server' => 'netserver'], ['Net Client ' => 'netclient']];
|
||||
% param 'Nutmode' => $nut_data->{Nutmode} unless param 'Nutmode';
|
||||
%= select_field 'Nutmode' => @Nutmode_options, class => 'input', id => 'Nutmode_select'
|
||||
<br></span> </p>
|
||||
|
||||
<div class=masterups>
|
||||
<h2 class='subh3'><%=l('nut_if_Net_Server')%></h2>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('nut_MasterUPS_UPSNAME@IP')
|
||||
</span><span class=data>
|
||||
% param 'MasterUPS_Name' => $nut_data->{MasterUPS_Name} unless param 'MasterUPS_Name';
|
||||
%= text_field 'MasterUPS_Name', size => '50', class => 'textinput MasterUPS_Name' , pattern=>'.*' , placeholder=>'ups@localhost'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class='label'>
|
||||
%=l('nut_MasterUPS_Password')
|
||||
</span><span class=data>
|
||||
% param 'MasterUPS_Password' => $nut_data->{MasterUPS_Password} unless param 'MasterUPS_Password';
|
||||
%=password_field 'MasterUPS_Password', class => 'pass6 sme-password'
|
||||
</span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('nut_UPS_Model')
|
||||
</span><span class=data>
|
||||
% 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'
|
||||
<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=>'auto (for usb)'
|
||||
<br></span></p>
|
||||
</div>
|
||||
|
||||
<div class=slaveups>
|
||||
<h2 class='subh4'><%=l('nut_if_Net_Client')%></h2>
|
||||
<p><span class=label>
|
||||
%=l('nut_SlaveUPS_UPSNAME@IP')
|
||||
</span><span class=data>
|
||||
% param 'SlaveUPS_Name' => $nut_data->{SlaveUPS_Name} unless param 'SlaveUPS_Name';
|
||||
%= text_field 'SlaveUPS_Name', size => '50', class => 'textinput SlaveUPS_Name' , pattern=>'.*' , placeholder=>'upsname@IP'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class='label'>
|
||||
%=l('nut_SlaveUPS_Password')
|
||||
</span><span class=data>
|
||||
% param 'SlaveUPS_Password' => $nut_data->{SlaveUPS_Password} unless param 'SlaveUPS_Password';
|
||||
%=password_field 'SlaveUPS_Password', class => 'pass4 sme-password'
|
||||
</span></p>
|
||||
</div>
|
||||
|
||||
<div class=generics>
|
||||
` <h2 class='subh5'><%=l('nut_if_genericups')%></h2>
|
||||
<p><span class=label>
|
||||
%=l('nut_UPS_Generic_Type')
|
||||
</span><span class=data>
|
||||
% param 'UPS_gen_Type' => $nut_data->{UPS_gen_Type} unless param 'UPS_gen_Type';
|
||||
%= text_field 'UPS_gen_Type', size => '50', class => 'textinput UPS_gen_Type' , pattern=>'.*' , placeholder=>'UPS_gen_Type'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('nut_UPS_Generic_Manufacturer')
|
||||
</span><span class=data>
|
||||
% param 'UPS_gen_Mfr' => $nut_data->{UPS_gen_Mfr} unless param 'UPS_gen_Mfr';
|
||||
%= text_field 'UPS_gen_Mfr', size => '50', class => 'textinput UPS_gen_Mfr' , pattern=>'.*' , placeholder=>'UPS_gen_Mfr'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('nut_UPS_Generic_Model')
|
||||
</span><span class=data>
|
||||
% 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>
|
||||
|
||||
|
||||
|
||||
|
||||
%# Probably finally by a submit.
|
||||
%end
|
||||
</div>
|
@@ -0,0 +1,48 @@
|
||||
%#
|
||||
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-01-20 16:21:33
|
||||
%#
|
||||
<div id="Nutups-STATUS" class="partial Nutups-STATUS">
|
||||
<script>
|
||||
window.onload = function() {
|
||||
SelectInput();
|
||||
};
|
||||
</script>
|
||||
% if (config->{debug} == 1) {
|
||||
<pre>
|
||||
%= dumper $nut_data
|
||||
</pre>
|
||||
% }
|
||||
% my $btn = l('nut_APPLY');
|
||||
%= form_for "nutupsu" => (method => 'POST') => begin
|
||||
% param 'trt' => $nut_data->{trt} unless param 'trt';
|
||||
%= hidden_field 'trt' => $nut_data->{trt}
|
||||
%# Inputs etc in here.
|
||||
|
||||
<div class=inline-buttons>
|
||||
|
||||
|
||||
<a href='nutupsd?trt=CONFIG' class='link link1'>
|
||||
%= l('nut_Configure_NutUPS')
|
||||
</a>
|
||||
%#= link_to l('nut_Configure_NutUPS'), 'nutupsd?trt=CONFIG' , class=>'link link1'
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<h2 class='subh1'><%=l('nut_Status_of_the_controlled_UPS')%></h2>
|
||||
|
||||
<p class='paragraph para1'>
|
||||
%=l('nut_Descriptive_paragraph')
|
||||
</p>
|
||||
|
||||
<span class=label>
|
||||
%=l('nut_Status_(from_upsc)')
|
||||
</span><span class=data>
|
||||
% param 'UPSStatus' => $nut_data->{UPSStatus} unless param 'UPSStatus';
|
||||
%= text_area 'UPSStatus', cols=>55, rows=>35, Readonly=>'true'
|
||||
</span><br>
|
||||
|
||||
%# Probably finally by a submit.
|
||||
%end
|
||||
</div>
|
@@ -0,0 +1,50 @@
|
||||
% layout 'default';
|
||||
% title 'UPS Status';
|
||||
|
||||
<h1>UPS Status</h1>
|
||||
%= stylesheet '/css/nut_ups-status-page.css'
|
||||
<div class="ups-status-page">
|
||||
<div class="grid">
|
||||
<div class="card">
|
||||
<h2>Device Information</h2>
|
||||
<table>
|
||||
<tr><td>Manufacturer:</td><td><%= $ups_data->{'device.mfr'} %></td></tr>
|
||||
<tr><td>Model:</td><td><%= $ups_data->{'device.model'} %></td></tr>
|
||||
<tr><td>Serial:</td><td><%= $ups_data->{'device.serial'} %></td></tr>
|
||||
<tr><td>Type:</td><td><%= $ups_data->{'device.type'} %></td></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2>Battery Status</h2>
|
||||
<table>
|
||||
<tr><td>Charge:</td><td><%= $ups_data->{'battery.charge'} %>%</td></tr>
|
||||
<tr><td>Runtime:</td><td><%= sprintf("%.2f", $ups_data->{'battery.runtime'} / 60) %> minutes</td></tr>
|
||||
<tr><td>Voltage:</td><td><%= $ups_data->{'battery.voltage'} %>V</td></tr>
|
||||
<tr><td>Type:</td><td><%= $ups_data->{'battery.type'} %></td></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2>Input Power</h2>
|
||||
<table>
|
||||
<tr><td>Voltage:</td><td><%= $ups_data->{'input.voltage'} %>V</td></tr>
|
||||
<tr><td>Nominal Voltage:</td><td><%= $ups_data->{'input.voltage.nominal'} %>V</td></tr>
|
||||
<tr><td>Sensitivity:</td><td><%= $ups_data->{'input.sensitivity'} %></td></tr>
|
||||
<tr><td>Transfer High:</td><td><%= $ups_data->{'input.transfer.high'} %>V</td></tr>
|
||||
<tr><td>Transfer Low:</td><td><%= $ups_data->{'input.transfer.low'} %>V</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2>UPS Status</h2>
|
||||
<table>
|
||||
<tr><td>Status:</td><td><%= $ups_data->{'ups.status'} %></td></tr>
|
||||
<tr><td>Load:</td><td><%= $ups_data->{'ups.load'} %>%</td></tr>
|
||||
<tr><td>Beeper:</td><td><%= $ups_data->{'ups.beeper.status'} %></td></tr>
|
||||
<tr><td>Firmware:</td><td><%= $ups_data->{'ups.firmware'} %></td></tr>
|
||||
<tr><td>Test Result:</td><td><%= $ups_data->{'ups.test.result'} %></td></tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Reference in New Issue
Block a user