show traffic details in admin and customer listings with the info-icon
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
|
||||
namespace Froxlor\UI\Callbacks;
|
||||
|
||||
use Froxlor\Traffic\Traffic;
|
||||
use Froxlor\PhpHelper;
|
||||
use Froxlor\Settings;
|
||||
|
||||
@@ -89,6 +90,28 @@ class ProgressBar
|
||||
*/
|
||||
public static function traffic(array $attributes): array
|
||||
{
|
||||
return self::pbData('traffic', $attributes['fields'], 1024, (int)Settings::Get('system.report_trafficmax'));
|
||||
$result = Traffic::getCustomerStats($attributes['fields'], 'currentmonth');
|
||||
$infotext = null;
|
||||
if (isset($result['metrics']['http'])) {
|
||||
$infotext = lng('panel.used') . ':' . PHP_EOL;
|
||||
$infotext .= 'http: ' . PhpHelper::sizeReadable($result['metrics']['http'], null, 'bi') . PHP_EOL;
|
||||
$infotext .= 'ftp: ' . PhpHelper::sizeReadable($result['metrics']['ftp'], null, 'bi') . PHP_EOL;
|
||||
$infotext .= 'mail: ' . PhpHelper::sizeReadable($result['metrics']['mail'], null, 'bi');
|
||||
}
|
||||
return self::pbData('traffic', $attributes['fields'], 1024, (int)Settings::Get('system.report_trafficmax'), $infotext);
|
||||
}
|
||||
|
||||
/**
|
||||
* get progressbar data for traffic for the admin overview
|
||||
* (key is to set 'adminsession' for the admin-users so the traffic-API selects
|
||||
* the correct customer data for the corresponsing admin/reseller)
|
||||
*
|
||||
* @param array $attributes ['fields']
|
||||
* @return array
|
||||
*/
|
||||
public static function traffic_admins(array $attributes): array
|
||||
{
|
||||
$attributes['fields']['adminsession'] = 1;
|
||||
return self::traffic($attributes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ return [
|
||||
'traffic' => [
|
||||
'label' => lng('customer.traffic'),
|
||||
'field' => 'traffic',
|
||||
'callback' => [ProgressBar::class, 'traffic'],
|
||||
'callback' => [ProgressBar::class, 'traffic_admins'],
|
||||
],
|
||||
'caneditphpsettings' => [
|
||||
'label' => lng('admin.caneditphpsettings'),
|
||||
|
||||
Reference in New Issue
Block a user