lasthourcloud/app/Livewire/Project/Shared/HealthChecks.php

50 lines
1.4 KiB
PHP
Raw Normal View History

2023-09-22 13:29:19 +00:00
<?php
2023-12-07 18:06:32 +00:00
namespace App\Livewire\Project\Shared;
2023-09-22 13:29:19 +00:00
use Livewire\Component;
class HealthChecks extends Component
{
public $resource;
2024-06-10 20:43:34 +00:00
2023-09-22 13:29:19 +00:00
protected $rules = [
'resource.health_check_enabled' => 'boolean',
2023-09-22 13:29:19 +00:00
'resource.health_check_path' => 'string',
'resource.health_check_port' => 'nullable|string',
'resource.health_check_host' => 'string',
'resource.health_check_method' => 'string',
'resource.health_check_return_code' => 'integer',
'resource.health_check_scheme' => 'string',
'resource.health_check_response_text' => 'nullable|string',
'resource.health_check_interval' => 'integer|min:1',
'resource.health_check_timeout' => 'integer|min:1',
'resource.health_check_retries' => 'integer|min:1',
2023-09-22 13:29:19 +00:00
'resource.health_check_start_period' => 'integer',
2024-04-29 11:33:28 +00:00
'resource.custom_healthcheck_found' => 'boolean',
2023-09-22 13:29:19 +00:00
];
2024-06-10 20:43:34 +00:00
public function instantSave()
{
$this->resource->save();
2023-12-07 18:06:32 +00:00
$this->dispatch('success', 'Health check updated.');
}
2024-06-10 20:43:34 +00:00
2023-09-22 13:29:19 +00:00
public function submit()
{
try {
$this->validate();
$this->resource->save();
2023-12-07 18:06:32 +00:00
$this->dispatch('success', 'Health check updated.');
2023-09-22 13:29:19 +00:00
} catch (\Throwable $e) {
return handleError($e, $this);
}
}
2024-06-10 20:43:34 +00:00
2023-09-22 13:29:19 +00:00
public function render()
{
return view('livewire.project.shared.health-checks');
}
}