From d371f0ed28f14d7700b668db364a369d4c19d30b Mon Sep 17 00:00:00 2001 From: ShadowArcanist <162910371+ShadowArcanist@users.noreply.github.com> Date: Thu, 23 Apr 2026 16:13:09 +0530 Subject: [PATCH] feat(destination): show resources that are deployed on the destination --- app/Livewire/Destination/Show.php | 62 +++++++++++++++++++ app/Models/StandaloneDocker.php | 5 +- .../views/livewire/destination/show.blade.php | 20 ++++++ 3 files changed, 86 insertions(+), 1 deletion(-) diff --git a/app/Livewire/Destination/Show.php b/app/Livewire/Destination/Show.php index 9d55d7462..11afbbccc 100644 --- a/app/Livewire/Destination/Show.php +++ b/app/Livewire/Destination/Show.php @@ -24,6 +24,8 @@ class Show extends Component #[Validate(['string', 'required'])] public string $serverIp; + public array $resources = []; + public function mount(string $destination_uuid) { try { @@ -33,11 +35,71 @@ class Show extends Component } $this->destination = $destination; $this->syncData(); + $this->loadResources(); } catch (\Throwable $e) { return handleError($e, $this); } } + public function loadResources(): void + { + if ($this->destination->getMorphClass() !== \App\Models\StandaloneDocker::class) { + return; + } + + $this->resources = $this->collectResources([ + $this->destination->applications, + $this->destination->services, + $this->destination->postgresqls, + $this->destination->redis, + $this->destination->mongodbs, + $this->destination->mysqls, + $this->destination->mariadbs, + $this->destination->keydbs, + $this->destination->dragonflies, + $this->destination->clickhouses, + ]); + } + + protected function collectResources(array $groups): array + { + $rows = []; + foreach ($groups as $group) { + foreach ($group as $resource) { + $rows[] = $this->resourceRow($resource); + } + } + + return $rows; + } + + protected function resourceRow($resource): array + { + $type = match (true) { + $resource instanceof \App\Models\Application => 'application', + $resource instanceof \App\Models\Service => 'service', + default => 'database', + }; + $environment = $resource->environment; + $project = $environment?->project; + $routeName = "project.{$type}.configuration"; + $url = ($project && $environment) + ? route($routeName, [ + 'project_uuid' => $project->uuid, + 'environment_uuid' => $environment->uuid, + "{$type}_uuid" => $resource->uuid, + ]) + : null; + + return [ + 'type' => $type, + 'name' => $resource->name, + 'project' => $project?->name, + 'environment' => $environment?->name, + 'url' => $url, + ]; + } + public function syncData(bool $toModel = false) { if ($toModel) { diff --git a/app/Models/StandaloneDocker.php b/app/Models/StandaloneDocker.php index d6b4d1a1c..d12a15a7c 100644 --- a/app/Models/StandaloneDocker.php +++ b/app/Models/StandaloneDocker.php @@ -134,8 +134,11 @@ class StandaloneDocker extends BaseModel $mongodbs = $this->mongodbs; $mysqls = $this->mysqls; $mariadbs = $this->mariadbs; + $keydbs = $this->keydbs; + $dragonflies = $this->dragonflies; + $clickhouses = $this->clickhouses; - return $postgresqls->concat($redis)->concat($mongodbs)->concat($mysqls)->concat($mariadbs); + return $postgresqls->concat($redis)->concat($mongodbs)->concat($mysqls)->concat($mariadbs)->concat($keydbs)->concat($dragonflies)->concat($clickhouses); } public function attachedTo() diff --git a/resources/views/livewire/destination/show.blade.php b/resources/views/livewire/destination/show.blade.php index 27260e920..1bb179823 100644 --- a/resources/views/livewire/destination/show.blade.php +++ b/resources/views/livewire/destination/show.blade.php @@ -28,4 +28,24 @@ @endif + + @if ($destination->getMorphClass() === 'App\Models\StandaloneDocker') +
+

Resources

+
Applications, services, and databases deployed to this network.
+ @if (count($resources) === 0) +
No resources are using this destination.
+ @else +
+ @foreach ($resources as $row) + +
{{ ucfirst($row['type']) }}: {{ $row['name'] }}
+
{{ $row['project'] }} / {{ $row['environment'] }}
+
+ @endforeach +
+ @endif +
+ @endif