New feat : Disk usage summary (#318)

* Disk usage summary

* Explain why there is more files than the max specified

* Update advanced.php

* Update advanced.php

* Few improvements

* Improve alerts

* Define HOME

* Use single alert

* Shorten message for single alert

* Add execute permission to scripts/disk_species_count.sh

* Removed MAX_FILE_SPECIES

* Update advanced.php

* Improve message

* Update scripts/advanced.php

Co-authored-by: Nachtzuster <Nachtzuster@users.noreply.github.com>

* Clean

* Update scripts/advanced.php

Co-authored-by: Nachtzuster <Nachtzuster@users.noreply.github.com>

* Typo

---------

Co-authored-by: root <root@db21ed7f-webtop.local.hass.io>
Co-authored-by: Nachtzuster <Nachtzuster@users.noreply.github.com>
This commit is contained in:
Alexandre
2025-04-23 18:41:59 +02:00
committed by GitHub
parent 1d8506bb93
commit 465e9739ce
2 changed files with 88 additions and 3 deletions
+13 -3
View File
@@ -5,9 +5,18 @@ error_reporting(E_ERROR);
require_once "scripts/common.php";
$home = get_home();
$config = get_config();
$user = get_user();
ensure_authenticated();
if (isset($_GET['run_species_count'])) {
echo "<script>";
$output = shell_exec("sudo -u $user ".$home."/BirdNET-Pi/scripts/disk_species_count.sh 2>&1");
$escaped_output = htmlspecialchars($output, ENT_QUOTES | ENT_SUBSTITUTE);
echo "alert(`$escaped_output`);";
echo "</script>";
}
if(isset($_GET['submit'])) {
$contents = file_get_contents('/etc/birdnet/birdnet.conf');
$restart_livestream = false;
@@ -307,14 +316,15 @@ $newconfig = get_config();
<label for="purge_threshold">Purge Threshold (Disk Used %):</label>
<input name="purge_threshold" type="number" style="width:6em;" min="20" max="99" step="1" value="<?php print($newconfig['PURGE_THRESHOLD']);?>"/>
<p>Defines how full the disk should be before the purge operations occur.<br>Note: This variable is still active if Keep is set. This means that the servies will be stopped at the purge threshold.</p><br>
<label for="max_files_species">Amount of files to keep for each species :</label>
<label for="max_files_species">Number of files to keep for each species :</label>
<input name="max_files_species" type="number" style="width:6em;" min="0" step="1" value="<?php print($newconfig['MAX_FILES_SPECIES']);?>"/>
</td></tr><tr><td>
If different than 0 (keep all), defines the maximum number of files to be kept for each species, with priority give to files with highest confidence.
This value does not take into account the last 7 days (protected by default).
If different than 0 (keep all), defines the number of files to keep for each species, with priority given to files with higher confidence. This value does not include files from the last 7 days, these new files are protected against auto-deletion.
</td></tr><tr><td>
Note only the spectrogram and audio files are deleted, the obsevation data remains in the database.
The files protected through the "lock" icon are also not affected.
<br>
<button type="submit" name="run_species_count" value="1" onclick="{this.innerHTML = 'Loading ... please wait.';this.classList.add('disabled')}"><i>[Click here for disk usage summary]</i></button>
</td></tr></table><br>
<table class="settingstable"><tr><td>