Changes auto-committed by Conductor

This commit is contained in:
Andras Bacsai
2025-10-16 17:07:32 +02:00
parent 543d6fb334
commit e2c254a5a8
6 changed files with 159 additions and 195 deletions
+8 -8
View File
@@ -2,12 +2,14 @@
namespace App\Livewire\Project\Service;
use App\Livewire\Concerns\SynchronizesModelData;
use App\Models\ServiceApplication;
use Livewire\Component;
use Spatie\Url\Url;
class EditDomain extends Component
{
use SynchronizesModelData;
public $applicationId;
public ServiceApplication $application;
@@ -28,16 +30,14 @@ class EditDomain extends Component
{
$this->application = ServiceApplication::query()->findOrFail($this->applicationId);
$this->authorize('view', $this->application);
$this->syncData(false);
$this->syncFromModel();
}
private function syncData(bool $toModel = false): void
protected function getModelBindings(): array
{
if ($toModel) {
$this->application->fqdn = $this->fqdn;
} else {
$this->fqdn = $this->application->fqdn;
}
return [
'fqdn' => 'application.fqdn',
];
}
public function confirmDomainUsage()
@@ -65,7 +65,7 @@ class EditDomain extends Component
$this->dispatch('warning', __('warning.sslipdomain'));
}
// Sync to model for domain conflict check
$this->syncData(true);
$this->syncToModel();
// Check for domain conflicts if not forcing save
if (! $this->forceSaveDomains) {
$result = checkDomainUsage(resource: $this->application);
+11 -13
View File
@@ -2,6 +2,7 @@
namespace App\Livewire\Project\Service;
use App\Livewire\Concerns\SynchronizesModelData;
use App\Models\Application;
use App\Models\InstanceSettings;
use App\Models\LocalFileVolume;
@@ -22,7 +23,7 @@ use Livewire\Component;
class FileStorage extends Component
{
use AuthorizesRequests;
use AuthorizesRequests, SynchronizesModelData;
public LocalFileVolume $fileStorage;
@@ -60,18 +61,15 @@ class FileStorage extends Component
}
$this->isReadOnly = $this->fileStorage->isReadOnlyVolume();
$this->syncData(false);
$this->syncFromModel();
}
private function syncData(bool $toModel = false): void
protected function getModelBindings(): array
{
if ($toModel) {
$this->fileStorage->content = $this->content;
$this->fileStorage->is_based_on_git = $this->isBasedOnGit;
} else {
$this->content = $this->fileStorage->content;
$this->isBasedOnGit = $this->fileStorage->is_based_on_git ?? false;
}
return [
'content' => 'fileStorage.content',
'isBasedOnGit' => 'fileStorage.is_based_on_git',
];
}
public function convertToDirectory()
@@ -98,7 +96,7 @@ class FileStorage extends Component
$this->authorize('update', $this->resource);
$this->fileStorage->loadStorageOnServer();
$this->syncData(false);
$this->syncFromModel();
$this->dispatch('success', 'File storage loaded from server.');
} catch (\Throwable $e) {
return handleError($e, $this);
@@ -167,14 +165,14 @@ class FileStorage extends Component
if ($this->fileStorage->is_directory) {
$this->content = null;
}
$this->syncData(true);
$this->syncToModel();
$this->fileStorage->save();
$this->fileStorage->saveStorageOnServer();
$this->dispatch('success', 'File updated.');
} catch (\Throwable $e) {
$this->fileStorage->setRawAttributes($original);
$this->fileStorage->save();
$this->syncData(false);
$this->syncFromModel();
return handleError($e, $this);
}
@@ -2,6 +2,7 @@
namespace App\Livewire\Project\Service;
use App\Livewire\Concerns\SynchronizesModelData;
use App\Models\InstanceSettings;
use App\Models\ServiceApplication;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
@@ -14,6 +15,7 @@ use Spatie\Url\Url;
class ServiceApplicationView extends Component
{
use AuthorizesRequests;
use SynchronizesModelData;
public ServiceApplication $application;
@@ -77,7 +79,7 @@ class ServiceApplicationView extends Component
return;
}
$this->syncData(true);
$this->syncToModel();
$this->application->save();
$this->dispatch('success', 'You need to restart the service for the changes to take effect.');
} catch (\Throwable $e) {
@@ -112,33 +114,24 @@ class ServiceApplicationView extends Component
try {
$this->parameters = get_route_parameters();
$this->authorize('view', $this->application);
$this->syncData(false);
$this->syncFromModel();
} catch (\Throwable $e) {
return handleError($e, $this);
}
}
private function syncData(bool $toModel = false): void
protected function getModelBindings(): array
{
if ($toModel) {
$this->application->human_name = $this->humanName;
$this->application->description = $this->description;
$this->application->fqdn = $this->fqdn;
$this->application->image = $this->image;
$this->application->exclude_from_status = $this->excludeFromStatus;
$this->application->is_log_drain_enabled = $this->isLogDrainEnabled;
$this->application->is_gzip_enabled = $this->isGzipEnabled;
$this->application->is_stripprefix_enabled = $this->isStripprefixEnabled;
} else {
$this->humanName = $this->application->human_name;
$this->description = $this->application->description;
$this->fqdn = $this->application->fqdn;
$this->image = $this->application->image;
$this->excludeFromStatus = $this->application->exclude_from_status ?? false;
$this->isLogDrainEnabled = $this->application->is_log_drain_enabled ?? false;
$this->isGzipEnabled = $this->application->is_gzip_enabled ?? false;
$this->isStripprefixEnabled = $this->application->is_stripprefix_enabled ?? false;
}
return [
'humanName' => 'application.human_name',
'description' => 'application.description',
'fqdn' => 'application.fqdn',
'image' => 'application.image',
'excludeFromStatus' => 'application.exclude_from_status',
'isLogDrainEnabled' => 'application.is_log_drain_enabled',
'isGzipEnabled' => 'application.is_gzip_enabled',
'isStripprefixEnabled' => 'application.is_stripprefix_enabled',
];
}
public function convertToDatabase()
@@ -201,7 +194,7 @@ class ServiceApplicationView extends Component
$this->dispatch('warning', __('warning.sslipdomain'));
}
// Sync to model for domain conflict check
$this->syncData(true);
$this->syncToModel();
// Check for domain conflicts if not forcing save
if (! $this->forceSaveDomains) {
$result = checkDomainUsage(resource: $this->application);
@@ -219,7 +212,7 @@ class ServiceApplicationView extends Component
$this->validate();
$this->application->save();
$this->application->refresh();
$this->syncData(false);
$this->syncFromModel();
updateCompose($this->application);
if (str($this->application->fqdn)->contains(',')) {
$this->dispatch('warning', 'Some services do not support multiple domains, which can lead to problems and is NOT RECOMMENDED.<br><br>Only use multiple domains if you know what you are doing.');
@@ -231,7 +224,7 @@ class ServiceApplicationView extends Component
$originalFqdn = $this->application->getOriginal('fqdn');
if ($originalFqdn !== $this->application->fqdn) {
$this->application->fqdn = $originalFqdn;
$this->syncData(false);
$this->syncFromModel();
}
return handleError($e, $this);