From 2e8b1134b9430032b27340584524378507f8ba24 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 19 Apr 2023 14:00:31 +0200 Subject: [PATCH] wip --- app/Http/Livewire/Application/General.php | 40 ++++++++++++++--- app/Http/Livewire/Application/Secrets.php | 5 +-- app/Http/Livewire/Application/Storages.php | 11 +++++ app/Models/ApplicationSetting.php | 4 ++ app/Models/GithubApp.php | 3 ++ app/View/Components/Input.php | 2 + .../components/applications/layout.blade.php | 2 +- resources/views/components/input.blade.php | 43 +++++++++++++------ .../application/destination.blade.php | 4 +- .../livewire/application/general.blade.php | 14 +++++- .../livewire/application/secrets.blade.php | 6 ++- .../livewire/application/source.blade.php | 3 +- .../livewire/application/storages.blade.php | 10 +++++ .../applications/configuration.blade.php | 9 +++- 14 files changed, 127 insertions(+), 29 deletions(-) create mode 100644 app/Http/Livewire/Application/Storages.php create mode 100644 resources/views/livewire/application/storages.blade.php diff --git a/app/Http/Livewire/Application/General.php b/app/Http/Livewire/Application/General.php index 41d4cbb62..10a550feb 100644 --- a/app/Http/Livewire/Application/General.php +++ b/app/Http/Livewire/Application/General.php @@ -17,6 +17,16 @@ class General extends Component public string|null $git_commit_sha; public string $build_pack; + public bool $is_git_submodules_allowed; + public bool $is_git_lfs_allowed; + public bool $is_debug; + public bool $is_previews; + public bool $is_bot; + public bool $is_custom_ssl; + public bool $is_http2; + public bool $is_auto_deploy; + public bool $is_dual_cert; + protected $rules = [ 'application.name' => 'required|min:6', 'application.fqdn' => 'nullable', @@ -26,17 +36,37 @@ class General extends Component 'application.build_pack' => 'required', 'application.base_directory' => 'required', 'application.publish_directory' => 'nullable', - 'application.environment.name' => 'required', - 'application.destination.network' => 'required', ]; - + public function instantSave() + { + // @TODO: find another way + $this->application->settings->is_git_submodules_allowed = $this->is_git_submodules_allowed; + $this->application->settings->is_git_lfs_allowed = $this->is_git_lfs_allowed; + $this->application->settings->is_debug = $this->is_debug; + $this->application->settings->is_previews = $this->is_previews; + $this->application->settings->is_bot = $this->is_bot; + $this->application->settings->is_custom_ssl = $this->is_custom_ssl; + $this->application->settings->is_http2 = $this->is_http2; + $this->application->settings->is_auto_deploy = $this->is_auto_deploy; + $this->application->settings->is_dual_cert = $this->is_dual_cert; + $this->application->settings->save(); + } public function mount() { - $this->application = Application::find($this->applicationId)->with('destination')->first(); + $this->application = Application::find($this->applicationId)->with('destination', 'settings')->first(); + $this->is_git_submodules_allowed = $this->application->settings->is_git_submodules_allowed; + $this->is_git_lfs_allowed = $this->application->settings->is_git_lfs_allowed; + $this->is_debug = $this->application->settings->is_debug; + $this->is_previews = $this->application->settings->is_previews; + $this->is_bot = $this->application->settings->is_bot; + $this->is_custom_ssl = $this->application->settings->is_custom_ssl; + $this->is_http2 = $this->application->settings->is_http2; + $this->is_auto_deploy = $this->application->settings->is_auto_deploy; + $this->is_dual_cert = $this->application->settings->is_dual_cert; + } public function submit() { - $this->validate(); $this->application->save(); } } diff --git a/app/Http/Livewire/Application/Secrets.php b/app/Http/Livewire/Application/Secrets.php index c94e0e4a4..d23fd8386 100644 --- a/app/Http/Livewire/Application/Secrets.php +++ b/app/Http/Livewire/Application/Secrets.php @@ -6,8 +6,5 @@ class Secrets extends Component { - public function render() - { - return view('livewire.application.secrets'); - } + public array $secrets = []; } diff --git a/app/Http/Livewire/Application/Storages.php b/app/Http/Livewire/Application/Storages.php new file mode 100644 index 000000000..340c897ad --- /dev/null +++ b/app/Http/Livewire/Application/Storages.php @@ -0,0 +1,11 @@ +belongsTo(Application::class); diff --git a/app/Models/GithubApp.php b/app/Models/GithubApp.php index fd7dd0775..5e16fa574 100644 --- a/app/Models/GithubApp.php +++ b/app/Models/GithubApp.php @@ -4,6 +4,9 @@ class GithubApp extends BaseModel { + protected $casts = [ + 'is_public' => 'boolean', + ]; public function applications() { return $this->morphMany(Application::class, 'source'); diff --git a/app/View/Components/Input.php b/app/View/Components/Input.php index 16897aef1..07879b157 100644 --- a/app/View/Components/Input.php +++ b/app/View/Components/Input.php @@ -16,6 +16,8 @@ public function __construct( public bool $required = false, public bool $readonly = false, public string|null $label = null, + public string|null $type = 'text', + public bool $instantSave = false, ) { // } diff --git a/resources/views/components/applications/layout.blade.php b/resources/views/components/applications/layout.blade.php index abc1bbd99..24de20df5 100644 --- a/resources/views/components/applications/layout.blade.php +++ b/resources/views/components/applications/layout.blade.php @@ -2,6 +2,6 @@

{{ $title ?? 'NOT SET' }}

- {{ $slot }} + {{ $slot }}
diff --git a/resources/views/components/input.blade.php b/resources/views/components/input.blade.php index 5abd7953d..4d6140a89 100644 --- a/resources/views/components/input.blade.php +++ b/resources/views/components/input.blade.php @@ -1,16 +1,33 @@ - - +@if ($type === 'checkbox') + +@else + + +@endif + @error($name) {{ $message }} @enderror diff --git a/resources/views/livewire/application/destination.blade.php b/resources/views/livewire/application/destination.blade.php index 6f48b8eec..a141c6c4b 100644 --- a/resources/views/livewire/application/destination.blade.php +++ b/resources/views/livewire/application/destination.blade.php @@ -1,3 +1,5 @@
-

{{$destination->name}}

+

IP: {{ $destination->server->ip }}

+

Description: {{ $destination->server->description }}

+

Docker Network: {{ $destination->network }}

diff --git a/resources/views/livewire/application/general.blade.php b/resources/views/livewire/application/general.blade.php index 573a5ee4b..fae4d09f7 100644 --- a/resources/views/livewire/application/general.blade.php +++ b/resources/views/livewire/application/general.blade.php @@ -15,12 +15,24 @@
-
+ + +
+ + + + + + + + + +
diff --git a/resources/views/livewire/application/secrets.blade.php b/resources/views/livewire/application/secrets.blade.php index fd5ed6b9b..88d549b1d 100644 --- a/resources/views/livewire/application/secrets.blade.php +++ b/resources/views/livewire/application/secrets.blade.php @@ -1,3 +1,7 @@
- {{-- Nothing in the world is as soft and yielding as water. --}} + @forelse ($secrets as $secret) + {{ dump($secret) }} + @empty +

There are no secrets for this application.

+ @endforelse
diff --git a/resources/views/livewire/application/source.blade.php b/resources/views/livewire/application/source.blade.php index 5af721496..45329f769 100644 --- a/resources/views/livewire/application/source.blade.php +++ b/resources/views/livewire/application/source.blade.php @@ -1,5 +1,6 @@
-

{{ $application->source->name }}

+

Source Name: {{ data_get($application,'source.name') }}

+

Is Public Source: {{ data_get($application,'source.is_public') }}

diff --git a/resources/views/livewire/application/storages.blade.php b/resources/views/livewire/application/storages.blade.php new file mode 100644 index 000000000..0f7a5bc9c --- /dev/null +++ b/resources/views/livewire/application/storages.blade.php @@ -0,0 +1,10 @@ +
+ @forelse ($storages as $storage) +

Name:{{ data_get($storage, 'name') }}

+

MountPath:{{ data_get($storage, 'mount_path') }}

+

HostPath:{{ data_get($storage, 'host_path') }}

+

ContainerId:{{ data_get($storage, 'container_id') }}

+ @empty +

No storage found.

+ @endforelse +
diff --git a/resources/views/project/applications/configuration.blade.php b/resources/views/project/applications/configuration.blade.php index 72c04977a..a62504bc4 100644 --- a/resources/views/project/applications/configuration.blade.php +++ b/resources/views/project/applications/configuration.blade.php @@ -6,18 +6,23 @@ +
- +
- + +
+
+