diff --git a/web/static/js/app.js b/web/static/js/app.js index 985009e8..bb0dcf62 100644 --- a/web/static/js/app.js +++ b/web/static/js/app.js @@ -90,3 +90,20 @@ function toggleEditMode(index) { } lucide.createIcons(); } + +// Format a byte count like core.system_utils.format_bytes (1024-based, 2 decimals, +// e.g. "42.93 GB"), so sizes computed in the browser match the ones the server renders. +// settings/cache.html declares its own GB/TB-only formatBytes() before this file loads; +// leave that one alone so its output does not change. +if (typeof window.formatBytes !== 'function') { + window.formatBytes = function formatBytes(bytes) { + var size = Number(bytes) || 0; + var units = ['B', 'KB', 'MB', 'GB', 'TB']; + var i = 0; + while (size >= 1024 && i < units.length - 1) { + size /= 1024; + i++; + } + return i === 0 ? Math.round(size) + ' B' : size.toFixed(2) + ' ' + units[i]; + }; +} diff --git a/web/templates/maintenance/index.html b/web/templates/maintenance/index.html index 2c4eabd2..38d5261f 100644 --- a/web/templates/maintenance/index.html +++ b/web/templates/maintenance/index.html @@ -119,6 +119,34 @@