lasthourcloud/app/Http/Livewire/Project/Service/Navbar.php

42 lines
1.1 KiB
PHP
Raw Normal View History

2023-09-22 09:23:49 +00:00
<?php
namespace App\Http\Livewire\Project\Service;
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 08:49:23 +00:00
protected $listeners = ["checkStatus"];
2023-09-22 09:23:49 +00:00
public function render()
{
return view('livewire.project.service.navbar');
}
2023-11-05 08:49:23 +00:00
public function checkStatus() {
$this->service->refresh();
}
2023-09-22 09:23:49 +00:00
public function deploy()
{
$this->service->parse();
$activity = StartService::run($this->service);
$this->emit('newMonitorActivity', $activity->id);
}
2023-11-07 09:18:28 +00:00
public function stop(bool $forceCleanup = false)
2023-09-22 09:23:49 +00:00
{
StopService::run($this->service);
$this->service->refresh();
2023-11-07 09:18:28 +00:00
if ($forceCleanup) {
$this->emit('success', 'Force cleanup service successfully.');
} else {
$this->emit('success', 'Service stopped successfully.');
}
2023-11-05 08:49:23 +00:00
$this->emit('checkStatus');
2023-09-22 09:23:49 +00:00
}
}