diff --git a/examples/ServerManager/Services/HetznerService.php b/examples/ServerManager/Services/HetznerService.php index 7ceaf99..a1c08f9 100644 --- a/examples/ServerManager/Services/HetznerService.php +++ b/examples/ServerManager/Services/HetznerService.php @@ -31,6 +31,7 @@ class HetznerService 'domains' => [], 'needs_reboot' => 'unbekannt', 'updates_available' => 'unbekannt', + 'os_version' => 'unbekannt', ]; } @@ -61,6 +62,7 @@ class HetznerService 'domains' => [], 'needs_reboot' => 'nein', 'updates_available' => 'nein', + 'os_version' => 'Ubuntu 22.04 LTS', ]; } return $testData; diff --git a/examples/ServerManager/UI/ServerListTab.php b/examples/ServerManager/UI/ServerListTab.php index 545bbc8..011fafa 100644 --- a/examples/ServerManager/UI/ServerListTab.php +++ b/examples/ServerManager/UI/ServerListTab.php @@ -81,22 +81,23 @@ class ServerListTab // Table $this->table = new Table(style: ' flex-1'); $this->table->setColumns([ - ['key' => 'id', 'title' => 'ID', 'width' => 80], + ['key' => 'id', 'title' => 'ID', 'width' => 100], ['key' => 'name', 'title' => 'Name'], - ['key' => 'status', 'title' => 'Status', 'width' => 100], + ['key' => 'status', 'title' => 'Status', 'width' => 90], ['key' => 'type', 'title' => 'Typ', 'width' => 80], - ['key' => 'ipv4', 'title' => 'IPv4', 'width' => 160], - ['key' => 'docker_status', 'title' => 'Docker', 'width' => 90], + ['key' => 'ipv4', 'title' => 'IPv4', 'width' => 140], + ['key' => 'docker_status', 'title' => 'Docker', 'width' => 80], + ['key' => 'os_version', 'title' => 'Ubuntu', 'width' => 180], [ 'key' => 'needs_reboot', 'title' => 'Neustart', - 'width' => 150, + 'width' => 110, 'render' => [$this, 'renderNeedsRebootCell'], ], [ 'key' => 'updates_available', 'title' => 'Updates', - 'width' => 150, + 'width' => 130, 'render' => [$this, 'renderUpdatesCell'], ], ]); @@ -293,6 +294,7 @@ class ServerListTab 'docker_error' => null, 'needs_reboot' => 'unbekannt', 'updates_available' => 'unbekannt', + 'os_version' => 'unbekannt', ], $row), $result['servers']); $serverListTab->table->setData($serverListTab->currentServerData); @@ -340,6 +342,12 @@ class ServerListTab )); $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 $output = $ssh->exec('docker inspect psc-web-1'); @@ -351,6 +359,7 @@ class ServerListTab 'docker_status' => 'error', 'needs_reboot' => $needsReboot, 'updates' => $updatesCount, + 'os_version' => $osVersion, ]; } @@ -363,6 +372,7 @@ class ServerListTab 'docker_status' => 'error', 'needs_reboot' => $needsReboot, 'updates' => $updatesCount, + 'os_version' => $osVersion, ]; } @@ -373,6 +383,7 @@ class ServerListTab 'docker_status' => 'ok', 'needs_reboot' => $needsReboot, 'updates' => $updatesCount, + 'os_version' => $osVersion, ]; } catch (\Throwable $e) { return [ @@ -382,6 +393,7 @@ class ServerListTab 'docker_status' => 'error', 'needs_reboot' => null, 'updates' => null, + 'os_version' => null, ]; } }); @@ -437,6 +449,13 @@ class ServerListTab : '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)) { $serverListTab->currentServerData[$i]['docker_error'] = $dockerResult['docker_error']; @@ -491,7 +510,7 @@ class ServerListTab $value = (string) ($rowData['needs_reboot'] ?? ''); $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') { $style = $baseStyle . 'text-green-600'; @@ -509,7 +528,7 @@ class ServerListTab $value = (string) ($rowData['updates_available'] ?? ''); $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)') { $style = $baseStyle . 'text-green-600'; diff --git a/src/Ui/Widget/Table.php b/src/Ui/Widget/Table.php index 878573c..cb41d1b 100644 --- a/src/Ui/Widget/Table.php +++ b/src/Ui/Widget/Table.php @@ -121,8 +121,12 @@ class Table extends Container // Check if column has custom render function if (isset($column['render']) && is_callable($column['render'])) { - $cellComponent = $column['render']($rowData, $rowIndex); - $rowContainer->addComponent($cellComponent); + // Wrap custom cell content in a container so that + // width/padding styles are applied consistently. + $cellContent = $column['render']($rowData, $rowIndex); + $cellContainer = new Container($cellStyle); + $cellContainer->addComponent($cellContent); + $rowContainer->addComponent($cellContainer); } else { $cellLabel = new Label((string) $value, $cellStyle); $rowContainer->addComponent($cellLabel);