This commit is contained in:
Thomas Peterson 2025-11-17 13:22:20 +01:00
parent fdac5a8b84
commit 21bc637ced
3 changed files with 35 additions and 10 deletions

View File

@ -31,6 +31,7 @@ class HetznerService
'domains' => [], 'domains' => [],
'needs_reboot' => 'unbekannt', 'needs_reboot' => 'unbekannt',
'updates_available' => 'unbekannt', 'updates_available' => 'unbekannt',
'os_version' => 'unbekannt',
]; ];
} }
@ -61,6 +62,7 @@ class HetznerService
'domains' => [], 'domains' => [],
'needs_reboot' => 'nein', 'needs_reboot' => 'nein',
'updates_available' => 'nein', 'updates_available' => 'nein',
'os_version' => 'Ubuntu 22.04 LTS',
]; ];
} }
return $testData; return $testData;

View File

@ -81,22 +81,23 @@ class ServerListTab
// Table // Table
$this->table = new Table(style: ' flex-1'); $this->table = new Table(style: ' flex-1');
$this->table->setColumns([ $this->table->setColumns([
['key' => 'id', 'title' => 'ID', 'width' => 80], ['key' => 'id', 'title' => 'ID', 'width' => 100],
['key' => 'name', 'title' => 'Name'], ['key' => 'name', 'title' => 'Name'],
['key' => 'status', 'title' => 'Status', 'width' => 100], ['key' => 'status', 'title' => 'Status', 'width' => 90],
['key' => 'type', 'title' => 'Typ', 'width' => 80], ['key' => 'type', 'title' => 'Typ', 'width' => 80],
['key' => 'ipv4', 'title' => 'IPv4', 'width' => 160], ['key' => 'ipv4', 'title' => 'IPv4', 'width' => 140],
['key' => 'docker_status', 'title' => 'Docker', 'width' => 90], ['key' => 'docker_status', 'title' => 'Docker', 'width' => 80],
['key' => 'os_version', 'title' => 'Ubuntu', 'width' => 180],
[ [
'key' => 'needs_reboot', 'key' => 'needs_reboot',
'title' => 'Neustart', 'title' => 'Neustart',
'width' => 150, 'width' => 110,
'render' => [$this, 'renderNeedsRebootCell'], 'render' => [$this, 'renderNeedsRebootCell'],
], ],
[ [
'key' => 'updates_available', 'key' => 'updates_available',
'title' => 'Updates', 'title' => 'Updates',
'width' => 150, 'width' => 130,
'render' => [$this, 'renderUpdatesCell'], 'render' => [$this, 'renderUpdatesCell'],
], ],
]); ]);
@ -293,6 +294,7 @@ class ServerListTab
'docker_error' => null, 'docker_error' => null,
'needs_reboot' => 'unbekannt', 'needs_reboot' => 'unbekannt',
'updates_available' => 'unbekannt', 'updates_available' => 'unbekannt',
'os_version' => 'unbekannt',
], $row), $result['servers']); ], $row), $result['servers']);
$serverListTab->table->setData($serverListTab->currentServerData); $serverListTab->table->setData($serverListTab->currentServerData);
@ -340,6 +342,12 @@ class ServerListTab
)); ));
$updatesCount = is_numeric($updatesOutput) ? ((int) $updatesOutput) : 0; $updatesCount = is_numeric($updatesOutput) ? ((int) $updatesOutput) : 0;
// Read Ubuntu version (PRETTY_NAME from /etc/os-release)
$osOutput = trim($ssh->exec(
'grep "^PRETTY_NAME=" /etc/os-release 2>/dev/null | cut -d= -f2 | tr -d \'"\'',
));
$osVersion = $osOutput !== '' ? $osOutput : 'unbekannt';
// Docker status for main application container // Docker status for main application container
$output = $ssh->exec('docker inspect psc-web-1'); $output = $ssh->exec('docker inspect psc-web-1');
@ -351,6 +359,7 @@ class ServerListTab
'docker_status' => 'error', 'docker_status' => 'error',
'needs_reboot' => $needsReboot, 'needs_reboot' => $needsReboot,
'updates' => $updatesCount, 'updates' => $updatesCount,
'os_version' => $osVersion,
]; ];
} }
@ -363,6 +372,7 @@ class ServerListTab
'docker_status' => 'error', 'docker_status' => 'error',
'needs_reboot' => $needsReboot, 'needs_reboot' => $needsReboot,
'updates' => $updatesCount, 'updates' => $updatesCount,
'os_version' => $osVersion,
]; ];
} }
@ -373,6 +383,7 @@ class ServerListTab
'docker_status' => 'ok', 'docker_status' => 'ok',
'needs_reboot' => $needsReboot, 'needs_reboot' => $needsReboot,
'updates' => $updatesCount, 'updates' => $updatesCount,
'os_version' => $osVersion,
]; ];
} catch (\Throwable $e) { } catch (\Throwable $e) {
return [ return [
@ -382,6 +393,7 @@ class ServerListTab
'docker_status' => 'error', 'docker_status' => 'error',
'needs_reboot' => null, 'needs_reboot' => null,
'updates' => null, 'updates' => null,
'os_version' => null,
]; ];
} }
}); });
@ -437,6 +449,13 @@ class ServerListTab
: 'nein'; : 'nein';
} }
if (array_key_exists('os_version', $dockerResult)) {
$osVersion = $dockerResult['os_version'];
$serverListTab->currentServerData[$i]['os_version'] = $osVersion !== null
? $osVersion
: 'unbekannt';
}
if (array_key_exists('docker_error', $dockerResult)) { if (array_key_exists('docker_error', $dockerResult)) {
$serverListTab->currentServerData[$i]['docker_error'] = $serverListTab->currentServerData[$i]['docker_error'] =
$dockerResult['docker_error']; $dockerResult['docker_error'];
@ -491,7 +510,7 @@ class ServerListTab
$value = (string) ($rowData['needs_reboot'] ?? ''); $value = (string) ($rowData['needs_reboot'] ?? '');
$normalized = strtolower(trim($value)); $normalized = strtolower(trim($value));
$baseStyle = 'px-4 py-2 border-r border-gray-300 text-sm '; $baseStyle = 'px-4 border-r border-gray-300 text-sm ';
if ($normalized === 'nein') { if ($normalized === 'nein') {
$style = $baseStyle . 'text-green-600'; $style = $baseStyle . 'text-green-600';
@ -509,7 +528,7 @@ class ServerListTab
$value = (string) ($rowData['updates_available'] ?? ''); $value = (string) ($rowData['updates_available'] ?? '');
$normalized = strtolower(trim($value)); $normalized = strtolower(trim($value));
$baseStyle = 'px-4 py-2 border-r border-gray-300 text-sm '; $baseStyle = 'px-4 border-r border-gray-300 text-sm ';
if ($normalized === 'nein' || $normalized === 'nein (0)') { if ($normalized === 'nein' || $normalized === 'nein (0)') {
$style = $baseStyle . 'text-green-600'; $style = $baseStyle . 'text-green-600';

View File

@ -121,8 +121,12 @@ class Table extends Container
// Check if column has custom render function // Check if column has custom render function
if (isset($column['render']) && is_callable($column['render'])) { if (isset($column['render']) && is_callable($column['render'])) {
$cellComponent = $column['render']($rowData, $rowIndex); // Wrap custom cell content in a container so that
$rowContainer->addComponent($cellComponent); // width/padding styles are applied consistently.
$cellContent = $column['render']($rowData, $rowIndex);
$cellContainer = new Container($cellStyle);
$cellContainer->addComponent($cellContent);
$rowContainer->addComponent($cellContainer);
} else { } else {
$cellLabel = new Label((string) $value, $cellStyle); $cellLabel = new Label((string) $value, $cellStyle);
$rowContainer->addComponent($cellLabel); $rowContainer->addComponent($cellLabel);