From d2e6e003a7b6422ea68ea14f10f2c5091502bfa1 Mon Sep 17 00:00:00 2001 From: hppanpaliya Date: Tue, 17 Oct 2023 21:59:18 -0400 Subject: [PATCH] Toggleable Disk Space Usage Display This commit builds upon the previous feature of displaying disk space information by adding a toggle option in the settings to show or hide disk space usage details. #### Changes: - Added a new setting under the settings section allowing users to toggle the display of disk space usage information. - Updated the disk space display logic to check the setting before fetching and displaying disk space information. #### Code Additions: - Introduced a new checkbox under the settings section to allow users to toggle the display of disk space usage. - Implemented a check for the `show_disk_usage` setting before executing disk space calculation and display logic. #### Benefits: - Provides users with the flexibility to choose whether or not to display disk space information based on their preferences or needs. - Helps in reducing unnecessary disk space calculations when the information is not needed, potentially improving performance. - Maintains a clean and uncluttered UI by allowing users to hide disk space information when it's not required. --- tinyfilemanager.php | 52 +++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/tinyfilemanager.php b/tinyfilemanager.php index e1e7a0f..044042d 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -1,6 +1,6 @@ data['hide_Cols']) ? $cfg->data['hide_Cols'] : true; // Theme $theme = isset($cfg->data['theme']) ? $cfg->data['theme'] : 'light'; +$show_disk_usage = isset($cfg->data['show_disk_usage']) ? $cfg->data['show_disk_usage'] : true; + define('FM_THEME', $theme); //available languages @@ -539,6 +541,7 @@ if ((isset($_SESSION[FM_SESSION_ID]['logged'], $auth_users[$_SESSION[FM_SESSION_ $erp = isset($_POST['js-error-report']) && $_POST['js-error-report'] == "true" ? true : false; $shf = isset($_POST['js-show-hidden']) && $_POST['js-show-hidden'] == "true" ? true : false; $hco = isset($_POST['js-hide-cols']) && $_POST['js-hide-cols'] == "true" ? true : false; + $sdu = isset($_POST['js-show-usage']) && $_POST['js-show-usage'] == "true" ? true : false; $te3 = $_POST['js-theme-3']; if ($cfg->data['lang'] != $newLng) { @@ -557,6 +560,10 @@ if ((isset($_SESSION[FM_SESSION_ID]['logged'], $auth_users[$_SESSION[FM_SESSION_ $cfg->data['show_hidden'] = $shf; $show_hidden_files = $shf; } + if ($cfg->data['show_disk_usage'] != $sdu) { + $cfg->data['show_disk_usage'] = $sdu; + $show_disk_usage = $sdu; + } if ($cfg->data['hide_Cols'] != $hco) { $cfg->data['hide_Cols'] = $hco; $hide_Cols = $hco; @@ -1553,6 +1560,16 @@ if (isset($_GET['settings']) && !FM_READONLY) { +
+ +
+
+ /> +
+
+
+ +
@@ -2202,25 +2219,31 @@ $tableTheme = (FM_THEME == "dark") ? "text-white bg-dark table-dark" : "bg-white - - - - '.fm_get_filesize($all_files_size).'' ?> - ' .$total_used_size.''; ?> - ' .$free_size.''; ?> + ' .$total_used_size.''; + echo lng('RemainingSpace').': ' .$free_size.''; + } + ?> '.$num_files.'' ?> '.$num_folders.'' ?> @@ -4304,6 +4327,7 @@ function lng($txt) { $tr['en']['File or folder with this path already exists'] = 'File or folder with this path already exists'; $tr['en']['RemainingSpace'] = 'Remaining Space'; $tr['en']['UsedSpace'] = 'Used Space'; + $tr['en']['ShowDiskUsage'] = 'Show Disk Usage'; $i18n = fm_get_translations($tr); $tr = $i18n ? $i18n : $tr;