From b11f466a0a2869e8cdec310165000ee1c8cb531e Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Wed, 23 Feb 2022 09:27:52 +0100 Subject: [PATCH] progressbar callback to behave like 0.10.x Signed-off-by: Michael Kaufmann --- lib/Froxlor/UI/Callbacks/ProgressBar.php | 97 +++++++++++++++++------- 1 file changed, 70 insertions(+), 27 deletions(-) diff --git a/lib/Froxlor/UI/Callbacks/ProgressBar.php b/lib/Froxlor/UI/Callbacks/ProgressBar.php index 896aebe8..17f71e9d 100644 --- a/lib/Froxlor/UI/Callbacks/ProgressBar.php +++ b/lib/Froxlor/UI/Callbacks/ProgressBar.php @@ -1,4 +1,5 @@ $attributes['customerid'] + )); - return '
' . $text . '
'; - } + if ($usages != true) { + $usages = [ + 'webspace' => 0, + 'mailspace' => 0, + 'dbspace' => 0 + ]; + } - /** - * TODO: use twig for html templates ... - * - * @param string $data - * @param array $attributes - * @return string - */ - public static function traffic(string $data, array $attributes): string - { - $percentage = $attributes['traffic_used'] ? round(100 * $attributes['traffic_used'] / $attributes['traffic']) : 0; - $text = Number::traffic($attributes['traffic_used']) . ' / ' . Number::traffic($attributes['traffic']); + $infotext = \Froxlor\UI\Panel\UI::getLng('panel.used') . ':
'; + $infotext .= 'web: ' . \Froxlor\PhpHelper::sizeReadable($usages['webspace'] * 1024, null, 'bi') . '
'; + $infotext .= 'mail: ' . \Froxlor\PhpHelper::sizeReadable($usages['mailspace'] * 1024, null, 'bi') . '
'; + $infotext .= 'mysql: ' . \Froxlor\PhpHelper::sizeReadable($usages['dbspace'] * 1024, null, 'bi'); + } - return '
' . $text . '
'; - } -} \ No newline at end of file + $disk_percent = 0; + $style = 'bg-info'; + $text = \Froxlor\PhpHelper::sizeReadable($attributes['diskspace_used'] * 1024, null, 'bi') . ' / ' . \Froxlor\UI\Panel\UI::getLng('customer.unlimited'); + if ((int) $attributes['diskspace'] >= 0) { + if (($attributes['diskspace'] / 100) * (int)\Froxlor\Settings::Get('system.report_webmax') < $attributes['diskspace_used']) { + $style = 'bg-danger'; + } elseif (($attributes['diskspace'] / 100) * ((int)\Froxlor\Settings::Get('system.report_webmax') - 15) < $attributes['diskspace_used']) { + $style = 'bg-warning'; + } + $disk_percent = round(($attributes['diskspace_used'] * 100) / ($attributes['diskspace'] == 0 ? 1 : $attributes['diskspace']), 0); + if ($disk_percent > 100) { + $disk_percent = 100; + } + $text = \Froxlor\PhpHelper::sizeReadable($attributes['diskspace_used'] * 1024, null, 'bi') . ' / ' . \Froxlor\PhpHelper::sizeReadable($attributes['diskspace'] * 1024, null, 'bi'); + } + + if (!empty($infotext)) { + $infotext = ' '; + } + return '
' . $infotext . $text . '
'; + } + + /** + * TODO: use twig for html templates ... + * + * @param string $data + * @param array $attributes + * @return string + */ + public static function traffic(string $data, array $attributes): string + { + $percentage = $attributes['traffic_used'] ? round(100 * $attributes['traffic_used'] / $attributes['traffic']) : 0; + $text = Number::traffic($attributes['traffic_used']) . ' / ' . Number::traffic($attributes['traffic']); + + return '
' . $text . '
'; + } +}