mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-15 09:12:32 -04:00
Co-authored-by: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Co-authored-by: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: rosslh <ross@rosshill.ca>
40 lines
1.0 KiB
PHP
40 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Support\Metrics;
|
|
|
|
class PressureLevel
|
|
{
|
|
public static function for(?float $percent, string $kind = 'default'): string
|
|
{
|
|
if ($percent === null) {
|
|
return 'ok';
|
|
}
|
|
|
|
[$warn, $error] = $kind === 'disk' ? [80.0, 90.0] : [70.0, 90.0];
|
|
|
|
return match (true) {
|
|
$percent >= $error => 'error',
|
|
$percent >= $warn => 'warning',
|
|
default => 'ok',
|
|
};
|
|
}
|
|
|
|
public static function textClass(string $level): string
|
|
{
|
|
return match ($level) {
|
|
'error' => 'text-red-500 dark:text-red-400',
|
|
'warning' => 'text-orange-500 dark:text-warning',
|
|
default => 'text-black dark:text-fg',
|
|
};
|
|
}
|
|
|
|
public static function barClass(string $level): string
|
|
{
|
|
return match ($level) {
|
|
'error' => 'bg-red-500 dark:bg-red-400',
|
|
'warning' => 'bg-orange-500 dark:bg-warning',
|
|
default => 'bg-neutral-400 dark:bg-white/30',
|
|
};
|
|
}
|
|
}
|