mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 20:16:51 +01:00 
			
		
		
		
	 d3da1b0a58
			
		
	
	
		d3da1b0a58
		
			
		
	
	
	
	
		
			
			* Update Console Updates console to be more better <3. Light Mode still needs some love, haven't figured that out with filaments light/dark options yet as it does not use the "bright<color>" colors... * Add overflow to... Everything? * Oops, Add Name label back * Actually handle Transfer Status & remove useless switch * Use switch case * Readonly command input if server can't receive one * lint * Update app/Filament/Server/Widgets/ServerConsole.php Co-authored-by: Boy132 <Boy132@users.noreply.github.com> * Use filament::icon instead of raw svg * Update resources/views/filament/components/server-console.blade.php Co-authored-by: Boy132 <Boy132@users.noreply.github.com> --------- Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com> Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
		
			
				
	
	
		
			47 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Filament\Server\Widgets;
 | |
| 
 | |
| use App\Models\Server;
 | |
| use Carbon\CarbonInterface;
 | |
| use Filament\Widgets\StatsOverviewWidget;
 | |
| use Filament\Widgets\StatsOverviewWidget\Stat;
 | |
| use Illuminate\Support\Str;
 | |
| 
 | |
| class ServerOverview extends StatsOverviewWidget
 | |
| {
 | |
|     protected static ?string $pollingInterval = '1s';
 | |
| 
 | |
|     public ?Server $server = null;
 | |
| 
 | |
|     protected function getStats(): array
 | |
|     {
 | |
|         return [
 | |
|             Stat::make('Name', $this->server->name)
 | |
|                 ->description($this->server->description)
 | |
|                 ->extraAttributes([
 | |
|                     'class' => 'overflow-x-auto',
 | |
|                 ]),
 | |
|             Stat::make('Status', $this->status()),
 | |
|             Stat::make('Address', $this->server->allocation->address)
 | |
|                 ->extraAttributes([
 | |
|                     'class' => 'overflow-x-auto',
 | |
|                 ]),
 | |
|         ];
 | |
|     }
 | |
| 
 | |
|     private function status(): string
 | |
|     {
 | |
|         $status = Str::title($this->server->condition);
 | |
|         $uptime = collect(cache()->get("servers.{$this->server->id}.uptime"))->last() ?? 0;
 | |
| 
 | |
|         if ($uptime === 0) {
 | |
|             return $status;
 | |
|         }
 | |
| 
 | |
|         $uptime = now()->subMillis($uptime)->diffForHumans(syntax: CarbonInterface::DIFF_ABSOLUTE, short: true, parts: 2);
 | |
| 
 | |
|         return "$status ($uptime)";
 | |
|     }
 | |
| }
 |