mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-26 08:06:52 +01:00 
			
		
		
		
	Enhance Node health column (#1023)
				
					
				
			* Make sure we are talking to a `Pelican Wings` instance * Enforce matching `token_id` * Refactor `NodeSystemInformation`
This commit is contained in:
		
							parent
							
								
									7d68da41f4
								
							
						
					
					
						commit
						d03366cf3d
					
				| @ -27,7 +27,7 @@ class ListNodes extends ListRecords | |||||||
|                     ->label('UUID') |                     ->label('UUID') | ||||||
|                     ->searchable() |                     ->searchable() | ||||||
|                     ->hidden(), |                     ->hidden(), | ||||||
|                 NodeHealthColumn::make('health')->label(trans('admin/node.table.health')), |                 NodeHealthColumn::make('health'), | ||||||
|                 TextColumn::make('name') |                 TextColumn::make('name') | ||||||
|                     ->label(trans('admin/node.table.name')) |                     ->label(trans('admin/node.table.name')) | ||||||
|                     ->icon('tabler-server-2') |                     ->icon('tabler-server-2') | ||||||
|  | |||||||
| @ -12,6 +12,8 @@ class NodeHealthColumn extends IconColumn | |||||||
|     { |     { | ||||||
|         parent::setUp(); |         parent::setUp(); | ||||||
| 
 | 
 | ||||||
|  |         $this->label(trans('admin/node.table.health')); | ||||||
|  | 
 | ||||||
|         $this->alignCenter(); |         $this->alignCenter(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -17,7 +17,22 @@ class DaemonConfigurationRepository extends DaemonRepository | |||||||
|     { |     { | ||||||
|         return $this->getHttpClient() |         return $this->getHttpClient() | ||||||
|             ->connectTimeout(3) |             ->connectTimeout(3) | ||||||
|             ->get('/api/system')->throw()->json(); |             ->get('/api/system') | ||||||
|  |             ->throwIf(function ($result) { | ||||||
|  |                 $header = $result->header('User-Agent'); | ||||||
|  |                 if ( | ||||||
|  |                     filled($header) && | ||||||
|  |                     preg_match('/^Pelican Wings\/v(?:\d+\.\d+\.\d+|develop) \(id:(\w*)\)$/', $header, $matches) && | ||||||
|  |                     array_get($matches, 1, '') !== $this->node->daemon_token_id | ||||||
|  |                 ) { | ||||||
|  |                     throw new ConnectionException($result->effectiveUri()->__toString() . ' does not match node token_id !'); | ||||||
|  |                 } | ||||||
|  |                 if (!$result->collect()->has(['architecture', 'cpu_count', 'kernel_version', 'os', 'version'])) { | ||||||
|  |                     throw new ConnectionException($result->effectiveUri()->__toString() . ' is not Pelican Wings !'); | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 return true; | ||||||
|  |             })->json(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | |||||||
| @ -1,33 +1,31 @@ | |||||||
| <div wire:poll.10s> | <div wire:poll.10s> | ||||||
|     @switch($node->systemInformation()['version'] ?? 'false') |     @php | ||||||
|         @case('false') |         $exception = $node->systemInformation()['exception'] ?? null; | ||||||
|             <x-filament::icon |         $version = $node->systemInformation()['version'] ?? null; | ||||||
|                 x-tooltip="{ |         $content = $exception ? 'Error connecting to node!<br>Check browser console for details.' : $version; | ||||||
|                     content: 'Error connecting to node!<br>Check browser console for details.', |         $icon = 'tabler-heart' . ($exception ? '-off' : 'beat'); | ||||||
|                     theme: $store.theme, |         $animated = $exception ? '' : 'animate-pulse'; | ||||||
|                     allowHTML: true, |         $condition = $exception ? 'danger' : 'success'; | ||||||
|                     placement: 'bottom', |         $class = ['fi-ta-icon-item', $sizeClasses, 'fi-color-custom text-custom-500 dark:text-custom-400', 'fi-color-'.$condition, $animated]; | ||||||
|                 }" |         $style = [Filament\Support\get_color_css_variables($condition, shades: [400, 500], alias: 'tables::columns.icon-column.item')]; | ||||||
|                 :icon="'tabler-heart-off'" |     @endphp | ||||||
|                 @class(['fi-ta-icon-item', $sizeClasses, 'fi-color-custom text-custom-500 dark:text-custom-400', 'fi-color-danger']) |         <x-filament::icon | ||||||
|                 @style([\Filament\Support\get_color_css_variables('danger', shades: [400, 500], alias: 'tables::columns.icon-column.item') => true]) |             x-tooltip="{ | ||||||
|             /> |                 content: '{{ $content }}', | ||||||
|  |                 theme: $store.theme, | ||||||
|  |                 allowHTML: true, | ||||||
|  |                 placement: 'bottom', | ||||||
|  |             }" | ||||||
|  |             :icon='$icon' | ||||||
|  |             @class($class) | ||||||
|  |             @style($style) | ||||||
|  |         /> | ||||||
|  |         @if($exception) | ||||||
|             @script |             @script | ||||||
|             <script> |             <script> | ||||||
|                 console.error(@json($node->systemInformation())); // TODO Make Purdy
 |                 console.error('{{ $exception }} '); | ||||||
|             </script> |             </script> | ||||||
|             @endscript |             @endscript | ||||||
|             @break |         @endif | ||||||
|         @default |     </div> | ||||||
|             <x-filament::icon |  | ||||||
|                 x-tooltip="{ |  | ||||||
|                     content: '{{ $node->systemInformation()['version'] }}', |  | ||||||
|                     theme: $store.theme, |  | ||||||
|                     placement: 'bottom', |  | ||||||
|                 }" |  | ||||||
|                 :icon="'tabler-heartbeat'" |  | ||||||
|                 @class(['fi-ta-icon-item', $sizeClasses, 'fi-color-custom text-custom-500 dark:text-custom-400', 'fi-color-success' => true]) |  | ||||||
|                 @style([\Filament\Support\get_color_css_variables('success', shades: [400, 500], alias: 'tables::columns.icon-column.item') => true]) |  | ||||||
|             /> |  | ||||||
|     @endswitch |  | ||||||
| </div> | </div> | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 MartinOscar
						MartinOscar