diff --git a/app/Http/Livewire/PrivateKey/Change.php b/app/Http/Livewire/PrivateKey/Change.php index a070e600b..def6b40da 100644 --- a/app/Http/Livewire/PrivateKey/Change.php +++ b/app/Http/Livewire/PrivateKey/Change.php @@ -19,9 +19,9 @@ class Change extends Component { $this->private_key = PrivateKey::where('uuid', $this->private_key_uuid)->first(); } - public function delete($private_key_uuid) + public function delete() { - PrivateKey::where('uuid', $private_key_uuid)->delete(); + PrivateKey::where('uuid', $this->private_key_uuid)->delete(); session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get(); redirect()->route('dashboard'); } diff --git a/app/Http/Livewire/Project/Application/EnvironmentVariable.php b/app/Http/Livewire/Project/Application/EnvironmentVariable.php new file mode 100644 index 000000000..aeb15c878 --- /dev/null +++ b/app/Http/Livewire/Project/Application/EnvironmentVariable.php @@ -0,0 +1,48 @@ +parameters = Route::current()->parameters(); + if (data_get($this->env, 'value') !== null) { + $this->value = $this->env['value']; + $this->isBuildOnly = $this->env['isBuildOnly']; + } else { + $this->isNewEnv = true; + } + } + public function updateEnv() + { + $application = Application::where('uuid', $this->parameters['application_uuid'])->first(); + $application->environment_variables->set("{$this->keyName}.value", $this->value); + $application->environment_variables->set("{$this->keyName}.isBuildOnly", $this->isBuildOnly); + $application->save(); + } + public function submit() + { + $this->updateEnv(); + $this->emit('reloadWindow'); + } + public function delete() + { + $application = Application::where('uuid', $this->parameters['application_uuid'])->first(); + $application->environment_variables->forget($this->keyName); + $application->save(); + $this->emit('reloadWindow'); + } +} diff --git a/app/Http/Livewire/Project/Application/EnvironmentVariables.php b/app/Http/Livewire/Project/Application/EnvironmentVariables.php deleted file mode 100644 index dc05c61c7..000000000 --- a/app/Http/Livewire/Project/Application/EnvironmentVariables.php +++ /dev/null @@ -1,10 +0,0 @@ - SchemalessAttributes::class, + ]; + public function scopeWithEnvironmentVariables(): Builder + { + return $this->environment_variables->modelScope(); + } public function publishDirectory(): Attribute { diff --git a/app/Models/Server.php b/app/Models/Server.php index 96253d290..fe1929007 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -23,21 +23,26 @@ class Server extends BaseModel 'team_id', 'private_key_id', ]; + + public $casts = [ + 'extra_attributes' => SchemalessAttributes::class, + ]; + public function standaloneDockers() { return $this->hasMany(StandaloneDocker::class); } + public function swarmDockers() { return $this->hasMany(SwarmDocker::class); } - public $casts = [ - 'extra_attributes' => SchemalessAttributes::class, - ]; + public function scopeWithExtraAttributes(): Builder { return $this->extra_attributes->modelScope(); } + public function privateKey() { return $this->belongsTo(PrivateKey::class); diff --git a/database/migrations/2023_03_27_081716_create_applications_table.php b/database/migrations/2023_03_27_081716_create_applications_table.php index b408589d2..462b58e6f 100644 --- a/database/migrations/2023_03_27_081716_create_applications_table.php +++ b/database/migrations/2023_03_27_081716_create_applications_table.php @@ -39,6 +39,8 @@ return new class extends Migration $table->string('base_directory')->default('/'); $table->string('publish_directory')->nullable(); + $table->schemalessAttributes('environment_variables'); + $table->string('health_check_path')->default('/'); $table->string('health_check_port')->nullable(); $table->string('health_check_host')->default('localhost'); diff --git a/database/seeders/ApplicationSeeder.php b/database/seeders/ApplicationSeeder.php index 2a03a7911..3f17d6ee6 100644 --- a/database/seeders/ApplicationSeeder.php +++ b/database/seeders/ApplicationSeeder.php @@ -35,6 +35,16 @@ class ApplicationSeeder extends Seeder 'destination_type' => StandaloneDocker::class, 'source_id' => $github_public_source->id, 'source_type' => GithubApp::class, + 'environment_variables' => [ + 'NODE_ENV' => [ + 'value' => 'production', + 'isBuildOnly' => true, + ], + 'PORT' => [ + 'value' => 3000, + 'isBuildOnly' => false, + ] + ] ]); } } diff --git a/resources/views/components/confirm-modal.blade.php b/resources/views/components/confirm-modal.blade.php index ab707519f..033800ab6 100644 --- a/resources/views/components/confirm-modal.blade.php +++ b/resources/views/components/confirm-modal.blade.php @@ -2,11 +2,17 @@ document.addEventListener('alpine:init', () => { Alpine.data('confirmModal', () => ({ open: false, + confirmAction: null, message: 'Are you sure?', - toggleConfirmModal(customMessage) { + toggleConfirmModal(customMessage, confirmAction) { + this.confirmAction = confirmAction this.message = customMessage this.open = !this.open }, + confirmed() { + this.open = false + this.$dispatch(this.confirmAction) + } })) }) @@ -16,7 +22,7 @@
- Confirm + Confirm Cancel
diff --git a/resources/views/components/inputs/button.blade.php b/resources/views/components/inputs/button.blade.php index 23e0e0f11..d8073c4bc 100644 --- a/resources/views/components/inputs/button.blade.php +++ b/resources/views/components/inputs/button.blade.php @@ -15,10 +15,10 @@ wire:loading.delay.class.remove="{{ $defaultClass }} {{ $attributes->whereStartsWith('class')->first() }}" @endif @isset($confirm) - x-on:click="toggleConfirmModal('{{ $confirm }}')" + x-on:click="toggleConfirmModal('{{ $confirm }}', '{{ explode('(', $confirmAction)[0] }}')" @endisset @isset($confirmAction) - @confirm.window="$wire.{{ $confirmAction }}()" + x-on:{{ explode('(', $confirmAction)[0] }}.window="$wire.{{ explode('(', $confirmAction)[0] }}" @endisset> {{ $slot }} diff --git a/resources/views/components/inputs/input.blade.php b/resources/views/components/inputs/input.blade.php index eba849e9d..9f04097c4 100644 --- a/resources/views/components/inputs/input.blade.php +++ b/resources/views/components/inputs/input.blade.php @@ -27,7 +27,7 @@ @else + @if ($instantSave) wire:click='instantSave' wire:model.defer={{ $id }} @else wire:model.defer={{ $value ?? $id }} @endif /> @endif @error($id) diff --git a/resources/views/components/layout.blade.php b/resources/views/components/layout.blade.php index 79c5cbe16..258df343c 100644 --- a/resources/views/components/layout.blade.php +++ b/resources/views/components/layout.blade.php @@ -73,6 +73,9 @@ console.log('Update initiated. Waiting for server to be dead...') checkIfIamDead(); }) + Livewire.on('reloadWindow', () => { + window.location.reload(); + }) @endauth diff --git a/resources/views/livewire/destination/form.blade.php b/resources/views/livewire/destination/form.blade.php index e74656eef..e7445722d 100644 --- a/resources/views/livewire/destination/form.blade.php +++ b/resources/views/livewire/destination/form.blade.php @@ -9,8 +9,7 @@ Submit - + Delete diff --git a/resources/views/livewire/private-key/change.blade.php b/resources/views/livewire/private-key/change.blade.php index 353488ae7..c3bb38142 100644 --- a/resources/views/livewire/private-key/change.blade.php +++ b/resources/views/livewire/private-key/change.blade.php @@ -6,8 +6,7 @@ Submit - + Delete diff --git a/resources/views/livewire/project/application/environment-variable.blade.php b/resources/views/livewire/project/application/environment-variable.blade.php new file mode 100644 index 000000000..69c224c4e --- /dev/null +++ b/resources/views/livewire/project/application/environment-variable.blade.php @@ -0,0 +1,28 @@ +
+ @if ($isNewEnv === true) +
+ @else + + @endif + + +
+
+ + +
+
+ + @if ($isNewEnv) + Add + @else + Update + @endif + + @if ($isNewEnv === false) + + Delete + + @endif +
+
diff --git a/resources/views/livewire/project/application/environment-variables.blade.php b/resources/views/livewire/project/application/environment-variables.blade.php deleted file mode 100644 index 648060f3a..000000000 --- a/resources/views/livewire/project/application/environment-variables.blade.php +++ /dev/null @@ -1,7 +0,0 @@ -
- @forelse ($envs as $env) - {{ dump($env) }} - @empty -

There are no environment variables for this application.

- @endforelse -
diff --git a/resources/views/project/application/configuration.blade.php b/resources/views/project/application/configuration.blade.php index b885c5a10..10c36a393 100644 --- a/resources/views/project/application/configuration.blade.php +++ b/resources/views/project/application/configuration.blade.php @@ -1,34 +1,47 @@

Configuration

-
+
+

General Configurations

-
- +
+

Environment Variables

+ @forelse ($application->environment_variables->all() as $keyName => $env) + + @empty +

There are no environment variables for this application.

+ @endforelse +
+

Source

+

Destination

+

Persistent Storages