save sentinel form update

This commit is contained in:
Andras Bacsai
2024-10-25 11:42:37 +02:00
parent b03767713f
commit 2263734129
3 changed files with 67 additions and 65 deletions

View File

@@ -178,6 +178,19 @@ class Form extends Component
}
}
public function saveSentinel()
{
try {
$this->validate();
$this->server->settings->save();
$this->dispatch('success', 'Sentinel updated.');
} catch (\Throwable $e) {
return handleError($e, $this);
} finally {
$this->checkSyncStatus();
}
}
public function restartSentinel($notification = true)
{
try {
@@ -185,7 +198,8 @@ class Form extends Component
$this->validate([
'server.settings.sentinel_custom_url' => 'required|url',
]);
$this->server->restartSentinel();
$this->server->settings->save();
$this->server->restartSentinel(async: false);
if ($notification) {
$this->dispatch('success', 'Sentinel restarted.');
}

View File

@@ -173,9 +173,6 @@ function get_latest_sentinel_version(): string
return data_get($versions, 'coolify.sentinel.version');
} catch (\Throwable $e) {
//throw $e;
ray($e->getMessage());
return '0.0.0';
}
}
@@ -362,10 +359,6 @@ function isCloud(): bool
return ! config('coolify.self_hosted');
}
function isExperimentalFeaturesEnabled(): bool
{
return config('coolify.is_experimental_features_enabled');
}
function translate_cron_expression($expression_to_validate): string
{
if (isset(VALID_CRON_STRINGS[$expression_to_validate])) {

View File

@@ -158,34 +158,29 @@
@endif
</div>
</div>
@if (!$server->isSwarm() && !$server->isBuildServer())
@if (isExperimentalFeaturesEnabled())
</form>
@if ($server->isFunctional() && !$server->isSwarm() && !$server->isBuildServer())
<form wire:submit.prevent='saveSentinel'>
<div class="flex gap-2 items-center pt-4 pb-2">
<h3>Sentinel</h3>
@if ($server->isSentinelEnabled())
<div class="flex gap-2 items-center"
wire:poll.{{ $server->settings->sentinel_push_interval_seconds }}s="checkSyncStatus">
<div class="flex gap-2 items-center">
@if ($server->isSentinelLive())
<x-status.running status="In sync" noLoading
title="{{ $server->sentinel_updated_at }}" />
<x-status.running status="In sync" noLoading title="{{ $server->sentinel_updated_at }}" />
<x-forms.button type="submit">Save</x-forms.button>
<x-forms.button wire:click='restartSentinel'>Restart</x-forms.button>
@else
<x-status.stopped status="Out of sync" noLoading
title="{{ $server->sentinel_updated_at }}" />
<x-forms.button type="submit">Save</x-forms.button>
<x-forms.button wire:click='restartSentinel'>Sync</x-forms.button>
@endif
</div>
@endif
</div>
@else
<h3>Sentinel</h3>
<div>Sentinel is not available in this version (soon).</div>
@endif
@if (isExperimentalFeaturesEnabled())
<div class="flex flex-col gap-2">
<div class="w-64">
<x-forms.checkbox wire:model.live="server.settings.is_sentinel_enabled"
label="Enable Sentinel" />
<x-forms.checkbox wire:model.live="server.settings.is_sentinel_enabled" label="Enable Sentinel" />
@if ($server->isSentinelEnabled())
<x-forms.checkbox instantSave id="server.settings.is_metrics_enabled"
label="Enable Metrics" />
@@ -219,7 +214,7 @@
</div>
@endif
</div>
@endif
@endif
</form>
@endif
</div>