admin widget zu dokploy geswitched, viele übersetzungen im Frontend vervollständigt und Anlässe-Seiten mit ChatGPT ausgebaut

This commit is contained in:
Codex Agent
2025-11-19 13:12:35 +01:00
parent 125c624588
commit d8f365ddd6
30 changed files with 2820 additions and 293 deletions

View File

@@ -64,7 +64,7 @@ class DokployClient
throw new \RuntimeException('Dokploy application name is required to reload the service.');
}
return $this->dispatchAction(
$response = $this->dispatchAction(
$applicationId,
'reload',
[
@@ -74,11 +74,15 @@ class DokployClient
fn (array $payload) => $this->post('/application.reload', $payload),
$actor,
);
$this->forgetApplicationCaches($applicationId);
return $response;
}
public function redeployApplication(string $applicationId, ?Authenticatable $actor = null): array
{
return $this->dispatchAction(
$response = $this->dispatchAction(
$applicationId,
'redeploy',
[
@@ -87,6 +91,95 @@ class DokployClient
fn (array $payload) => $this->post('/application.redeploy', $payload),
$actor,
);
$this->forgetApplicationCaches($applicationId);
return $response;
}
public function composeStatus(string $composeId): array
{
return $this->cached($this->composeCacheKey($composeId), function () use ($composeId) {
$compose = $this->get('/compose.one', [
'composeId' => $composeId,
]);
$services = $this->optionalGet('/compose.loadServices', [
'composeId' => $composeId,
'type' => 'cache',
]);
return [
'compose' => $compose,
'services' => $services,
];
}, 30);
}
public function composeDeployments(string $composeId, int $limit = 5): array
{
return $this->cached($this->composeDeploymentsCacheKey($composeId), function () use ($composeId, $limit) {
$deployments = $this->get('/deployment.allByCompose', [
'composeId' => $composeId,
]);
if (! is_array($deployments)) {
return [];
}
return array_slice($deployments, 0, $limit);
}, 60);
}
public function redeployCompose(string $composeId, ?Authenticatable $actor = null): array
{
$response = $this->dispatchAction(
$composeId,
'compose.redeploy',
[
'composeId' => $composeId,
],
fn (array $payload) => $this->post('/compose.redeploy', $payload),
$actor,
);
$this->forgetComposeCaches($composeId);
return $response;
}
public function deployCompose(string $composeId, ?Authenticatable $actor = null): array
{
$response = $this->dispatchAction(
$composeId,
'compose.deploy',
[
'composeId' => $composeId,
],
fn (array $payload) => $this->post('/compose.deploy', $payload),
$actor,
);
$this->forgetComposeCaches($composeId);
return $response;
}
public function stopCompose(string $composeId, ?Authenticatable $actor = null): array
{
$response = $this->dispatchAction(
$composeId,
'compose.stop',
[
'composeId' => $composeId,
],
fn (array $payload) => $this->post('/compose.stop', $payload),
$actor,
);
$this->forgetComposeCaches($composeId);
return $response;
}
protected function cached(string $key, callable $callback, int $seconds): mixed
@@ -167,7 +260,7 @@ class DokployClient
}
protected function dispatchAction(
string $applicationId,
string $targetId,
string $action,
array $payload,
callable $callback,
@@ -178,22 +271,20 @@ class DokployClient
$body = $response->json() ?? [];
$status = $response->status();
} catch (\Throwable $exception) {
$this->logAction($applicationId, $action, $payload, [
$this->logAction($targetId, $action, $payload, [
'error' => $exception->getMessage(),
], null, $actor);
throw $exception;
}
$this->logAction($applicationId, $action, $payload, $body, $status, $actor);
Cache::forget($this->applicationCacheKey($applicationId));
Cache::forget($this->deploymentCacheKey($applicationId));
$this->logAction($targetId, $action, $payload, $body, $status, $actor);
return $body;
}
protected function logAction(
string $applicationId,
string $targetId,
string $action,
array $payload,
array $response,
@@ -202,7 +293,7 @@ class DokployClient
): void {
InfrastructureActionLog::create([
'user_id' => $actor?->getAuthIdentifier() ?? auth()->id(),
'service_id' => $applicationId,
'service_id' => $targetId,
'action' => $action,
'payload' => $payload,
'response' => $response,
@@ -219,4 +310,26 @@ class DokployClient
{
return "dokploy.deployments.{$applicationId}";
}
protected function composeCacheKey(string $composeId): string
{
return "dokploy.compose.{$composeId}";
}
protected function composeDeploymentsCacheKey(string $composeId): string
{
return "dokploy.compose.deployments.{$composeId}";
}
protected function forgetApplicationCaches(string $applicationId): void
{
Cache::forget($this->applicationCacheKey($applicationId));
Cache::forget($this->deploymentCacheKey($applicationId));
}
protected function forgetComposeCaches(string $composeId): void
{
Cache::forget($this->composeCacheKey($composeId));
Cache::forget($this->composeDeploymentsCacheKey($composeId));
}
}