Add enums

This commit is contained in:
Lance Pioch 2024-04-18 03:48:30 -04:00
parent d642987df4
commit 256a961e1b
2 changed files with 66 additions and 0 deletions

View File

@ -11,4 +11,33 @@ enum ContainerStatus: string
case Paused = 'paused';
case Dead = 'dead';
case Removing = 'removing';
case Missing = 'missing';
public function icon(): string
{
return match ($this) {
self::Created => 'tabler-heart-plus',
self::Running => 'tabler-heartbeat',
self::Restarting => 'tabler-heart-bolt',
self::Exited => 'tabler-heart-exclamation',
self::Paused => 'tabler-heart-pause',
self::Dead => 'tabler-heart-x',
self::Removing => 'tabler-heart-down',
self::Missing => 'tabler-heart-question',
};
}
public function color(): string
{
return match ($this) {
self::Created => 'primary',
self::Running => 'success',
self::Restarting => 'info',
self::Exited => 'danger',
self::Paused => 'warning',
self::Dead => 'danger',
self::Removing => 'warning',
self::Missing => 'gray',
};
}
}

37
app/Enums/ServerState.php Normal file
View File

@ -0,0 +1,37 @@
<?php
namespace App\Enums;
enum ServerState: string
{
case None = 'none';
case Installing = 'installing';
case InstallFailed = 'install_failed';
case ReinstallFailed = 'reinstall_failed';
case Suspended = 'suspended';
case RestoringBackup = 'restoring_backup';
public function icon(): string
{
return match ($this) {
self::None => 'tabler-heart',
self::Installing => 'tabler-heart-bolt',
self::InstallFailed => 'tabler-heart-x',
self::ReinstallFailed => 'tabler-heart-x',
self::Suspended => 'tabler-heart-cancel',
self::RestoringBackup => 'tabler-heart-up',
};
}
public function color(): string
{
return match ($this) {
self::None => 'primary',
self::Installing => 'info',
self::InstallFailed => 'danger',
self::ReinstallFailed => 'danger',
self::Suspended => 'danger',
self::RestoringBackup => 'info',
};
}
}