diff --git a/php/src/Controller/DockerController.php b/php/src/Controller/DockerController.php index c4625564..e326676a 100644 --- a/php/src/Controller/DockerController.php +++ b/php/src/Controller/DockerController.php @@ -202,16 +202,7 @@ readonly class DockerController { error_log('WARNING: Not pulling container images. Instead, using local ones.'); } - $nonbufResp = $response - ->withBody(new NonBufferedBody()) - ->withHeader('Content-Type', 'text/html; charset=utf-8') - ->withHeader('X-Accel-Buffering', 'no') - ->withHeader('Cache-Control', 'no-cache'); - - // Text written into this body is immediately sent to the client, without waiting for later content. - $streamingResponseBody = $nonbufResp->getBody(); - - $streamingResponseBody->write($this->getStreamingResponseHtmlStart()); + [$nonbufResp, $streamingResponseBody] = $this->startStreamingResponse($response); // Create a closure to pass around to the code, which should to the logging (because it e.g. decides // if it'll actually pull an image), but which should not need to know anything about the @@ -286,14 +277,7 @@ readonly class DockerController { } public function SystemPrune(Request $request, Response $response, array $args) : Response { - $nonbufResp = $response - ->withBody(new NonBufferedBody()) - ->withHeader('Content-Type', 'text/html; charset=utf-8') - ->withHeader('X-Accel-Buffering', 'no') - ->withHeader('Cache-Control', 'no-cache'); - - $streamingResponseBody = $nonbufResp->getBody(); - $streamingResponseBody->write($this->getStreamingResponseHtmlStart()); + [$nonbufResp, $streamingResponseBody] = $this->startStreamingResponse($response); $addToStreamingResponseBody = function (string $message) use ($streamingResponseBody) : void { $streamingResponseBody->write("
{$message}
"); @@ -352,6 +336,20 @@ readonly class DockerController { $this->PerformRecursiveContainerStop($id); } + private function startStreamingResponse(Response $response) : array { + $nonbufResp = $response + ->withBody(new NonBufferedBody()) + ->withHeader('Content-Type', 'text/html; charset=utf-8') + ->withHeader('X-Accel-Buffering', 'no') + ->withHeader('Cache-Control', 'no-cache'); + + // Text written into this body is immediately sent to the client, without waiting for later content. + $streamingResponseBody = $nonbufResp->getBody(); + $streamingResponseBody->write($this->getStreamingResponseHtmlStart()); + + return [$nonbufResp, $streamingResponseBody]; + } + private function getStreamingResponseHtmlStart() : string { return << diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index b4f9d406..78315316 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -1007,7 +1007,11 @@ readonly class DockerActionManager { } try { - $this->guzzleClient->post($url); + $resp = $this->guzzleClient->post($url); + $body = (string) $resp->getBody(); + if ($addToStreamingResponseBody !== null && $body !== '') { + $addToStreamingResponseBody($body); + } } catch (RequestException $e) { error_log(sprintf('Docker prune (%s) failed: %s', $endpoint, $e->getMessage())); if ($addToStreamingResponseBody !== null) { diff --git a/php/templates/containers.twig b/php/templates/containers.twig index 426407ce..d14eda20 100644 --- a/php/templates/containers.twig +++ b/php/templates/containers.twig @@ -322,6 +322,11 @@ +
+ + + +
{% endif %} {% else %} {% if isBackupOrRestoreRunning == true %} @@ -367,13 +372,6 @@ {% endif %} {% endif %} - {% if was_start_button_clicked == true %} -
- - - -
- {% endif %} {% endif %} {% endif %}