coolify/app/Livewire/Project/Shared/ScheduledTask/All.php

45 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2024-01-01 18:33:16 +00:00
<?php
namespace App\Livewire\Project\Shared\ScheduledTask;
use Illuminate\Support\Collection;
use Livewire\Attributes\Locked;
use Livewire\Attributes\On;
2024-01-01 18:33:16 +00:00
use Livewire\Component;
class All extends Component
{
#[Locked]
2024-01-01 18:33:16 +00:00
public $resource;
2024-06-10 20:43:34 +00:00
#[Locked]
public array $parameters;
public Collection $containerNames;
2024-06-10 20:43:34 +00:00
2024-01-01 18:33:16 +00:00
public ?string $variables = null;
2024-06-10 20:43:34 +00:00
2024-01-01 18:33:16 +00:00
public function mount()
{
$this->parameters = get_route_parameters();
if ($this->resource->type() === 'service') {
$this->containerNames = $this->resource->applications()->pluck('name');
$this->containerNames = $this->containerNames->merge($this->resource->databases()->pluck('name'));
} elseif ($this->resource->type() === 'application') {
if ($this->resource->build_pack === 'dockercompose') {
$parsed = $this->resource->parse();
2024-06-10 20:43:34 +00:00
$containers = collect(data_get($parsed, 'services'))->keys();
$this->containerNames = $containers;
} else {
$this->containerNames = collect([]);
}
}
2024-01-01 18:33:16 +00:00
}
2024-06-10 20:43:34 +00:00
#[On('refreshTasks')]
2024-01-01 18:33:16 +00:00
public function refreshTasks()
{
$this->resource->refresh();
}
}