mirror of
https://github.com/ConvoyPanel/panel.git
synced 2026-07-07 05:04:25 +08:00
43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Convoy\Http\Controllers\Client\Servers;
|
|
|
|
use Convoy\Enums\Activity\Status;
|
|
use Convoy\Http\Controllers\ApplicationApiController;
|
|
use Convoy\Models\ActivityLog;
|
|
use Convoy\Models\Server;
|
|
use Convoy\Services\Servers\ServerDetailService;
|
|
use Inertia\Inertia;
|
|
|
|
class ServerController extends ApplicationApiController
|
|
{
|
|
public function __construct(private ServerDetailService $detailService)
|
|
{
|
|
}
|
|
|
|
public function show(Server $server)
|
|
{
|
|
return Inertia::render('servers/Show', [
|
|
'server' => $server->toArray(),
|
|
]);
|
|
}
|
|
|
|
public function showBuilding(Server $server)
|
|
{
|
|
$deployment = $server->activity()->where([['event', '=', 'server:rebuild'], ['status', '=', Status::RUNNING->value]])
|
|
->orWhere([['event', '=', 'server:build'], ['status', '=', Status::RUNNING->value]])->first();
|
|
|
|
return Inertia::render('servers/Building', [
|
|
'server' => $server->toArray(),
|
|
'batch' => $deployment?->batch,
|
|
'batch_type' => (bool) $deployment?->batch ? $deployment->event : null,
|
|
'events' => ActivityLog::where('batch', '=', $deployment)->get(),
|
|
]);
|
|
}
|
|
|
|
public function getDetails(Server $server)
|
|
{
|
|
return $this->detailService->setServer($server)->getDetails();
|
|
}
|
|
}
|