From e4704fb7e64dc3d8a865e808ef079a43339d4870 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 13 Jun 2023 10:02:58 +0200 Subject: [PATCH] updates --- .../Destination/New/StandaloneDocker.php | 39 +++++++++++-------- app/Models/Server.php | 7 +++- resources/css/app.css | 4 +- resources/js/components/MagicBar.vue | 31 +++++++++------ .../views/components/forms/select.blade.php | 2 +- resources/views/components/navbar.blade.php | 2 +- resources/views/destination/all.blade.php | 30 ++++++++++++++ resources/views/destination/show.blade.php | 1 - .../views/livewire/activity-monitor.blade.php | 2 +- .../views/livewire/destination/form.blade.php | 25 ++++++++---- .../views/livewire/server/new/by-ip.blade.php | 2 +- .../views/livewire/server/proxy.blade.php | 7 ++-- .../livewire/server/proxy/deploy.blade.php | 9 +++-- .../livewire/source/github/create.blade.php | 4 +- resources/views/source/gitlab/show.blade.php | 2 +- routes/web.php | 10 +++++ 16 files changed, 123 insertions(+), 54 deletions(-) create mode 100644 resources/views/destination/all.blade.php diff --git a/app/Http/Livewire/Destination/New/StandaloneDocker.php b/app/Http/Livewire/Destination/New/StandaloneDocker.php index d9d556510..efe68e241 100644 --- a/app/Http/Livewire/Destination/New/StandaloneDocker.php +++ b/app/Http/Livewire/Destination/New/StandaloneDocker.php @@ -38,24 +38,29 @@ public function mount() public function submit() { + $this->validate(); - $found = ModelsStandaloneDocker::where('server_id', $this->server_id)->where('network', $this->network)->first(); - if ($found) { - $this->addError('network', 'Network already added to this server.'); - return; + try { + $found = ModelsStandaloneDocker::where('server_id', $this->server_id)->where('network', $this->network)->first(); + if ($found) { + $this->addError('network', 'Network already added to this server.'); + return; + } + $server = Server::find($this->server_id); + + instant_remote_process(['docker network create --attachable ' . $this->network], $server); + + instant_remote_process(["docker network connect $this->network coolify-proxy"], $server); + + $docker = ModelsStandaloneDocker::create([ + 'name' => $this->name, + 'network' => $this->network, + 'server_id' => $this->server_id, + 'team_id' => session('currentTeam')->id + ]); + return redirect()->route('destination.show', $docker->uuid); + } catch (\Exception $e) { + return general_error_handler(err: $e); } - $server = Server::find($this->server_id); - instant_remote_process(['docker network create --attachable ' . $this->network], $server, throwError: false); - instant_remote_process(["docker network connect $this->network coolify-proxy"], $server, throwError: false); - - $docker = ModelsStandaloneDocker::create([ - 'name' => $this->name, - 'network' => $this->network, - 'server_id' => $this->server_id, - 'team_id' => session('currentTeam')->id - ]); - - - return redirect()->route('destination.show', $docker->uuid); } } diff --git a/app/Models/Server.php b/app/Models/Server.php index bde034a86..ac9e1c30c 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -33,7 +33,12 @@ public function scopeWithExtraAttributes(): Builder { return $this->extra_attributes->modelScope(); } - + public function destinations() + { + $standalone_docker = $this->hasMany(StandaloneDocker::class)->get(); + $swarm_docker = $this->hasMany(SwarmDocker::class)->get(); + return $standalone_docker->concat($swarm_docker); + } public function standaloneDockers() { return $this->hasMany(StandaloneDocker::class); diff --git a/resources/css/app.css b/resources/css/app.css index e6639945b..e26a62460 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -38,7 +38,7 @@ textarea { @apply textarea placeholder:text-neutral-700 text-white rounded scrollbar; } select { - @apply select select-sm text-sm disabled:bg-coolgray-200 border-none disabled:opacity-50 font-normal placeholder:text-neutral-700 text-white rounded; + @apply h-7 select select-sm text-sm disabled:bg-coolgray-200 border-none disabled:opacity-50 font-normal placeholder:text-neutral-700 text-white rounded; } .loading { @apply w-4 text-warning; @@ -67,7 +67,7 @@ a { } .main-navbar { - @apply fixed h-full overflow-hidden pt-14; + @apply fixed h-full overflow-hidden pt-16; } .kbd-custom { @apply px-2 text-xs border border-dashed rounded border-neutral-700 text-warning; diff --git a/resources/js/components/MagicBar.vue b/resources/js/components/MagicBar.vue index 1821dd4b7..b7b5594df 100644 --- a/resources/js/components/MagicBar.vue +++ b/resources/js/components/MagicBar.vue @@ -1,7 +1,7 @@