mirror of
https://github.com/coollabsio/coolify.git
synced 2025-12-28 05:34:50 +00:00
The Resources tab threw a "Queueing collections with multiple model types is not supported" error because the Livewire component was storing a mixed-type Eloquent collection (Applications, Databases, Services) as a public property, causing Livewire's serialization to fail. Fixed by: storing only the unmanaged containers array in the component, and calling definedResources() directly in the Blade view for the managed tab. Fixes #7666 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
100 lines
2.5 KiB
PHP
100 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Server;
|
|
|
|
use App\Models\Server;
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|
use Livewire\Component;
|
|
|
|
class Resources extends Component
|
|
{
|
|
use AuthorizesRequests;
|
|
|
|
public ?Server $server = null;
|
|
|
|
public $parameters = [];
|
|
|
|
public array $unmanagedContainers = [];
|
|
|
|
public $activeTab = 'managed';
|
|
|
|
public function getListeners()
|
|
{
|
|
$teamId = auth()->user()->currentTeam()->id;
|
|
|
|
return [
|
|
"echo-private:team.{$teamId},ApplicationStatusChanged" => 'refreshStatus',
|
|
];
|
|
}
|
|
|
|
public function startUnmanaged($id)
|
|
{
|
|
$this->server->startUnmanaged($id);
|
|
$this->dispatch('success', 'Container started.');
|
|
$this->loadUnmanagedContainers();
|
|
}
|
|
|
|
public function restartUnmanaged($id)
|
|
{
|
|
$this->server->restartUnmanaged($id);
|
|
$this->dispatch('success', 'Container restarted.');
|
|
$this->loadUnmanagedContainers();
|
|
}
|
|
|
|
public function stopUnmanaged($id)
|
|
{
|
|
$this->server->stopUnmanaged($id);
|
|
$this->dispatch('success', 'Container stopped.');
|
|
$this->loadUnmanagedContainers();
|
|
}
|
|
|
|
public function refreshStatus()
|
|
{
|
|
$this->server->refresh();
|
|
if ($this->activeTab === 'managed') {
|
|
$this->loadManagedContainers();
|
|
} else {
|
|
$this->loadUnmanagedContainers();
|
|
}
|
|
$this->dispatch('success', 'Resource statuses refreshed.');
|
|
}
|
|
|
|
public function loadManagedContainers()
|
|
{
|
|
try {
|
|
$this->activeTab = 'managed';
|
|
$this->server->refresh();
|
|
} catch (\Throwable $e) {
|
|
return handleError($e, $this);
|
|
}
|
|
}
|
|
|
|
public function loadUnmanagedContainers()
|
|
{
|
|
$this->activeTab = 'unmanaged';
|
|
try {
|
|
$this->unmanagedContainers = $this->server->loadUnmanagedContainers()->toArray();
|
|
} catch (\Throwable $e) {
|
|
return handleError($e, $this);
|
|
}
|
|
}
|
|
|
|
public function mount()
|
|
{
|
|
$this->parameters = get_route_parameters();
|
|
try {
|
|
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
|
|
if (is_null($this->server)) {
|
|
return redirect()->route('server.index');
|
|
}
|
|
} catch (\Throwable $e) {
|
|
return handleError($e, $this);
|
|
}
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.server.resources');
|
|
}
|
|
}
|