Add maintenance features

Theme Selector, some bugfixing, update Readme
This commit is contained in:
leiweibau
2022-06-23 18:47:23 +02:00
parent 86a78b7e3a
commit e7168ca832
7 changed files with 106 additions and 12 deletions

View File

@@ -66,6 +66,17 @@ A web frontal that allows:
| -------------------- | -------------------- | | -------------------- | -------------------- |
| ![Screen 3][screen3] | ![Screen 4][screen4] | | ![Screen 3][screen3] | ![Screen 4][screen4] |
### Maintenance
With the work of [jokobsk/Pi.Alert](https://github.com/jokob-sk/Pi.Alert) and own extensions, various possibilities for
maintenance and settings are available on this page:
- DB Backup and Restore
- Theme Selection (blue, red, green, yellow, black, purple)
- Light/Dark-Mode Switch
- DB maintenance tools
In addition, some information is available (active scans, database size, backup counter).
![Maintain screen dark][maintain_dark]
# Installation # Installation
<!--- --------------------------------------------------------------------- ---> <!--- --------------------------------------------------------------------- --->
@@ -137,4 +148,5 @@ Linux distributions.
[report1]: ./docs/img/4_report_1.jpg "Report sample 1" [report1]: ./docs/img/4_report_1.jpg "Report sample 1"
[report2]: ./docs/img/4_report_2.jpg "Report sample 2" [report2]: ./docs/img/4_report_2.jpg "Report sample 2"
[main_dark]: /docs/img/1_devices_dark.jpg "Main screen dark" [main_dark]: /docs/img/1_devices_dark.jpg "Main screen dark"
[maintain_dark]: /docs/img/5_maintain.jpg "Maintain screen dark"

BIN
docs/img/5_maintain.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

View File

@@ -119,6 +119,18 @@
margin-left: 0px; margin-left: 0px;
} }
.fix_maintain_section {
min-height: 650px;
}
}
@media (max-width: 520px) {
.fix_maintain_section {
min-height: 900px;
}
} }
.sidebar-open .content-wrapper, .sidebar-open .main-footer { .sidebar-open .content-wrapper, .sidebar-open .main-footer {
@@ -453,7 +465,7 @@
} }
.dbtools-button { .dbtools-button {
margin: 5px; display: inline-block; width: 140px; height: 100px; white-space: normal; word-wrap: break-word; font-size: 16px; border-radius: 10px; margin: 5px; display: inline-block; width: 140px; height: 100px; white-space: normal; word-wrap: break-word; font-size: 16px; border-radius: 10px; margin-bottom: 25px;
} }
.db_info_table_cell:nth-child(1) {background: white} .db_info_table_cell:nth-child(1) {background: white}
@@ -469,6 +481,7 @@
margin: auto; margin: auto;
margin-top: 40px; margin-top: 40px;
margin-bottom: 40px; margin-bottom: 40px;
border: solid 1px #ddd;
} }
.db_info_table_row {display: table-row; padding: 3px; } .db_info_table_row {display: table-row; padding: 3px; }
.db_info_table_cell {display: table-cell; padding: 3px; padding-left: 10px;} .db_info_table_cell {display: table-cell; padding: 3px; padding-left: 10px;}

View File

@@ -2,6 +2,13 @@
"name": "Pi-Alert Console", "name": "Pi-Alert Console",
"short_name": "Pi-Alert", "short_name": "Pi-Alert",
"display": "standalone", "display": "standalone",
"theme_color": "#367fa9", "icons": [
"background_color": "#367fa9" {
"src": "",
"sizes": "180x180",
"type": "image/png"
}
],
"theme_color": "#000",
"background_color": "#000"
} }

View File

