mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 04:04:45 +02: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')
|
||||
->searchable()
|
||||
->hidden(),
|
||||
NodeHealthColumn::make('health')->label(trans('admin/node.table.health')),
|
||||
NodeHealthColumn::make('health'),
|
||||
TextColumn::make('name')
|
||||
->label(trans('admin/node.table.name'))
|
||||
->icon('tabler-server-2')
|
||||
|
@ -12,6 +12,8 @@ class NodeHealthColumn extends IconColumn
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->label(trans('admin/node.table.health'));
|
||||
|
||||
$this->alignCenter();
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,22 @@ class DaemonConfigurationRepository extends DaemonRepository
|
||||
{
|
||||
return $this->getHttpClient()
|
||||
->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>
|
||||
@switch($node->systemInformation()['version'] ?? 'false')
|
||||
@case('false')
|
||||
@php
|
||||
$exception = $node->systemInformation()['exception'] ?? null;
|
||||
$version = $node->systemInformation()['version'] ?? null;
|
||||
$content = $exception ? 'Error connecting to node!<br>Check browser console for details.' : $version;
|
||||
$icon = 'tabler-heart' . ($exception ? '-off' : 'beat');
|
||||
$animated = $exception ? '' : 'animate-pulse';
|
||||
$condition = $exception ? 'danger' : 'success';
|
||||
$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')];
|
||||
@endphp
|
||||
<x-filament::icon
|
||||
x-tooltip="{
|
||||
content: 'Error connecting to node!<br>Check browser console for details.',
|
||||
content: '{{ $content }}',
|
||||
theme: $store.theme,
|
||||
allowHTML: true,
|
||||
placement: 'bottom',
|
||||
}"
|
||||
:icon="'tabler-heart-off'"
|
||||
@class(['fi-ta-icon-item', $sizeClasses, 'fi-color-custom text-custom-500 dark:text-custom-400', 'fi-color-danger'])
|
||||
@style([\Filament\Support\get_color_css_variables('danger', shades: [400, 500], alias: 'tables::columns.icon-column.item') => true])
|
||||
:icon='$icon'
|
||||
@class($class)
|
||||
@style($style)
|
||||
/>
|
||||
@if($exception)
|
||||
@script
|
||||
<script>
|
||||
console.error(@json($node->systemInformation())); // TODO Make Purdy
|
||||
console.error('{{ $exception }} ');
|
||||
</script>
|
||||
@endscript
|
||||
@break
|
||||
@default
|
||||
<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
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user