From 7aca4930db5a390855d53a450cc26cef24e7ea1b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 31 Mar 2024 18:38:26 +0200 Subject: [PATCH] fix: unfunctional server should see resources --- app/Models/Server.php | 33 +- .../views/livewire/server/resources.blade.php | 282 +++++++++--------- 2 files changed, 157 insertions(+), 158 deletions(-) diff --git a/app/Models/Server.php b/app/Models/Server.php index 08235a26d..10af2915d 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -550,21 +550,26 @@ public function startUnmanaged($id) } public function loadUnmanagedContainers() { - if ($this->isFunctional()) { - $containers = instant_remote_process(["docker ps -a --format '{{json .}}' "], $this); - $containers = format_docker_command_output_to_json($containers); - $containers = $containers->map(function ($container) { - $labels = data_get($container, 'Labels'); - if (!str($labels)->contains("coolify.managed")) { - return $container; - } - return null; - }); - $containers = $containers->filter(); - return collect($containers); - } else { - return collect([]); + try { + if ($this->isFunctional()) { + $containers = instant_remote_process(["docker ps -a --format '{{json .}}' "], $this); + $containers = format_docker_command_output_to_json($containers); + $containers = $containers->map(function ($container) { + $labels = data_get($container, 'Labels'); + if (!str($labels)->contains("coolify.managed")) { + return $container; + } + return null; + }); + $containers = $containers->filter(); + return collect($containers); + } else { + return collect([]); + } + } catch (\Throwable $e) { + return handleError($e); } + } public function hasDefinedResources() { diff --git a/resources/views/livewire/server/resources.blade.php b/resources/views/livewire/server/resources.blade.php index 225636ca8..8c888b131 100644 --- a/resources/views/livewire/server/resources.blade.php +++ b/resources/views/livewire/server/resources.blade.php @@ -1,165 +1,159 @@
- @if ($server->isFunctional()) -
- -
-
+
+ +
+
+
+
+

Resources

+ Refresh +
+
Here you can find all resources that are managed by Coolify.
+
+ @if ($server->definedResources()->count() > 0)
-
-

Resources

- Refresh -
-
Here you can find all resources that are managed by Coolify.
-
- @if ($server->definedResources()->count() > 0)
-
-
-
-
- - +
+
+
+
+ + + + + + + + + + + @forelse ($server->definedResources()->sortBy('name',SORT_NATURAL) as $resource) - - - - - + + + + + - - - @forelse ($server->definedResources()->sortBy('name',SORT_NATURAL) as $resource) - - - - - - - - @empty - @endforelse - -
+ Project + + Environment + Name + + Type + + Status +
- Project - - Environment - Name - - Type - - Status - + {{ data_get($resource->project(), 'name') }} + + {{ data_get($resource, 'environment.name') }} + + {{ $resource->name }} + + + {{ str($resource->type())->headline() }} + @if ($resource->type() === 'service') + + @else + + @endif +
- {{ data_get($resource->project(), 'name') }} - - {{ data_get($resource, 'environment.name') }} - {{ $resource->name }} - - - {{ str($resource->type())->headline() }} - @if ($resource->type() === 'service') - - @else - - @endif -
-
+ @empty + @endforelse + +
- @else -
No resources found.
- @endif -
-
-
-
-

Resources

- Refresh -
-
Here you can find all other containers running on the server.
- @if ($unmanagedContainers->count() > 0) + @else +
No resources found.
+ @endif +
+
+
+
+

Resources

+ Refresh +
+
Here you can find all other containers running on the server.
+
+ @if ($unmanagedContainers->count() > 0) +
-
-
-
-
- - +
+
+
+
+ + + + + + + + + + @forelse ($unmanagedContainers->sortBy('name',SORT_NATURAL) as $resource) - - - - + + + + - - - @forelse ($unmanagedContainers->sortBy('name',SORT_NATURAL) as $resource) - - - - - - - @empty - @endforelse - -
+ Name + + Image + + Status + + Action +
- Name - - Image - - Status - - Action - + {{ data_get($resource, 'Names') }} + + {{ data_get($resource, 'Image') }} + + {{ data_get($resource, 'State') }} + + @if (data_get($resource, 'State') === 'running') + Restart + Stop + @elseif (data_get($resource, 'State') === 'exited') + Start + @elseif (data_get($resource, 'State') === 'restarting') + Stop + @endif +
- {{ data_get($resource, 'Names') }} - - {{ data_get($resource, 'Image') }} - - {{ data_get($resource, 'State') }} - - @if (data_get($resource, 'State') === 'running') - Restart - Stop - @elseif (data_get($resource, 'State') === 'exited') - Start - @elseif (data_get($resource, 'State') === 'restarting') - Stop - @endif -
-
+ @empty + @endforelse + +
- @else -
No resources found.
- @endif -
+
+ @else +
No resources found.
+ @endif
- @else -
Server is not validated. Validate first.
- @endif +