@@ -28,7 +28,7 @@
</section> </section>
<!-- Main content ---------------------------------------------------------- --> <!-- Main content ---------------------------------------------------------- -->
<section class="content" style="min-height: 600px;"> <section class="content fix_maintain_section" style="height: 100%;">
<?php <?php
@@ -59,6 +59,35 @@ natsort($latestfiles);
$latestfiles = array_reverse($latestfiles,False); $latestfiles = array_reverse($latestfiles,False);
$latestbackup = $latestfiles[0]; $latestbackup = $latestfiles[0];
$latestbackup_date = date ("Y-m-d H:i:s", filemtime($latestbackup)); $latestbackup_date = date ("Y-m-d H:i:s", filemtime($latestbackup));
if (submit) {
$pia_skin_set_dir = '../db/';
$pia_skin_selector = htmlspecialchars($_POST['skinselector']);
$pia_installed_skins = array('skin-black-light', 'skin-black', 'skin-blue-light', 'skin-blue', 'skin-green-light', 'skin-green', 'skin-purple-light', 'skin-purple', 'skin-red-light', 'skin-red', 'skin-yellow-light', 'skin-yellow',);
if (in_array($pia_skin_selector, $pia_installed_skins)) {
foreach ($pia_installed_skins as $file) {
unlink ($pia_skin_set_dir.'/'.$file);
}
foreach ($pia_installed_skins as $file) {
if (file_exists($pia_skin_set_dir.'/'.$file)) {
$pia_skin_error = True;
break;
} else {
$pia_skin_error = False;
}
}
if ($pia_skin_error == False) {
$testskin = fopen($pia_skin_set_dir.$pia_skin_selector, 'w');
$pia_skin_test = '';
echo("<meta http-equiv='refresh' content='1'>");
} else {
$pia_skin_test = '';
echo("<meta http-equiv='refresh' content='1'>");
}
}
}
?> ?>
<div class="db_info_table"> <div class="db_info_table">
@@ -88,10 +117,36 @@ $latestbackup_date = date ("Y-m-d H:i:s", filemtime($latestbackup));
</div> </div>
</div> </div>
<form method="post" action="maintenance.php">
<div class="db_info_table">
<div class="db_info_table_row">
<div class="db_info_table_cell" style="height:50px; text-align:center; vertical-align: middle;">
<div style="display: inline-block; margin-right: 10px;">Theme Selection:</div>
<div style="display: inline-block;">
<select name="skinselector">
<option value="">--Choose a theme--</option>
<option value="skin-black-light">black light</option>
<option value="skin-black">black</option>
<option value="skin-blue-light">blue light</option>
<option value="skin-blue">blue</option>
<option value="skin-green-light">green light</option>
<option value="skin-green">green</option>
<option value="skin-purple-light">purple light</option>
<option value="skin-purple">purple</option>
<option value="skin-red-light">red light</option>
<option value="skin-red">red</option>
<option value="skin-yellow-light">yellow light</option>
<option value="skin-yellow">yellow</option>
</select></div>
<div style="display: inline-block;"><input type="submit" value="Set"><?php echo $pia_skin_test; ?></div>
</div>
</div>
</div>
</form>
<div class="col-xs-12" style="text-align:center; padding-top: 10px; margin-bottom: 50px;"> <div class="col-xs-12" style="text-align:center; padding-top: 10px;">
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-green dbtools-button" id="btnPiaEnableDarkmode" style="border-top: solid 3px #00a65a;" onclick="askPiaEnableDarkmode()">Switch Themes (Dark/Light)</button> <button type="button" class="btn btn-default pa-btn pa-btn-delete bg-green dbtools-button" id="btnPiaEnableDarkmode" style="border-top: solid 3px #00a65a;" onclick="askPiaEnableDarkmode()">Switch Modes (Dark/Light)</button>
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteMAC" style="border-top: solid 3px #dd4b39;" onclick="askDeleteDevicesWithEmptyMACs()">Delete Devices with empty MACs</button> <button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteMAC" style="border-top: solid 3px #dd4b39;" onclick="askDeleteDevicesWithEmptyMACs()">Delete Devices with empty MACs</button>

View File

