coolify/app/Livewire/Dashboard.php

49 lines
1.5 KiB
PHP
Raw Normal View History

2023-08-29 14:36:17 +02:00
<?php
2023-12-07 19:06:32 +01:00
namespace App\Livewire;
2023-08-29 14:36:17 +02:00
2024-01-27 18:44:40 +01:00
use App\Models\ApplicationDeploymentQueue;
2023-08-29 14:36:17 +02:00
use App\Models\Project;
use App\Models\Server;
2024-01-27 18:44:40 +01:00
use Illuminate\Support\Collection;
2023-08-29 14:36:17 +02:00
use Livewire\Component;
class Dashboard extends Component
{
2023-10-10 10:56:11 +02:00
public $projects = [];
2024-01-27 18:44:40 +01:00
public Collection $servers;
public Collection $deployments_per_server;
2023-08-29 14:36:17 +02:00
public function mount()
{
2023-10-10 10:56:11 +02:00
$this->servers = Server::ownedByCurrentTeam()->get();
2023-10-11 10:08:37 +02:00
$this->projects = Project::ownedByCurrentTeam()->get();
2024-01-27 18:44:40 +01:00
$this->get_deployments();
}
public function get_deployments()
{
$this->deployments_per_server = ApplicationDeploymentQueue::whereIn("status", ["in_progress", "queued"])->whereIn("server_id", $this->servers->pluck("id"))->get([
"id",
"application_id",
"application_name",
"deployment_url",
"pull_request_id",
"server_name",
"server_id",
"status"
])->sortBy('id');
2023-08-29 14:36:17 +02:00
}
// public function getIptables()
// {
// $servers = Server::ownedByCurrentTeam()->get();
// foreach ($servers as $server) {
// checkRequiredCommands($server);
// $iptables = instant_remote_process(['docker run --privileged --net=host --pid=host --ipc=host --volume /:/host busybox chroot /host bash -c "iptables -L -n | jc --iptables"'], $server);
// ray($iptables);
// }
// }
2023-08-29 14:36:17 +02:00
public function render()
{
return view('livewire.dashboard');
}
}