From 021ed4dfa50010ac2633f0507c984f858dec0627 Mon Sep 17 00:00:00 2001 From: master3395 Date: Mon, 19 Jan 2026 18:20:21 +0100 Subject: [PATCH] Add AngularJS filesize filter to fix createUser page error --- .../baseTemplate/custom-js/system-status.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/static/baseTemplate/custom-js/system-status.js b/static/baseTemplate/custom-js/system-status.js index 31af4cc6f..015740e67 100644 --- a/static/baseTemplate/custom-js/system-status.js +++ b/static/baseTemplate/custom-js/system-status.js @@ -37,6 +37,26 @@ function randomPassword(length) { var app = angular.module('CyberCP', []); +// Filesize filter for formatting bytes to human-readable format +app.filter('filesize', function() { + return function(bytes) { + if (bytes === null || bytes === undefined || isNaN(bytes)) { + return '0 B'; + } + bytes = parseInt(bytes, 10); + if (bytes === 0) { + return '0 B'; + } + var k = 1024; + var sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + var i = Math.floor(Math.log(bytes) / Math.log(k)); + var size = (bytes / Math.pow(k, i)).toFixed(2); + // Remove trailing zeros + size = parseFloat(size).toString(); + return size + ' ' + sizes[i]; + }; +}); + var globalScope; function GlobalRespSuccess(response) {