fix: update Boot.php to enhance theme handling and improve status display elements

This commit is contained in:
Zack Spear
2025-04-03 13:48:33 -07:00
parent 855508edb6
commit dc1a9759ef

View File

@@ -20,9 +20,20 @@ $_SERVER['REQUEST_URI'] = '';
require_once "$docroot/webGui/include/Translations.php";
$var = parse_ini_file("/var/local/emhttp/var.ini");
/**
* Just like DefaultPageLayout.php
*/
$theme = strtok($display['theme'],'-');
$themes1 = in_array($theme,['black','white']);
$themes2 = in_array($theme,['gray','azure']);
$themeHtmlClass = "Theme--$theme";
if ($themes2) {
$themeHtmlClass .= " Theme--sidebar";
}
?>
<!DOCTYPE HTML>
<html <?=$display['rtl']?>lang="<?=strtok($locale,'_')?:'en'?>">
<html <?=$display['rtl']?>lang="<?=strtok($locale,'_')?:'en'?>" class="<?= $themeHtmlClass ?>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
@@ -35,11 +46,22 @@ $var = parse_ini_file("/var/local/emhttp/var.ini");
<link type="text/css" rel="stylesheet" href="<?autov("/webGui/styles/default-color-palette.css")?>">
<link type="text/css" rel="stylesheet" href="<?autov("/webGui/styles/default-base.css")?>">
<link type="text/css" rel="stylesheet" href="<?autov("/webGui/styles/default-{$display['theme']}.css")?>">
<link type="text/css" rel="stylesheet" href="<?autov("/webGui/styles/themes/{$display['theme']}.css")?>">
<style>
.notice{background-image:none;color:#e68a00;font-size:6rem;text-transform:uppercase;text-align:center;padding:4rem 0}
.sub1,.sub2{margin:6rem 0;text-align:center;font-size:3rem}
.boot-title {
background-image: none;
color: var(--orange-300);
font-size: 6rem;
text-transform: uppercase;
text-align: center;
padding: 4rem 0;
}
.boot-subtext {
margin: 6rem 0;
text-align: center;
font-size: 3rem;
}
</style>
<script src="<?autov('/webGui/javascript/dynamix.js')?>"></script>
@@ -65,7 +87,7 @@ boot.on('message', function(msg) {
default : var status = "<span class='orange'>"+_('Array '+ini['fsState'])+"</span>";
}
status += ini['fsProgress'] ? "<br><span class='blue'>"+_(ini['fsProgress'])+"</span>" : "<br>&nbsp;";
$('.sub1').html(status);
$('.js-arrayStatus').html(status);
});
function parseINI(msg) {
@@ -102,19 +124,19 @@ function timer() {
return Math.round((now.getTime()-start.getTime())/1000);
}
function reboot_now() {
$('.notice').html("<?=_('Reboot')?> - <?=gethostname()?>");
$('.js-bootTitle').html("<?=_('Reboot')?> - <?=gethostname()?>");
boot.start();
reboot_online();
}
function shutdown_now() {
$('.notice').html("<?=_('Shutdown')?> - <?=gethostname()?>");
$('.js-bootTitle').html("<?=_('Shutdown')?> - <?=gethostname()?>");
boot.start();
shutdown_online();
}
function reboot_online() {
$.ajax({url:'/webGui/include/ProcessStatus.php',type:'POST',data:{name:'emhttpd',update:true},timeout:500})
.done(function(){
$('.sub2').html("<?=_('System is going down')?>... "+timer());
$('.js-powerStatus').html("<?=_('System is going down')?>... "+timer());
setTimeout(reboot_online,500);
})
.fail(function(){start=new Date(); setTimeout(reboot_offline,500);});
@@ -123,14 +145,14 @@ function reboot_offline() {
$.ajax({url:'/webGui/include/ProcessStatus.php',type:'POST',data:{name:'emhttpd',update:true},timeout:500})
.done(function(){location = '/Main';})
.fail(function(){
$('.sub2').html("<?=_('System is rebooting')?>... "+timer());
$('.js-powerStatus').html("<?=_('System is rebooting')?>... "+timer());
setTimeout(reboot_offline,500);
});
}
function shutdown_online() {
$.ajax({url:'/webGui/include/ProcessStatus.php',type:'POST',data:{name:'emhttpd',update:true},timeout:500})
.done(function(){
$('.sub2').html("<?=_('System is going down')?>... "+timer());
$('.js-powerStatus').html("<?=_('System is going down')?>... "+timer());
setTimeout(shutdown_online,500);
})
.fail(function(){start=new Date(); setTimeout(shutdown_offline,500);});
@@ -138,10 +160,10 @@ function shutdown_online() {
function shutdown_offline() {
var time = timer();
if (time < 30) {
$('.sub2').html("<?=_('System is offline')?>... "+time);
$('.js-powerStatus').html("<?=_('System is offline')?>... "+time);
setTimeout(shutdown_offline,500);
} else {
$('.sub2').html("<?=_('System is powered off')?>...");
$('.js-powerStatus').html("<?=_('System is powered off')?>...");
setTimeout(power_on,500);
}
}
@@ -177,8 +199,8 @@ case 'shutdown':
exec('/sbin/poweroff -n');
break;
}
echo '<div class="notice"></div>';
echo '<div class="sub1">';
echo '<div class="js-bootTitle boot-title"></div>';
echo '<div class="js-arrayStatus boot-subtext">';
switch (_var($var,'fsState')) {
case 'Stopped':
echo "<span class='red'>",_('Array Stopped'),"</span>$progress"; break;
@@ -190,7 +212,7 @@ default:
echo "<span class='green'>",_('Array Started'),"</span>$progress"; break;
}
echo '</div>';
echo '<div class="sub2"></div>';
echo '<div class="js-powerStatus boot-subtext"></div>';
echo '</body>';
}else{
?>