From 8d04fbdb74b55b4fa6a8ea0459e77ea079963291 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 12 Jan 2024 11:25:20 +0100 Subject: [PATCH] feat: search between resources --- app/Livewire/Project/Resource/Index.php | 87 ++++++- resources/css/app.css | 2 +- .../livewire/project/resource/index.blade.php | 232 ++++++++++++++---- 3 files changed, 270 insertions(+), 51 deletions(-) diff --git a/app/Livewire/Project/Resource/Index.php b/app/Livewire/Project/Resource/Index.php index 2a7570c9d..6a170ace8 100644 --- a/app/Livewire/Project/Resource/Index.php +++ b/app/Livewire/Project/Resource/Index.php @@ -10,7 +10,15 @@ class Index extends Component { public Project $project; public Environment $environment; - public function mount () { + public $applications = []; + public $postgresqls = []; + public $redis = []; + public $mongodbs = []; + public $mysqls = []; + public $mariadbs = []; + public $services = []; + public function mount() + { $project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first(); if (!$project) { return redirect()->route('dashboard'); @@ -21,6 +29,83 @@ class Index extends Component } $this->project = $project; $this->environment = $environment; + $this->applications = $environment->applications->sortBy('name'); + $this->applications = $this->applications->map(function ($application) { + if (data_get($application, 'environment.project.uuid')) { + $application->hrefLink = route('project.application.configuration', [ + 'project_uuid' => data_get($application, 'environment.project.uuid'), + 'environment_name' => data_get($application, 'environment.name'), + 'application_uuid' => data_get($application, 'uuid') + ]); + } + return $application; + }); + $this->postgresqls = $environment->postgresqls->sortBy('name'); + $this->postgresqls = $this->postgresqls->map(function ($postgresql) { + if (data_get($postgresql, 'environment.project.uuid')) { + $postgresql->hrefLink = route('project.database.configuration', [ + 'project_uuid' => data_get($postgresql, 'environment.project.uuid'), + 'environment_name' => data_get($postgresql, 'environment.name'), + 'database_uuid' => data_get($postgresql, 'uuid') + ]); + } + return $postgresql; + }); + $this->redis = $environment->redis->sortBy('name'); + $this->redis = $this->redis->map(function ($redis) { + if (data_get($redis, 'environment.project.uuid')) { + $redis->hrefLink = route('project.database.configuration', [ + 'project_uuid' => data_get($redis, 'environment.project.uuid'), + 'environment_name' => data_get($redis, 'environment.name'), + 'database_uuid' => data_get($redis, 'uuid') + ]); + } + return $redis; + }); + $this->mongodbs = $environment->mongodbs->sortBy('name'); + $this->mongodbs = $this->mongodbs->map(function ($mongodb) { + if (data_get($mongodb, 'environment.project.uuid')) { + $mongodb->hrefLink = route('project.database.configuration', [ + 'project_uuid' => data_get($mongodb, 'environment.project.uuid'), + 'environment_name' => data_get($mongodb, 'environment.name'), + 'database_uuid' => data_get($mongodb, 'uuid') + ]); + } + return $mongodb; + }); + $this->mysqls = $environment->mysqls->sortBy('name'); + $this->mysqls = $this->mysqls->map(function ($mysql) { + if (data_get($mysql, 'environment.project.uuid')) { + $mysql->hrefLink = route('project.database.configuration', [ + 'project_uuid' => data_get($mysql, 'environment.project.uuid'), + 'environment_name' => data_get($mysql, 'environment.name'), + 'database_uuid' => data_get($mysql, 'uuid') + ]); + } + return $mysql; + }); + $this->mariadbs = $environment->mariadbs->sortBy('name'); + $this->mariadbs = $this->mariadbs->map(function ($mariadb) { + if (data_get($mariadb, 'environment.project.uuid')) { + $mariadb->hrefLink = route('project.database.configuration', [ + 'project_uuid' => data_get($mariadb, 'environment.project.uuid'), + 'environment_name' => data_get($mariadb, 'environment.name'), + 'database_uuid' => data_get($mariadb, 'uuid') + ]); + } + return $mariadb; + }); + $this->services = $environment->services->sortBy('name'); + $this->services = $this->services->map(function ($service) { + if (data_get($service, 'environment.project.uuid')) { + $service->hrefLink = route('project.service.configuration', [ + 'project_uuid' => data_get($service, 'environment.project.uuid'), + 'environment_name' => data_get($service, 'environment.name'), + 'service_uuid' => data_get($service, 'uuid') + ]); + } + return $service; + }); } public function render() { diff --git a/resources/css/app.css b/resources/css/app.css index 868cbd9c0..cd383c1cd 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -80,7 +80,7 @@ a { } .description { - @apply pt-2 text-xs font-bold text-neutral-500 group-hover:text-white; + @apply text-xs font-bold text-neutral-500 group-hover:text-white; } .lds-heart { diff --git a/resources/views/livewire/project/resource/index.blade.php b/resources/views/livewire/project/resource/index.blade.php index a1ff05693..ca2325419 100644 --- a/resources/views/livewire/project/resource/index.blade.php +++ b/resources/views/livewire/project/resource/index.blade.php @@ -44,54 +44,188 @@ + Add New Resource @endif -
- @foreach ($environment->applications->sortBy('name') as $application) - -
-
{{ $application->name }}
-
{{ $application->description }}
-
- @if (Str::of(data_get($application, 'status'))->startsWith('running')) -
- @elseif (Str::of(data_get($application, 'status'))->startsWith('exited')) -
- @elseif (Str::of(data_get($application, 'status'))->startsWith('restarting')) -
- @endif -
- @endforeach - @foreach ($environment->databases()->sortBy('name') as $database) - -
-
{{ $database->name }}
-
{{ $database->description }}
-
- @if (Str::of(data_get($database, 'status'))->startsWith('running')) -
- @elseif (Str::of(data_get($database, 'status'))->startsWith('exited')) -
- @elseif (Str::of(data_get($database, 'status'))->startsWith('restaring')) -
- @endif -
- @endforeach - @foreach ($environment->services->sortBy('name') as $service) - -
-
{{ $service->name }}
-
{{ $service->description }}
-
- @if (Str::of(serviceStatus($service))->startsWith('running')) -
- @elseif (Str::of(serviceStatus($service))->startsWith('degraded')) -
- @elseif (Str::of(serviceStatus($service))->startsWith('exited')) -
- @endif -
- @endforeach +
+ +
+ + + + + + +
+ +