|
8 | 8 | $config = new Config; |
9 | 9 | $config->load("local.config", "defaults.php"); |
10 | 10 |
|
| 11 | +if(!isset($_SESSION["setup"])){ |
| 12 | + if($config->get("general.initialsetup")=="0"){ |
| 13 | + header("Location: setup.php"); |
| 14 | + } |
| 15 | +} |
| 16 | + |
11 | 17 | $path=$_SERVER['SCRIPT_FILENAME']; |
12 | 18 | $fol=substr($path, 0, -9); |
13 | 19 |
|
14 | | -$passVal = ($config->get("general.pass")!=='63a9f0ea7bb98050796b649e85481845') ? '***' : ''; |
| 20 | +$passVal = ($config->get("general.pass")!=='63a9f0ea7bb98050796b649e85481845') ? "***notdefault***" : ''; |
15 | 21 | ?> |
16 | 22 | <!doctype html> |
17 | 23 | <html lang="en"> |
|
104 | 110 | $p = $df / $ds * 100; |
105 | 111 | // |
106 | 112 |
|
| 113 | + $permissionerr=false; |
107 | 114 | $spannung=substr(exec("vcgencmd measure_volts core"),5); |
108 | | - if(strpos($spannung,"failed")!==false) $spannung=$spannung."<div class='alert alert-danger' role='alert'>Reading of core voltage failed. Please run<br><kbd>sudo usermod -aG video www-data</kbd><br>in a terminal to solve this problem.</div>"; |
| 115 | + if( (strpos($spannung,"failed")!==false) || (strlen($spannung)<2) ){ |
| 116 | + $spannung=$spannung."<div class='alert alert-danger' role='alert'>Reading of core voltage failed. Please run<br><kbd>sudo usermod -aG video www-data</kbd><br>in a terminal to solve this problem.</div>"; |
| 117 | + $permissionerr=true; |
| 118 | + } |
109 | 119 | } |
110 | 120 | ?> |
111 | 121 |
|
|
142 | 152 | <div class="card-body"> |
143 | 153 | <h5 id="sys1" class="card-title"><span id="overallstate"></span></h5> |
144 | 154 | <p id="sys11" class="card-text"></p> |
| 155 | + <?php |
| 156 | + if(isset($_SESSION["setup"])){ |
| 157 | + ?> |
| 158 | + <div class="alert alert-info alert-dismissible fade show" role="alert"><i class="bi bi-info-circle"></i> Setup finished! RPi Dashboard is ready.<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div> |
| 159 | + <?php |
| 160 | + unset($_SESSION["setup"]); |
| 161 | + } |
| 162 | + ?> |
| 163 | + |
145 | 164 | <p id="sys2" class="card-text"></p> |
146 | 165 | <hr> |
147 | 166 | <p><i class="bi bi-clock-history"></i><!--<img src="img/time-icon.png">--> Uptime: <b><span id="uptime"></span></b><?php if($auth){ ?> (started <?=$uptstr;?>)<?php } ?></p> |
|
255 | 274 | <div class="card-header">Model</div> |
256 | 275 | <div class="card-body"> |
257 | 276 | <samp><?php echo exec("cat /sys/firmware/devicetree/base/model");?></samp> |
258 | | - <samp><?php $ot=shell_exec("vcgencmd version");if(strpos($ot,"failed")!==false){echo "<div class='alert alert-danger' role='alert'>Execution of system command failed. Please run<br><kbd>sudo usermod -aG video www-data</kbd><br>in a terminal to solve this problem.</div>";}else{echo $ot;}?></samp> |
| 277 | + <?php $ot=shell_exec("vcgencmd version");if($permissionerr){echo "<div class='alert alert-danger' role='alert'>Execution of system command failed. Please run<br><kbd>sudo usermod -aG video www-data</kbd><br>in a terminal to solve this problem.</div>";}else{echo '<samp>'.$ot.'</samp>';}?> |
259 | 278 | <p class="card-text"><small class="text-muted">Updated <span><?php echo date("H:i:s");?> (at page load)</span></small></p> |
260 | 279 | </div> |
261 | 280 | </div> |
|
433 | 452 | <form id="settingsForm"> |
434 | 453 | <div class="form-row"> |
435 | 454 | <div class="col"> |
436 | | - <input type="number" id="warn_cpu_temp" class="form-control" placeholder="default: 60" aria-describedby="critCpuTempHelp" min="20" max="80" value="<?=$config->get("thresholds.warn_cpu_temp")?>"> |
| 455 | + <input type="number" id="warn_cpu_temp" class="form-control" placeholder="default: 65" aria-describedby="critCpuTempHelp" min="20" max="80" value="<?=$config->modified("thresholds.warn_cpu_temp")?>"> |
437 | 456 | <small id="critCpuTempHelp" class="form-text text-muted">CPU Temperature (°C) - default: 65°C</small> |
438 | 457 | </div> |
439 | 458 | <div class="col"> |
440 | | - <input type="number" id="warn_ram_space" class="form-control" placeholder="default: 80" aria-describedby="critRamSizeHelp" min="0" max="100" value="<?=$config->get("thresholds.warn_ram_space")?>"> |
| 459 | + <input type="number" id="warn_ram_space" class="form-control" placeholder="default: 80" aria-describedby="critRamSizeHelp" min="0" max="100" value="<?=$config->modified("thresholds.warn_ram_space")?>"> |
441 | 460 | <small id="critRamSizeHelp" class="form-text text-muted">RAM Load (%) - default: 80%</small> |
442 | 461 | </div> |
443 | 462 | </div> |
444 | 463 | <div class="form-row"> |
445 | 464 | <div class="col-6"> |
446 | | - <input type="number" id="warn_loads_size" class="form-control" placeholder="default: 2" aria-describedby="critCpuLoadHelp" min="1" max="4" value="<?=$config->get("thresholds.warn_loads_size")?>"> |
| 465 | + <input type="number" id="warn_loads_size" class="form-control" placeholder="default: 2" aria-describedby="critCpuLoadHelp" min="1" max="4" value="<?=$config->modified("thresholds.warn_loads_size")?>"> |
447 | 466 | <small id="critCpuLoadHelp" class="form-text text-muted">CPU workload (last min) - default: 2</small> |
448 | 467 | </div> |
449 | 468 | </div> |
450 | 469 | <div class="form-row mb-2"> |
451 | 470 | <label for="upd_time_interval" class="col-sm-6 col-form-label">Refresh rate (sec)</label> |
452 | 471 | <div class="col-sm-6"> |
453 | | - <input type="number" class="form-control" placeholder="default: 15" id="upd_time_interval" aria-describedby="dbRefreshHelp" min="5" max="600" value="<?=$config->get("thresholds.upd_time_interval")?>"> |
| 472 | + <input type="number" class="form-control" placeholder="default: 15" id="upd_time_interval" aria-describedby="dbRefreshHelp" min="5" max="600" value="<?=$config->modified("thresholds.upd_time_interval")?>"> |
454 | 473 | </div> |
455 | 474 | <small id="dbRefreshHelp" class="col form-text text-muted">Refresh interval of live data update section (recommended: 10 - 60 sec) - Pay attention: Do not set too low. - default: 15</small> |
456 | 475 | </div> |
|
571 | 590 | upd_time_interval = <?=$config->get("thresholds.upd_time_interval")?>; |
572 | 591 | warn_loads_size = <?=$config->get("thresholds.warn_loads_size")?>; |
573 | 592 | var settingsKeys=["warn_cpu_temp", "warn_ram_space", "warn_loads_size", "upd_time_interval", "pass"]; |
574 | | -var defaultSettings=[65, 80, 2, 15, "root"]; |
575 | 593 | console.log("Custom user options: warncputemp="+warn_cpu_temp+" | warn_ram_space="+warn_ram_space+" | upd_time_interval="+upd_time_interval+" | warn_loads_size="+warn_loads_size); |
576 | 594 | </script> |
577 | 595 |
|
|
0 commit comments