Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat(destination): show resources that are deployed on the destination

ShadowArcanistd371f0ed28f1
diff --git a/app/Livewire/Destination/Show.php b/app/Livewire/Destination/Show.php
index 9d55d74627..11afbbccc0 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 d6b4d1a1c4..d12a15a7c6 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 27260e920f..1bb1798237 100644
--- a/resources/views/livewire/destination/show.blade.php
+++ b/resources/views/livewire/destination/show.blade.php
@@ -28,4 +28,24 @@
@endif
</div>
</form>
+
+ @if ($destination->getMorphClass() === 'App\Models\StandaloneDocker')
+ <div class="pt-6">
+ <h3>Resources</h3>
+ <div class="pb-2 text-xs opacity-70">Applications, services, and databases deployed to this network.</div>
+ @if (count($resources) === 0)
+ <div class="text-xs opacity-70 pt-2">No resources are using this destination.</div>
+ @else
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-2 pt-2">
+ @foreach ($resources as $row)
+ <a href="{{ $row['url'] }}"
+ class="relative flex flex-col dark:text-white coolbox group cursor-pointer">
+ <div class="box-title">{{ ucfirst($row['type']) }}: {{ $row['name'] }}</div>
+ <div class="box-description">{{ $row['project'] }} / {{ $row['environment'] }}</div>
+ </a>
+ @endforeach
+ </div>
+ @endif
+ </div>
+ @endif
</div>