@@ -272,7 +272,7 @@ function PiaBackupDBtoArchive() {
// copy files as a fast Backup // copy files as a fast Backup
if (!copy($file, $newfile)) { if (!copy($file, $newfile)) {
echo "The Backup executed not successfully"; echo "The original database could not be saved.";
} else { } else {
// Create archive with actual date // Create archive with actual date
$Pia_Archive_Name = 'pialertdb_'.date("Ymd_His").'.zip'; $Pia_Archive_Name = 'pialertdb_'.date("Ymd_His").'.zip';
@@ -282,8 +282,9 @@ function PiaBackupDBtoArchive() {
if (file_exists($Pia_Archive_Path.$Pia_Archive_Name) && filesize($Pia_Archive_Path.$Pia_Archive_Name) > 0) { if (file_exists($Pia_Archive_Path.$Pia_Archive_Name) && filesize($Pia_Archive_Path.$Pia_Archive_Name) > 0) {
echo 'The backup executed successfully with the new archive: ('.$Pia_Archive_Name.')'; echo 'The backup executed successfully with the new archive: ('.$Pia_Archive_Name.')';
unlink($newfile); unlink($newfile);
echo("<meta http-equiv='refresh' content='1'>");
} else { } else {
echo 'Test backup executed partially successfully. The archive could not be created or is empty. (pialert.db.latestbackup)'; echo 'The backup executed partially successfully. The archive could not be created or is empty. (pialert.db.latestbackup)';
} }
} }
@@ -299,7 +300,7 @@ function PiaRestoreDBfromArchive() {
// copy files as a fast Backup // copy files as a fast Backup
if (!copy($file, $oldfile)) { if (!copy($file, $oldfile)) {
echo "Test Function executed not successfully"; echo 'The original database could not be saved.';
} else { } else {
// extract latest archive and overwrite the actual pialert.db // extract latest archive and overwrite the actual pialert.db
$Pia_Archive_Path = '../../../db/'; $Pia_Archive_Path = '../../../db/';
@@ -308,6 +309,7 @@ function PiaRestoreDBfromArchive() {
if (file_exists($file)) { if (file_exists($file)) {
echo 'Restore executed successfully'; echo 'Restore executed successfully';
unlink($oldfile); unlink($oldfile);
echo("<meta http-equiv='refresh' content='1'>");
} else { } else {
echo 'Restore Failed. Please restore the backup manually.'; echo 'Restore Failed. Please restore the backup manually.';
} }

View File

@@ -8,9 +8,14 @@
#--------------------------------------------------------------------------- --> #--------------------------------------------------------------------------- -->
<?php <?php
if (file_exists('../db/darkmode')) { if (file_exists('../db/darkmode')) {
$ENABLED_DARKMODE = True; $ENABLED_DARKMODE = True;
} }
foreach (glob("../db/skin*") as $filename) {
$pia_skin_selected = basename($filename);
}
if (strlen($pia_skin_selected) == 0) {$pia_skin_selected = 'skin-blue';}
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
@@ -42,7 +47,7 @@ if (file_exists('../db/darkmode')) {
<!-- AdminLTE Skins. We have chosen the skin-blue for this starter <!-- AdminLTE Skins. We have chosen the skin-blue for this starter
page. However, you can choose any other skin. Make sure you page. However, you can choose any other skin. Make sure you
apply the skin class to the body tag so the changes take effect. --> apply the skin class to the body tag so the changes take effect. -->
<link rel="stylesheet" href="lib/AdminLTE/dist/css/skins/skin-blue.min.css"> <link rel="stylesheet" href="lib/AdminLTE/dist/css/skins/<?php echo $pia_skin_selected;?>.min.css">
<!-- Pi.Alert CSS --> <!-- Pi.Alert CSS -->
<link rel="stylesheet" href="css/pialert.css"> <link rel="stylesheet" href="css/pialert.css">
@@ -61,7 +66,7 @@ if (file_exists('../db/darkmode')) {
<!-- For better UX on Mobile Devices using the Shortcut on the Homescreen --> <!-- For better UX on Mobile Devices using the Shortcut on the Homescreen -->
<link rel="manifest" href="img/manifest.json"> <link rel="manifest" href="img/manifest.json">
<link rel="apple-touch-icon" href="https://net-dev.de/pialert_homescreen.png">
<!-- Dark-Mode Patch --> <!-- Dark-Mode Patch -->
<?php <?php
if ($ENABLED_DARKMODE === True) { if ($ENABLED_DARKMODE === True) {
@@ -93,7 +98,7 @@ function show_pia_servertime() {
<!-- ----------------------------------------------------------------------- --> <!-- ----------------------------------------------------------------------- -->
<!-- Layout Boxed Yellow --> <!-- Layout Boxed Yellow -->
<body class="hold-transition skin-blue layout-boxed sidebar-mini" <?php echo $BACKGROUND_IMAGE_PATCH;?> onLoad="show_pia_servertime();" > <body class="hold-transition <?php echo $pia_skin_selected;?> layout-boxed sidebar-mini" <?php echo $BACKGROUND_IMAGE_PATCH;?> onLoad="show_pia_servertime();" >
<!-- Site wrapper --> <!-- Site wrapper -->
<div class="wrapper"> <div class="wrapper">