Skip to content

Commit

Permalink
- renamed Small style to Minimal
Browse files Browse the repository at this point in the history
- disabled tooltip on Minimal style
  • Loading branch information
Peuuuur-Noel committed Jul 26, 2023
1 parent 85442bf commit 66dec97
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
6 changes: 5 additions & 1 deletion source/nut/usr/local/emhttp/plugins/nut/NUTsettings.page
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,15 @@ require_once '/usr/local/emhttp/plugins/nut/include/nut_config.php'; ?>
<dd>
<select class="" name="FOOTER_STYLE" size="1">
<?=mk_option($nut_footer_style, '0', 'Default');?>
<?=mk_option($nut_footer_style, '1', 'Small');?>
<?=mk_option($nut_footer_style, '1', 'Minimal');?>
</select>
</dd>
</dl>

<blockquote class="inline_help">
<p>Tooltip disabled on Minimal style.</p>
</blockquote>

<dl>
<dt>Display Page Refresh:</dt>
<dd>
Expand Down
16 changes: 10 additions & 6 deletions source/nut/usr/local/emhttp/plugins/nut/include/nut_footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ function format_time($seconds) {
$fa_icon = "fa-battery-empty";
$online['fulltext'][] = 'Battery status unknown';
}
$tooltipData = '[' . $nut_name . '] ' . implode(' - ', $online['fulltext']);
if ($config['FOOTER_STYLE'] == 0)
$statusTooltipData = ' data="[' . $nut_name . '] ' . implode(' - ', $online['fulltext']) . '"';

$status[0] = "<span id='" . ($config['FOOTER_STYLE'] == 0 ? "nut_battery" : "") . "' class='tooltip-nut " . $css_class . "' data='" . $tooltipData . "'><i class='fa " . $fa_icon . "' style='vertical-align: baseline;'></i>&thinsp;" . $batteryText . "</span>";
$status[0] = "<span id='" . ($config['FOOTER_STYLE'] == 0 ? "nut_battery" : "") . "' class='tooltip-nut " . $css_class . "'" . $statusTooltipData . "><i class='fa " . $fa_icon . "' style='vertical-align: baseline;'></i>&thinsp;" . $batteryText . "</span>";

# ups.power.nominal (in VA) or compute from load and ups.power.nominal
$apparentPower = $powerNominal > 0 && $load ? round($powerNominal * $load * 0.01) : -1;
Expand All @@ -115,15 +116,18 @@ function format_time($seconds) {
$powerTooltipData = '';
if ($realPower >= 0 && $apparentPower >= 0) {
$powerText = "{$realPower}&thinsp;W ({$apparentPower}&thinsp;VA)";
$powerTooltipData = "[{$nut_name}] Load: $load&thinsp;% - Real power: $realPower&thinsp;W - Apparent power: $apparentPower&thinsp;VA";
$powerTooltipData = "Load: $load&thinsp;% - Real power: $realPower&thinsp;W - Apparent power: $apparentPower&thinsp;VA";
} else if ($realPower >= 0 && $load) {
$powerText = "{$realPower}&thinsp;W";
$powerTooltipData = "[{$nut_name}] Load: $load&thinsp;% - Real power: $realPower&thinsp;W";
$powerTooltipData = "Load: $load&thinsp;% - Real power: $realPower&thinsp;W";
} else if ($apparentPower >= 0) {
$powerText = "{$apparentPower}&thinsp;VA";
$powerTooltipData = "[{$nut_name}] Load: $load&thinsp;% - Apparent power: $apparentPower&thinsp;VA";
$powerTooltipData = "Load: $load&thinsp;% - Apparent power: $apparentPower&thinsp;VA";
}
$status[1] = "<span id='".($config['FOOTER_STYLE'] == 0 ? "nut_power" : "")."' class='tooltip-nut " . ($load >= 90 ? "$red" : ($config['FOOTER_STYLE'] == 1 ? "$black" : "$green")) . "' data='{$powerTooltipData}'><i class='fa fa-plug'></i>&thinsp;{$powerText}</span>";
if ($config['FOOTER_STYLE'] == 0)
$powerTooltipData = " data='[{$nut_name}] " . $powerTooltipData . "'";

$status[1] = "<span id='".($config['FOOTER_STYLE'] == 0 ? "nut_power" : "")."' class='tooltip-nut " . ($load >= 90 ? $red : ($config['FOOTER_STYLE'] == 1 ? $black : $green)) . "'" . $powerTooltipData . "><i class='fa fa-plug'></i>&thinsp;" . $powerText . "</span>";

echo "<span style='margin:0 6px 0 12px'>".implode('</span><span style="margin:0 6px 0 6px">', $status)."</span>";
} else {
Expand Down
18 changes: 11 additions & 7 deletions source/nut/usr/local/emhttp/plugins/nut/nutFooter.page
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ EOT;
-webkit-animation:ring 3s ease infinite;
animation:ring 3s ease infinite
}
#nut_footer {
float: right;
margin-right: 6px;
}
#nut_footer.minimal {
font-family: bitstream;
font-size: 1.1rem;
padding-right: 10px;
}
</style>
<script type="text/javascript">
function getNUTfooter() {
Expand All @@ -127,14 +136,9 @@ EOT;

$(function()
{
var footer = $("<span id='nut_footer'></span>").insertAfter("div#footer > span#copyright").css({"float": "right", "margin-right": "6px"});
var footer = $("<span id='nut_footer'></span>").insertAfter("div#footer > span#copyright");
<?if ($config['FOOTER_STYLE'] == 1): ?>
footer.css({
"font-family": "bitstream",
"font-size": "1.1rem",
"float": "right",
"padding-right": "10px"
});
footer.addClass('minimal');
<?endif;?>
getNUTfooter();
$('body').on('mouseenter', '.tooltip-nut', function()
Expand Down

0 comments on commit 66dec97

Please sign in to comment.