If behind by more than 50 commits, show update badge on "Tools"

This commit is contained in:
ehpersonal38
2022-05-27 15:32:43 -04:00
parent 0187cc2c45
commit 201f705517
3 changed files with 27 additions and 9 deletions
+5
View File
@@ -701,3 +701,8 @@ dialog::backdrop {
text-align:center;
font-size:small;
}
form#views button .updatenumber {
position:initial;
margin-left:0px;
}
+21 -2
View File
@@ -1,3 +1,19 @@
<?php
session_start();
$user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd");
$home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd");
$home = trim($home);
if(!isset($_SESSION['behind'])) {
$_SESSION['behind'] = trim(shell_exec("sudo git -C ".$home."/BirdNET-Pi fetch > /dev/null 2>&1 && git -C ".$home."/BirdNET-Pi status | sed -n '2 p' | cut -d ' ' -f 7"));
}
if(intval($_SESSION['behind']) >= 99) {?>
<style>
.updatenumber {
width:30px !important;
}
</style>
<?php }
?>
<link rel="stylesheet" href="style.css">
<style>
body::-webkit-scrollbar {
@@ -31,7 +47,7 @@ body::-webkit-scrollbar {
<button type="submit" name="view" value="View Log" form="views">View Log</button>
</form>
<form action="" method="GET" id="views">
<button type="submit" name="view" value="Tools" form="views">Tools</button>
<button type="submit" name="view" value="Tools" form="views">Tools<?php if(intval($_SESSION['behind']) >= 50){ $updatediv = ' <div class="updatenumber">'.$_SESSION["behind"].'</div>'; } else { $updatediv = ""; } echo $updatediv; ?></button>
</form>
<button href="javascript:void(0);" class="icon" onclick="myFunction()"><img src="images/menu.png"></button>
</div>
@@ -94,7 +110,7 @@ if(isset($_GET['view'])){
<form action=\"\" method=\"GET\" id=\"views\">
<button type=\"submit\" name=\"view\" value=\"Settings\" form=\"views\">Settings</button>
<button type=\"submit\" name=\"view\" value=\"System Info\" form=\"views\">System Info</button>
<button type=\"submit\" name=\"view\" value=\"System Controls\" form=\"views\">System Controls</button>
<button type=\"submit\" name=\"view\" value=\"System Controls\" form=\"views\">System Controls".$updatediv."</button>
<button type=\"submit\" name=\"view\" value=\"Services\" form=\"views\">Services</button>
<button type=\"submit\" name=\"view\" value=\"File\" form=\"views\">File Manager</button>
<a href=\"scripts/adminer.php\" target=\"_top\"><button type=\"submit\" form=\"\">Database Maintenance</button></a>
@@ -264,6 +280,9 @@ if(isset($_GET['view'])){
$tmp = explode(" ",trim($command));
$command .= "& sleep 3;sudo systemctl status ".end($tmp);
}
if($initcommand == "update_birdnet.sh") {
unset($_SESSION['behind']);
}
$results = shell_exec("$command 2>&1");
$results = str_replace("FAILURE", "<span style='color:red'>FAILURE</span>", $results);
$results = str_replace("failed", "<span style='color:red'>failed</span>",$results);
+1 -7
View File
@@ -1,9 +1,3 @@
<?php
$user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd");
$home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd");
$home = trim($home);
$behind = trim(shell_exec("sudo git -C ".$home."/BirdNET-Pi fetch > /dev/null 2>&1 && git -C ".$home."/BirdNET-Pi status | sed -n '2 p' | cut -d ' ' -f 7"));
?>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<br>
@@ -13,7 +7,7 @@ $behind = trim(shell_exec("sudo git -C ".$home."/BirdNET-Pi fetch > /dev/null 2>
<button type="submit" name="submit" value="sudo reboot" onclick="return confirm('Are you sure you want to reboot?')">Reboot</button>
</form>
<form action="" method="GET">
<button type="submit" name="submit" value="update_birdnet.sh" onclick="return confirm('Are you sure you want to update?')">Update <?php if($behind != "0" && $behind != "with"){?><div class="updatenumber"><?php echo $behind; ?></div><?php } ?></button>
<button type="submit" name="submit" value="update_birdnet.sh" onclick="return confirm('Are you sure you want to update?')">Update <?php if($_SESSION['behind'] != "0" && $_SESSION['behind'] != "with"){?><div class="updatenumber"><?php echo $_SESSION['behind']; ?></div><?php } ?></button>
</form>
<form action="" method="GET">
<button type="submit" name="submit" value="sudo shutdown now" onclick="return confirm('Are you sure you want to shutdown?')">Shutdown</button>