Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

pelican-dev/panel

1722 stars
3 code files
View pelican-dev/panel on GitHub

app/helpers.php

Open in GitHub
// ...
 
if (!function_exists('convert_bytes_to_readable')) {
function convert_bytes_to_readable(int $bytes, int $decimals = 2, ?int $base = null): string
{
$conversionUnit = config('panel.use_binary_prefix') ? 1024 : 1000;
$suffix = config('panel.use_binary_prefix') ? ['Bytes', 'KiB', 'MiB', 'GiB', 'TiB'] : ['Bytes', 'KB', 'MB', 'GB', 'TB'];
 
if ($bytes <= 0) {
return '0 ' . $suffix[0];
}
 
$fromBase = log($bytes) / log($conversionUnit);
$base ??= floor($fromBase);
 
return Number::format(pow($conversionUnit, $fromBase - $base), $decimals, locale: auth()->user()->language) . ' ' . $suffix[$base];
}
}
 
// ...

composer.json

Open in GitHub
{
// ...
"autoload": {
"files": [
"app/helpers.php"
],
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/Factories/",
"Database\\Seeders\\": "database/Seeders/"
}
},
// ...
}

app/Filament/Admin/Resources/NodeResource/Widgets/NodeStorageChart.php

Open in GitHub
class NodeStorageChart extends ChartWidget
{
// ...
 
public function getHeading(): string
{
$used = convert_bytes_to_readable($this->node->statistics()['disk_used']);
$total = convert_bytes_to_readable($this->node->statistics()['disk_total']);
 
return trans('admin/node.disk_chart', ['used' => $used, 'total' => $total]);
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.