42 lines
1.1 KiB
PHP
Raw Normal View History

2023-09-22 11:23:49 +02:00
<?php
2023-12-07 19:06:32 +01:00
namespace App\Livewire\Project\Service;
2023-09-22 11:23:49 +02:00
use App\Actions\Service\StartService;
use App\Actions\Service\StopService;
use App\Models\Service;
use Livewire\Component;
class Navbar extends Component
{
public Service $service;
public array $parameters;
public array $query;
2023-11-05 09:49:23 +01:00
protected $listeners = ["checkStatus"];
2023-09-22 11:23:49 +02:00
public function render()
{
return view('livewire.project.service.navbar');
}
2023-11-05 09:49:23 +01:00
public function checkStatus() {
$this->service->refresh();
}
2023-09-22 11:23:49 +02:00
public function deploy()
{
$this->service->parse();
$activity = StartService::run($this->service);
2023-12-07 19:06:32 +01:00
$this->dispatch('newMonitorActivity', $activity->id);
2023-09-22 11:23:49 +02:00
}
2023-11-07 10:18:28 +01:00
public function stop(bool $forceCleanup = false)
2023-09-22 11:23:49 +02:00
{
StopService::run($this->service);
$this->service->refresh();
2023-11-07 10:18:28 +01:00
if ($forceCleanup) {
2023-12-07 19:06:32 +01:00
$this->dispatch('success', 'Force cleanup service successfully.');
2023-11-07 10:18:28 +01:00
} else {
2023-12-07 19:06:32 +01:00
$this->dispatch('success', 'Service stopped successfully.');
2023-11-07 10:18:28 +01:00
}
2023-12-07 19:06:32 +01:00
$this->dispatch('checkStatus');
2023-09-22 11:23:49 +02:00
}
}