From 22d3b0ba30be56ab02abd5a89bf7f9e542291f58 Mon Sep 17 00:00:00 2001 From: szaimen Date: Wed, 9 Mar 2022 16:50:53 +0100 Subject: [PATCH] allow to get the mastercontainer logs from the frontend Signed-off-by: szaimen --- php/src/Controller/DockerController.php | 8 ++++++-- php/src/Docker/DockerActionManager.php | 4 ++-- php/templates/containers.twig | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/php/src/Controller/DockerController.php b/php/src/Controller/DockerController.php index 7de6c1dd..c054311e 100644 --- a/php/src/Controller/DockerController.php +++ b/php/src/Controller/DockerController.php @@ -44,8 +44,12 @@ class DockerController public function GetLogs(Request $request, Response $response, $args) : Response { $id = $request->getQueryParams()['id']; - $container = $this->containerDefinitionFetcher->GetContainerById($id); - $logs = $this->dockerActionManager->GetLogs($container); + if (str_starts_with($id, 'nextcloud-aio-')) { + $logs = $this->dockerActionManager->GetLogs($id); + } else { + $logs = 'Container not found.'; + } + $body = $response->getBody(); $body->write($logs); diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index 455d2999..df23da3f 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -120,12 +120,12 @@ class DockerActionManager } } - public function GetLogs(Container $container) : string + public function GetLogs(string $id) : string { $url = $this->BuildApiUrl( sprintf( 'containers/%s/logs?stdout=true&stderr=true', - urlencode($container->GetIdentifier()) + urlencode($id) )); $responseBody = (string)$this->guzzleClient->get($url)->getBody(); diff --git a/php/templates/containers.twig b/php/templates/containers.twig index 353e7d1f..679b8d0c 100644 --- a/php/templates/containers.twig +++ b/php/templates/containers.twig @@ -164,7 +164,7 @@ {% if isBackupOrRestoreRunning == false %}

Mastercontainer

- You are currently running the {{ current_channel }} channel.

+ You are currently running the {{ current_channel }} channel. (Logs)

{% if is_mastercontainer_update_available == true %} {% if isAnyRunning == false %}