fix: service navbar using new realtime events
This commit is contained in:
@@ -133,13 +133,13 @@ class Select extends Component
|
||||
public function setDestination(string $destination_uuid)
|
||||
{
|
||||
$this->destination_uuid = $destination_uuid;
|
||||
return $this->redirectRoute('project.resources.new', [
|
||||
return redirect()->route('project.resources.new', [
|
||||
'project_uuid' => $this->parameters['project_uuid'],
|
||||
'environment_name' => $this->parameters['environment_name'],
|
||||
'type' => $this->type,
|
||||
'destination' => $this->destination_uuid,
|
||||
'server_id' => $this->server_id,
|
||||
], navigate: true);
|
||||
]);
|
||||
}
|
||||
|
||||
public function loadServers()
|
||||
|
||||
@@ -13,7 +13,15 @@ class Index extends Component
|
||||
public $databases;
|
||||
public array $parameters;
|
||||
public array $query;
|
||||
protected $listeners = ["refreshStacks", "checkStatus"];
|
||||
public function getListeners()
|
||||
{
|
||||
$userId = auth()->user()->id;
|
||||
return [
|
||||
"echo-private:custom.{$userId},ServiceStatusChanged" => 'checkStatus',
|
||||
"refreshStacks",
|
||||
"checkStatus",
|
||||
];
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.project.service.index');
|
||||
@@ -28,7 +36,7 @@ class Index extends Component
|
||||
}
|
||||
public function checkStatus()
|
||||
{
|
||||
dispatch(new ContainerStatusJob($this->service->server));
|
||||
dispatch_sync(new ContainerStatusJob($this->service->server));
|
||||
$this->refreshStacks();
|
||||
}
|
||||
public function refreshStacks()
|
||||
|
||||
@@ -6,9 +6,6 @@ use Livewire\Component;
|
||||
|
||||
class Modal extends Component
|
||||
{
|
||||
public function checkStatus() {
|
||||
$this->dispatch('checkStatus');
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.project.service.modal');
|
||||
|
||||
@@ -4,25 +4,53 @@ namespace App\Livewire\Project\Service;
|
||||
|
||||
use App\Actions\Service\StartService;
|
||||
use App\Actions\Service\StopService;
|
||||
use App\Jobs\ContainerStatusJob;
|
||||
use App\Models\Service;
|
||||
use Livewire\Component;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
class Navbar extends Component
|
||||
{
|
||||
public Service $service;
|
||||
public array $parameters;
|
||||
public array $query;
|
||||
protected $listeners = ["checkStatus"];
|
||||
public $isDeploymentProgress = false;
|
||||
|
||||
public function checkDeployments() {
|
||||
$activity = Activity::where('properties->type_uuid', $this->service->uuid)->latest()->first();
|
||||
$status = data_get($activity, 'properties.status');
|
||||
if ($status === 'queued' || $status === 'in_progress') {
|
||||
$this->isDeploymentProgress = true;
|
||||
} else {
|
||||
$this->isDeploymentProgress = false;
|
||||
}
|
||||
}
|
||||
public function getListeners()
|
||||
{
|
||||
$userId = auth()->user()->id;
|
||||
return [
|
||||
"echo-private:custom.{$userId},ServiceStatusChanged" => 'serviceStatusChanged',
|
||||
];
|
||||
}
|
||||
public function serviceStatusChanged()
|
||||
{
|
||||
$this->service->refresh();
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.project.service.navbar');
|
||||
}
|
||||
public function checkStatus() {
|
||||
public function checkStatus()
|
||||
{
|
||||
$this->service->refresh();
|
||||
}
|
||||
public function deploy()
|
||||
{
|
||||
$this->checkDeployments();
|
||||
if ($this->isDeploymentProgress) {
|
||||
$this->dispatch('error', 'There is a deployment in progress.');
|
||||
return;
|
||||
}
|
||||
$this->service->parse();
|
||||
$activity = StartService::run($this->service);
|
||||
$this->dispatch('newMonitorActivity', $activity->id);
|
||||
|
||||
Reference in New Issue
Block a user