admin widget zu dokploy geswitched, viele übersetzungen im Frontend vervollständigt und Anlässe-Seiten mit ChatGPT ausgebaut
This commit is contained in:
@@ -19,7 +19,7 @@ class DokployDeployments extends Page
|
||||
|
||||
protected string $view = 'filament.super-admin.pages.dokploy-deployments';
|
||||
|
||||
public array $applications = [];
|
||||
public array $composes = [];
|
||||
|
||||
public array $recentLogs = [];
|
||||
|
||||
@@ -28,43 +28,45 @@ class DokployDeployments extends Page
|
||||
public function mount(DokployClient $client): void
|
||||
{
|
||||
$this->dokployWebUrl = config('dokploy.web_url');
|
||||
$this->refreshApplications($client);
|
||||
$this->refreshComposes($client);
|
||||
$this->refreshLogs();
|
||||
}
|
||||
|
||||
public function reload(string $applicationId): void
|
||||
public function redeploy(string $composeId): void
|
||||
{
|
||||
$this->performAction($applicationId, 'reload');
|
||||
$this->performAction($composeId, 'redeploy');
|
||||
}
|
||||
|
||||
public function redeploy(string $applicationId): void
|
||||
public function stop(string $composeId): void
|
||||
{
|
||||
$this->performAction($applicationId, 'redeploy');
|
||||
$this->performAction($composeId, 'stop');
|
||||
}
|
||||
|
||||
protected function performAction(string $applicationId, string $action): void
|
||||
protected function performAction(string $composeId, string $action): void
|
||||
{
|
||||
$client = app(DokployClient::class);
|
||||
|
||||
if (! $this->isKnownApplication($applicationId)) {
|
||||
if (! $this->isKnownCompose($composeId)) {
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Unknown service')
|
||||
->body("The application ID {$applicationId} is not configured.")
|
||||
->body("The compose ID {$composeId} is not configured.")
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$action === 'reload'
|
||||
? $client->reloadApplication($applicationId, auth()->user())
|
||||
: $client->redeployApplication($applicationId, auth()->user());
|
||||
match ($action) {
|
||||
'redeploy' => $client->redeployCompose($composeId, auth()->user()),
|
||||
'stop' => $client->stopCompose($composeId, auth()->user()),
|
||||
default => throw new \RuntimeException("Unsupported action [{$action}]"),
|
||||
};
|
||||
|
||||
Notification::make()
|
||||
->success()
|
||||
->title(ucfirst($action).' requested')
|
||||
->body("Dokploy accepted the {$action} action for {$applicationId}.")
|
||||
->body("Dokploy accepted the {$action} action for {$composeId}.")
|
||||
->send();
|
||||
} catch (\Throwable $exception) {
|
||||
Notification::make()
|
||||
@@ -74,35 +76,35 @@ class DokployDeployments extends Page
|
||||
->send();
|
||||
}
|
||||
|
||||
$this->refreshApplications($client);
|
||||
$this->refreshComposes($client);
|
||||
$this->refreshLogs();
|
||||
}
|
||||
|
||||
protected function refreshApplications(DokployClient $client): void
|
||||
protected function refreshComposes(DokployClient $client): void
|
||||
{
|
||||
$applicationMap = config('dokploy.applications', []);
|
||||
$composeMap = config('dokploy.composes', []);
|
||||
$results = [];
|
||||
|
||||
foreach ($applicationMap as $label => $id) {
|
||||
foreach ($composeMap as $label => $id) {
|
||||
try {
|
||||
$status = $client->applicationStatus($id);
|
||||
$application = Arr::get($status, 'application', []);
|
||||
$status = $client->composeStatus($id);
|
||||
$compose = Arr::get($status, 'compose', []);
|
||||
|
||||
$results[] = [
|
||||
'label' => ucfirst($label),
|
||||
'application_id' => $id,
|
||||
'status' => Arr::get($application, 'applicationStatus', 'unknown'),
|
||||
'compose_id' => $id,
|
||||
'status' => Arr::get($compose, 'composeStatus', 'unknown'),
|
||||
];
|
||||
} catch (\Throwable $e) {
|
||||
$results[] = [
|
||||
'label' => ucfirst($label),
|
||||
'application_id' => $id,
|
||||
'compose_id' => $id,
|
||||
'status' => 'error',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$this->applications = $results;
|
||||
$this->composes = $results;
|
||||
}
|
||||
|
||||
protected function refreshLogs(): void
|
||||
@@ -122,8 +124,8 @@ class DokployDeployments extends Page
|
||||
->toArray();
|
||||
}
|
||||
|
||||
protected function isKnownApplication(string $applicationId): bool
|
||||
protected function isKnownCompose(string $composeId): bool
|
||||
{
|
||||
return in_array($applicationId, array_values(config('dokploy.applications', [])), true);
|
||||
return in_array($composeId, array_values(config('dokploy.composes', [])), true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user