nexus base
This commit is contained in:
149
partials/landingpages/integrations.php
Normal file
149
partials/landingpages/integrations.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
require_auth();
|
||||
|
||||
$service = dashboards();
|
||||
$ownerKey = auth_user_key();
|
||||
$notice = null;
|
||||
$error = null;
|
||||
|
||||
if (!$service->available() || $ownerKey === '') {
|
||||
echo '<div class="module-shell"><div class="module-page-bg"><div class="module-page-stack"><section class="section-box">Integrationssystem nicht verfügbar.</section></div></div></div>';
|
||||
return;
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$action = trim((string) ($_POST['action'] ?? ''));
|
||||
try {
|
||||
if ($action === 'create_integration') {
|
||||
$service->createIntegration($ownerKey, [
|
||||
'type' => trim((string) ($_POST['type'] ?? 'generic')),
|
||||
'name' => trim((string) ($_POST['name'] ?? '')),
|
||||
'base_url' => trim((string) ($_POST['base_url'] ?? '')),
|
||||
'visibility' => trim((string) ($_POST['visibility'] ?? 'private')),
|
||||
'is_active' => isset($_POST['is_active']),
|
||||
'config' => [
|
||||
'notes' => trim((string) ($_POST['notes'] ?? '')),
|
||||
],
|
||||
]);
|
||||
$notice = 'Integration angelegt.';
|
||||
} elseif ($action === 'delete_integration') {
|
||||
$service->deleteIntegration((int) ($_POST['integration_id'] ?? 0), $ownerKey);
|
||||
$notice = 'Integration gelöscht.';
|
||||
}
|
||||
} catch (\Throwable $exception) {
|
||||
$error = $exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
$integrations = $service->listIntegrationsForOwner($ownerKey);
|
||||
|
||||
$GLOBALS['layout_header_base_title'] = 'Nexus';
|
||||
$GLOBALS['layout_header_title'] = 'Nexus';
|
||||
$GLOBALS['layout_header_context'] = 'Integrationen';
|
||||
$GLOBALS['layout_header_text'] = 'Zentrale Anbindungen an externe Systeme, getrennt vom klassischen Modulsystem.';
|
||||
?>
|
||||
<div class="module-shell"><div class="module-page-bg"><div class="module-page-stack">
|
||||
<header class="module-hero submenu-box">
|
||||
<div class="module-hero-top module-hero-top--compact">
|
||||
<nav class="module-tabs" aria-label="Integration Navigation">
|
||||
<a class="module-button module-button--tab" href="/dashboard">Dashboard</a>
|
||||
<a class="module-button module-button--tab" href="/dashboards">Dashboards</a>
|
||||
<a class="module-button module-button--tab-active" href="/integrations">Integrationen</a>
|
||||
<a class="module-button module-button--tab" href="/page-modules">Seitenmodule</a>
|
||||
</nav>
|
||||
<div class="module-hero-actions module-submenu-actions">
|
||||
<a class="module-button module-button--secondary module-button--small" href="/">Nexus Übersicht</a>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<?php if ($error !== null): ?>
|
||||
<section class="section-box"><?= e($error) ?></section>
|
||||
<?php elseif ($notice !== null): ?>
|
||||
<section class="section-box"><?= e($notice) ?></section>
|
||||
<?php endif; ?>
|
||||
|
||||
<section class="section-box">
|
||||
<h2>Neue Integration</h2>
|
||||
<form method="post" class="setup-form">
|
||||
<input type="hidden" name="action" value="create_integration">
|
||||
<div class="setup-grid">
|
||||
<label class="setup-field muted">
|
||||
<span>Name</span>
|
||||
<input type="text" name="name" required>
|
||||
</label>
|
||||
<label class="setup-field muted">
|
||||
<span>Typ</span>
|
||||
<select name="type">
|
||||
<option value="home_assistant">Home Assistant</option>
|
||||
<option value="pi_hole">Pi-hole</option>
|
||||
<option value="proxmox">Proxmox</option>
|
||||
<option value="docker">Docker</option>
|
||||
<option value="generic">Generic</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div class="setup-grid">
|
||||
<label class="setup-field muted">
|
||||
<span>Basis-URL</span>
|
||||
<input type="url" name="base_url" placeholder="https://...">
|
||||
</label>
|
||||
<label class="setup-field muted">
|
||||
<span>Sichtbarkeit</span>
|
||||
<select name="visibility">
|
||||
<option value="private">Privat</option>
|
||||
<option value="public">Öffentlich</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div class="setup-grid">
|
||||
<label class="setup-field muted">
|
||||
<span>Notizen</span>
|
||||
<input type="text" name="notes">
|
||||
</label>
|
||||
<label class="setup-field muted">
|
||||
<input type="checkbox" name="is_active" value="1" checked>
|
||||
<span>Aktiv</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="setup-actions setup-actions--footer">
|
||||
<button class="cta-button" type="submit">Integration speichern</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<div class="module-admin-grid">
|
||||
<?php foreach ($integrations as $integration): ?>
|
||||
<article class="card-box module-admin-card">
|
||||
<div class="module-admin-card__head">
|
||||
<div class="module-admin-card__title">
|
||||
<h2><?= e((string) ($integration['name'] ?? 'Integration')) ?></h2>
|
||||
<p><?= e((string) (($integration['config']['notes'] ?? '') ?: (string) ($integration['base_url'] ?? 'Zentrale externe Anbindung.'))) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="module-admin-meta">
|
||||
<div class="module-admin-meta__item">
|
||||
<span class="module-admin-meta__label">Typ</span>
|
||||
<strong class="module-admin-badge"><?= e((string) ($integration['type'] ?? 'generic')) ?></strong>
|
||||
</div>
|
||||
<div class="module-admin-meta__item">
|
||||
<span class="module-admin-meta__label">Status</span>
|
||||
<strong class="module-admin-badge<?= !empty($integration['is_active']) ? ' module-admin-badge--success' : ' module-admin-badge--warning' ?>"><?= !empty($integration['is_active']) ? 'Aktiv' : 'Inaktiv' ?></strong>
|
||||
</div>
|
||||
</div>
|
||||
<div class="module-admin-actions">
|
||||
<?php if (!empty($integration['base_url'])): ?>
|
||||
<a class="module-button module-button--secondary module-button--small" href="<?= e((string) $integration['base_url']) ?>" target="_blank" rel="noreferrer">Öffnen</a>
|
||||
<?php endif; ?>
|
||||
<form method="post">
|
||||
<input type="hidden" name="action" value="delete_integration">
|
||||
<input type="hidden" name="integration_id" value="<?= (int) ($integration['id'] ?? 0) ?>">
|
||||
<button class="module-button module-button--secondary module-button--small" type="submit">Löschen</button>
|
||||
</form>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div></div></div>
|
||||
Reference in New Issue
Block a user