progressbar callback to behave like 0.10.x
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Froxlor\UI\Callbacks;
|
namespace Froxlor\UI\Callbacks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,10 +28,52 @@ class ProgressBar
|
|||||||
*/
|
*/
|
||||||
public static function diskspace(string $data, array $attributes): string
|
public static function diskspace(string $data, array $attributes): string
|
||||||
{
|
{
|
||||||
$percentage = $attributes['diskspace_used'] ? round(100 * $attributes['diskspace_used'] / $attributes['diskspace']) : 0;
|
$infotext = '';
|
||||||
$text = Number::diskspace($attributes['diskspace_used']) . ' / ' . Number::diskspace($attributes['diskspace']);
|
if (isset($attributes['customerid'])) {
|
||||||
|
// get disk-space usages for web, mysql and mail
|
||||||
|
$usages_stmt = \Froxlor\Database\Database::prepare("
|
||||||
|
SELECT * FROM `" . TABLE_PANEL_DISKSPACE . "`
|
||||||
|
WHERE `customerid` = :cid
|
||||||
|
ORDER BY `stamp` DESC LIMIT 1
|
||||||
|
");
|
||||||
|
$usages = \Froxlor\Database\Database::pexecute_first($usages_stmt, array(
|
||||||
|
'cid' => $attributes['customerid']
|
||||||
|
));
|
||||||
|
|
||||||
return '<div class="progress progress-thin"><div class="progress-bar bg-info" style="width: ' . $percentage . '%;"></div></div><div class="text-end">' . $text . '</div>';
|
if ($usages != true) {
|
||||||
|
$usages = [
|
||||||
|
'webspace' => 0,
|
||||||
|
'mailspace' => 0,
|
||||||
|
'dbspace' => 0
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$infotext = \Froxlor\UI\Panel\UI::getLng('panel.used') . ':<br>';
|
||||||
|
$infotext .= 'web: ' . \Froxlor\PhpHelper::sizeReadable($usages['webspace'] * 1024, null, 'bi') . '<br>';
|
||||||
|
$infotext .= 'mail: ' . \Froxlor\PhpHelper::sizeReadable($usages['mailspace'] * 1024, null, 'bi') . '<br>';
|
||||||
|
$infotext .= 'mysql: ' . \Froxlor\PhpHelper::sizeReadable($usages['dbspace'] * 1024, null, 'bi');
|
||||||
|
}
|
||||||
|
|
||||||
|
$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 = '<i class="fa-solid fa-circle-info" title="' . $infotext . '"></i> ';
|
||||||
|
}
|
||||||
|
return '<div class="progress progress-thin"><div class="progress-bar bg-info" style="width: ' . $disk_percent . '%;"></div></div><div class="text-end">' . $infotext . $text . '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user