update tabellisting and callbacks, make columns invisible
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
namespace Froxlor\UI\Callbacks;
|
||||
|
||||
use Froxlor\PhpHelper;
|
||||
use Froxlor\UI\Panel\UI;
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||
*
|
||||
* For the full copyright and license information, please view the COPYING
|
||||
* file that was distributed with this source code. You can also view the
|
||||
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @author Maurice Preuß <hello@envoyr.com>
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Listing
|
||||
*
|
||||
*/
|
||||
class Number
|
||||
{
|
||||
/**
|
||||
* Formats the diskspace to human-readable number
|
||||
*
|
||||
* @param string $data
|
||||
* @return string
|
||||
*/
|
||||
public static function diskspace(string $data): string
|
||||
{
|
||||
return $data >= 0 ? PhpHelper::sizeReadable($data * 1024, null, 'bi') : UI::getLng('panel.unlimited');
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the traffic to human-readable number
|
||||
*
|
||||
* @param string $data
|
||||
* @return string
|
||||
*/
|
||||
public static function traffic(string $data): string
|
||||
{
|
||||
return $data >= 0 ? PhpHelper::sizeReadable($data * (1024 * 1024), null, 'bi') : UI::getLng('panel.unlimited');
|
||||
}
|
||||
}
|
||||
@@ -31,30 +31,12 @@ class ProgressBar
|
||||
*/
|
||||
public static function diskspace(string $data, array $attributes): array
|
||||
{
|
||||
$infotext = '';
|
||||
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']
|
||||
));
|
||||
|
||||
if ($usages != true) {
|
||||
$usages = [
|
||||
'webspace' => 0,
|
||||
'mailspace' => 0,
|
||||
'dbspace' => 0
|
||||
];
|
||||
}
|
||||
|
||||
$infotext = null;
|
||||
if (isset($attributes['webspace_used']) && isset($attributes['mailspace_used']) && isset($attributes['dbspace_used'])) {
|
||||
$infotext = UI::getLng('panel.used') . ':<br>';
|
||||
$infotext .= 'web: ' . PhpHelper::sizeReadable($usages['webspace'] * 1024, null, 'bi') . '<br>';
|
||||
$infotext .= 'mail: ' . PhpHelper::sizeReadable($usages['mailspace'] * 1024, null, 'bi') . '<br>';
|
||||
$infotext .= 'mysql: ' . PhpHelper::sizeReadable($usages['dbspace'] * 1024, null, 'bi');
|
||||
$infotext .= 'web: ' . PhpHelper::sizeReadable($attributes['webspace_used'] * 1024, null, 'bi') . '<br>';
|
||||
$infotext .= 'mail: ' . PhpHelper::sizeReadable($attributes['mailspace_used'] * 1024, null, 'bi') . '<br>';
|
||||
$infotext .= 'mysql: ' . PhpHelper::sizeReadable($attributes['dbspace_used'] * 1024, null, 'bi');
|
||||
}
|
||||
|
||||
return self::pbData('diskspace', $attributes, 1024, (int)\Froxlor\Settings::Get('system.report_webmax'), $infotext);
|
||||
@@ -79,7 +61,7 @@ class ProgressBar
|
||||
{
|
||||
$percent = 0;
|
||||
$style = 'bg-info';
|
||||
$text = PhpHelper::sizeReadable($attributes[$field . '_used'] * $size_factor, null, 'bi') . ' / ' . UI::getLng('customer.unlimited');
|
||||
$text = PhpHelper::sizeReadable($attributes[$field . '_used'] * $size_factor, null, 'bi') . ' / ' . UI::getLng('panel.unlimited');
|
||||
if ((int) $attributes[$field] >= 0) {
|
||||
if (($attributes[$field] / 100) * $report_max < $attributes[$field . '_used']) {
|
||||
$style = 'bg-danger';
|
||||
|
||||
@@ -23,12 +23,20 @@ class Listing
|
||||
$items = $collection->getData()['list'];
|
||||
$table = [];
|
||||
|
||||
foreach ($tabellisting['visible_columns'] as $visible_column) {
|
||||
foreach ($tabellisting['visible_columns'] as $key => $visible_column) {
|
||||
if (isset($tabellisting['columns'][$visible_column]['visible']) && !$tabellisting['columns'][$visible_column]['visible']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$table['th'][] = $tabellisting['columns'][$visible_column]['label'];
|
||||
}
|
||||
|
||||
foreach ($items as $key => $item) {
|
||||
foreach ($tabellisting['visible_columns'] as $visible_column) {
|
||||
if (isset($tabellisting['columns'][$visible_column]['visible']) && !$tabellisting['columns'][$visible_column]['visible']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$format_callback = $tabellisting['columns'][$visible_column]['format_callback'] ?? null;
|
||||
$column = $tabellisting['columns'][$visible_column]['column'];
|
||||
$data = self::getMultiArrayFromString($item, $column);
|
||||
|
||||
Reference in New Issue
Block a user