diff --git a/lib/Froxlor/UI/Callbacks/ProgressBar.php b/lib/Froxlor/UI/Callbacks/ProgressBar.php
index 17f71e9d..9338753a 100644
--- a/lib/Froxlor/UI/Callbacks/ProgressBar.php
+++ b/lib/Froxlor/UI/Callbacks/ProgressBar.php
@@ -52,28 +52,12 @@ class ProgressBar
$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');
- }
- $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 . '
';
+
+ $pbdata = self::pbData('diskspace', $attributes, 1024, (int)\Froxlor\Settings::Get('system.report_webmax'));
+ return '' . $infotext . $pbdata['text'] . '
';
}
/**
@@ -85,9 +69,35 @@ class ProgressBar
*/
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']);
+ $pbdata = self::pbData('traffic', $attributes, 1024 * 1024, (int)\Froxlor\Settings::Get('system.report_trafficmax'));
+ return '' . $pbdata['text'] . '
';
+ }
- return '' . $text . '
';
+ /**
+ * do needed calculations
+ */
+ private static function pbData(string $field, array $attributes, int $size_factor = 1024, int $report_max = 90): array
+ {
+ $percent = 0;
+ $style = 'bg-info';
+ $text = \Froxlor\PhpHelper::sizeReadable($attributes[$field . '_used'] * $size_factor, null, 'bi') . ' / ' . \Froxlor\UI\Panel\UI::getLng('customer.unlimited');
+ if ((int) $attributes[$field] >= 0) {
+ if (($attributes[$field] / 100) * $report_max < $attributes[$field . '_used']) {
+ $style = 'bg-danger';
+ } elseif (($attributes[$field] / 100) * ($report_max - 15) < $attributes[$field . '_used']) {
+ $style = 'bg-warning';
+ }
+ $percent = round(($attributes[$field . '_used'] * 100) / ($attributes[$field] == 0 ? 1 : $attributes[$field]), 0);
+ if ($percent > 100) {
+ $percent = 100;
+ }
+ $text = \Froxlor\PhpHelper::sizeReadable($attributes[$field . '_used'] * $size_factor, null, 'bi') . ' / ' . \Froxlor\PhpHelper::sizeReadable($attributes[$field] * $size_factor, null, 'bi');
+ }
+
+ return [
+ 'percent' => $percent,
+ 'style' => $style,
+ 'text' => $text
+ ];
}
}
diff --git a/lib/tablelisting/admin/admin/tablelisting.admin.php b/lib/tablelisting/admin/admin/tablelisting.admin.php
index 6a134ea8..709fa713 100644
--- a/lib/tablelisting/admin/admin/tablelisting.admin.php
+++ b/lib/tablelisting/admin/admin/tablelisting.admin.php
@@ -17,84 +17,67 @@
*/
return [
- 'admin_list' => [
- 'title' => $lng['admin']['admin'],
- 'icon' => 'fa-solid fa-user',
- 'columns' => [
- 'adminid' => [
- 'label' => '#',
- 'column' => 'adminid',
- 'sortable' => true,
- ],
- 'loginname' => [
- 'label' => $lng['login']['username'],
- 'column' => 'loginname',
- 'sortable' => true,
- ],
- 'name' => [
- 'label' => $lng['customer']['name'],
- 'column' => 'name',
- ],
- 'diskspace' => [
- 'label' => $lng['customer']['diskspace'],
- 'column' => 'diskspace',
- 'format_callback' => [\Froxlor\UI\Callbacks\Number::class, 'diskspace'],
- ],
- 'diskspace_used' => [
- 'label' => $lng['customer']['diskspace'] . ' (' . $lng['panel']['used'] . ')',
- 'column' => 'diskspace_used',
- 'format_callback' => [\Froxlor\UI\Callbacks\ProgressBar::class, 'diskspace'],
- ],
- 'traffic' => [
- 'label' => $lng['customer']['traffic'],
- 'column' => 'traffic',
- 'format_callback' => [\Froxlor\UI\Callbacks\Number::class, 'traffic'],
- ],
- 'traffic_used' => [
- 'label' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')',
- 'column' => 'traffic_used',
- 'format_callback' => [\Froxlor\UI\Callbacks\ProgressBar::class, 'traffic'],
- ],
- 'deactivated' => [
- 'label' => $lng['admin']['deactivated'],
- 'column' => 'deactivated',
- 'format_callback' => [\Froxlor\UI\Callbacks\Text::class, 'boolean'],
- ],
- ],
- 'visible_columns' => \Froxlor\UI\Listing::getVisibleColumnsForListing('admin_list', [
- 'loginname',
- 'name',
- 'diskspace',
- 'diskspace_used',
- 'traffic',
- 'traffic_used',
- 'deactivated',
- ]),
- 'actions' => [
- 'delete' => [
- 'icon' => 'fa fa-trash',
- 'href' => '#',
- ],
- 'show' => [
- 'text' => 'Show',
- 'href' => '#',
- ]
- ],
- 'contextual_class' => [
- 'deactivated' => [
- 'value' => true,
- 'return' => 'bg-secondary'
- ],
- 'diskspace_used' => [
- 'column' => 'diskspace',
- 'operator' => '>=',
- 'return' => 'bg-danger'
- ],
- 'traffic_used' => [
- 'column' => 'traffic',
- 'operator' => '>=',
- 'return' => 'bg-danger'
- ],
- ]
- ]
+ 'admin_list' => [
+ 'title' => $lng['admin']['admin'],
+ 'icon' => 'fa-solid fa-user',
+ 'columns' => [
+ 'adminid' => [
+ 'label' => '#',
+ 'column' => 'adminid',
+ 'sortable' => true,
+ ],
+ 'loginname' => [
+ 'label' => $lng['login']['username'],
+ 'column' => 'loginname',
+ 'sortable' => true,
+ ],
+ 'name' => [
+ 'label' => $lng['customer']['name'],
+ 'column' => 'name',
+ ],
+ 'customers_used' => [
+ 'label' => $lng['admin']['customers'],
+ 'column' => 'customers_used'
+ ],
+ 'diskspace' => [
+ 'label' => $lng['customer']['diskspace'],
+ 'column' => 'diskspace',
+ 'format_callback' => [\Froxlor\UI\Callbacks\ProgressBar::class, 'diskspace'],
+ ],
+ 'traffic' => [
+ 'label' => $lng['customer']['traffic'],
+ 'column' => 'traffic',
+ 'format_callback' => [\Froxlor\UI\Callbacks\ProgressBar::class, 'traffic'],
+ ],
+ 'deactivated' => [
+ 'label' => $lng['admin']['deactivated'],
+ 'column' => 'deactivated',
+ 'format_callback' => [\Froxlor\UI\Callbacks\Text::class, 'boolean'],
+ ],
+ ],
+ 'visible_columns' => \Froxlor\UI\Listing::getVisibleColumnsForListing('admin_list', [
+ 'loginname',
+ 'name',
+ 'customers_used',
+ 'diskspace',
+ 'traffic',
+ 'deactivated',
+ ]),
+ 'actions' => [
+ 'delete' => [
+ 'icon' => 'fa fa-trash',
+ 'href' => '#',
+ ],
+ 'edit' => [
+ 'text' => 'fa fa-pen',
+ 'href' => '#',
+ ]
+ ],
+ 'contextual_class' => [
+ 'deactivated' => [
+ 'value' => true,
+ 'return' => 'bg-secondary'
+ ]
+ ]
+ ]
];
diff --git a/lib/tablelisting/admin/admin/tablelisting.customer.php b/lib/tablelisting/admin/admin/tablelisting.customer.php
index c189062d..1296e181 100644
--- a/lib/tablelisting/admin/admin/tablelisting.customer.php
+++ b/lib/tablelisting/admin/admin/tablelisting.customer.php
@@ -48,21 +48,11 @@ return [
'c.diskspace' => [
'label' => $lng['customer']['diskspace'],
'column' => 'diskspace',
- 'format_callback' => [\Froxlor\UI\Callbacks\Number::class, 'diskspace'],
- ],
- 'c.diskspace_used' => [
- 'label' => $lng['customer']['diskspace'] . ' (' . $lng['panel']['used'] . ')',
- 'column' => 'diskspace_used',
'format_callback' => [\Froxlor\UI\Callbacks\ProgressBar::class, 'diskspace'],
],
'c.traffic' => [
'label' => $lng['customer']['traffic'],
'column' => 'traffic',
- 'format_callback' => [\Froxlor\UI\Callbacks\Number::class, 'traffic'],
- ],
- 'c.traffic_used' => [
- 'label' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')',
- 'column' => 'traffic_used',
'format_callback' => [\Froxlor\UI\Callbacks\ProgressBar::class, 'traffic'],
],
],
@@ -73,9 +63,7 @@ return [
'c.firstname',
'c.company',
'c.diskspace',
- 'c.diskspace_used',
'c.traffic',
- 'c.traffic_used',
]),
]
];