nexus base
All checks were successful
Deploy / deploy-staging (push) Successful in 6s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-05-15 01:19:31 +02:00
parent 52158ef041
commit 3ed4fba58c
12 changed files with 1975 additions and 29 deletions

View File

@@ -0,0 +1,261 @@
<?php
declare(strict_types=1);
require_auth();
$service = dashboards();
$ownerKey = auth_user_key();
$groups = auth_groups();
$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">Dashboard-System nicht verfügbar.</section></div></div></div>';
return;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$action = trim((string) ($_POST['action'] ?? ''));
try {
if ($action === 'add_item') {
$dashboardId = (int) ($_POST['dashboard_id'] ?? 0);
$itemType = trim((string) ($_POST['item_type'] ?? 'link'));
$config = [];
if ($itemType === 'page_module') {
$config['page_module_id'] = (int) ($_POST['page_module_id'] ?? 0);
} else {
$config['url'] = trim((string) ($_POST['target_url'] ?? ''));
}
$service->createItem($dashboardId, $ownerKey, [
'item_type' => $itemType,
'title' => trim((string) ($_POST['title'] ?? '')),
'description' => trim((string) ($_POST['description'] ?? '')),
'grid_column' => trim((string) ($_POST['grid_column'] ?? '')),
'grid_row' => trim((string) ($_POST['grid_row'] ?? '')),
'column_span' => (int) ($_POST['column_span'] ?? 1),
'row_span' => (int) ($_POST['row_span'] ?? 1),
'config' => $config,
]);
$notice = 'Dashboard-Element hinzugefügt.';
} elseif ($action === 'delete_item') {
$service->deleteItem((int) ($_POST['item_id'] ?? 0), (int) ($_POST['dashboard_id'] ?? 0), $ownerKey);
$notice = 'Dashboard-Element entfernt.';
}
} catch (\Throwable $exception) {
$error = $exception->getMessage();
}
}
$accessibleDashboards = $service->listAccessibleDashboards($ownerKey, $groups);
$selectedDashboardId = (int) ($_GET['id'] ?? 0);
$currentDashboard = null;
foreach ($accessibleDashboards as $dashboard) {
if ((int) ($dashboard['id'] ?? 0) === $selectedDashboardId) {
$currentDashboard = $dashboard;
break;
}
}
if ($currentDashboard === null) {
$currentDashboard = $service->ensureDefaultDashboard($ownerKey, 'Mein Dashboard');
}
$currentDashboardId = (int) ($currentDashboard['id'] ?? 0);
$dashboardItems = $service->listItems($currentDashboardId);
$ownPageModules = $service->listPageModulesForOwner($ownerKey);
$pageModuleMap = [];
foreach ($ownPageModules as $pageModule) {
$pageModuleMap[(int) ($pageModule['id'] ?? 0)] = $pageModule;
}
$GLOBALS['layout_header_base_title'] = 'Nexus';
$GLOBALS['layout_header_title'] = 'Nexus';
$GLOBALS['layout_header_context'] = 'Dashboard';
$GLOBALS['layout_header_text'] = 'Persönliche Arbeitsfläche mit frei platzierbaren Dashboard-Elementen.';
?>
<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="Dashboard Navigation">
<a class="module-button module-button--tab-active" href="/dashboard">Dashboard</a>
<a class="module-button module-button--tab" href="/dashboards">Dashboards</a>
<a class="module-button module-button--tab" href="/integrations">Integrationen</a>
<a class="module-button module-button--tab" href="/page-modules">Seitenmodule</a>
<?php if (auth_is_admin()): ?>
<a class="module-button module-button--tab" href="/modules">Aktive Module</a>
<?php endif; ?>
</nav>
<div class="module-hero-actions module-submenu-actions">
<a class="module-button module-button--secondary module-button--small" href="/">Nexus Übersicht</a>
<a class="module-button module-button--secondary module-button--small" href="/settings">Nexus Einstellungen</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><?= e((string) ($currentDashboard['title'] ?? 'Dashboard')) ?></h2>
<p class="muted"><?= e((string) ($currentDashboard['description'] ?? 'Dein aktuelles Standard-Dashboard.')) ?></p>
<div class="setup-grid">
<label class="setup-field muted">
<span>Aktives Dashboard</span>
<select onchange="if (this.value) window.location.href='/dashboard?id=' + this.value;">
<?php foreach ($accessibleDashboards as $dashboard): ?>
<option value="<?= (int) ($dashboard['id'] ?? 0) ?>" <?= (int) ($dashboard['id'] ?? 0) === $currentDashboardId ? 'selected' : '' ?>>
<?= e((string) ($dashboard['title'] ?? 'Dashboard')) ?>
</option>
<?php endforeach; ?>
</select>
</label>
</div>
</section>
<section class="section-box">
<h2>Element hinzufügen</h2>
<p class="muted">V1 unterstützt direkte Links, iFrames und gespeicherte Seitenmodule.</p>
<form method="post" class="setup-form">
<input type="hidden" name="action" value="add_item">
<input type="hidden" name="dashboard_id" value="<?= $currentDashboardId ?>">
<div class="setup-grid">
<label class="setup-field muted">
<span>Titel</span>
<input type="text" name="title" required>
</label>
<label class="setup-field muted">
<span>Typ</span>
<select name="item_type" data-dashboard-item-type>
<option value="link">Link</option>
<option value="iframe">iFrame</option>
<option value="page_module">Seitenmodul</option>
</select>
</label>
</div>
<div class="setup-grid">
<label class="setup-field muted">
<span>Beschreibung</span>
<input type="text" name="description">
</label>
<label class="setup-field muted" data-dashboard-target-url>
<span>Ziel-URL</span>
<input type="url" name="target_url" placeholder="https://...">
</label>
<label class="setup-field muted" data-dashboard-page-module hidden>
<span>Seitenmodul</span>
<select name="page_module_id">
<option value="0">Bitte wählen</option>
<?php foreach ($ownPageModules as $pageModule): ?>
<option value="<?= (int) ($pageModule['id'] ?? 0) ?>"><?= e((string) ($pageModule['title'] ?? 'Seitenmodul')) ?></option>
<?php endforeach; ?>
</select>
</label>
</div>
<div class="setup-grid">
<label class="setup-field muted">
<span>Spaltenbreite</span>
<select name="column_span">
<option value="1">1</option>
<option value="2" selected>2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</label>
<label class="setup-field muted">
<span>Zeilenhöhe</span>
<select name="row_span">
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</label>
<label class="setup-field muted">
<span>Grid-Spalte optional</span>
<input type="number" name="grid_column" min="1" max="4">
</label>
</div>
<div class="setup-actions setup-actions--footer">
<button class="cta-button" type="submit">Element speichern</button>
</div>
</form>
</section>
<?php if ($dashboardItems === []): ?>
<section class="section-box dashboard-empty">Noch keine Elemente vorhanden.</section>
<?php else: ?>
<div class="dashboard-grid">
<?php foreach ($dashboardItems as $item): ?>
<?php
$itemType = (string) ($item['item_type'] ?? 'link');
$config = is_array($item['config'] ?? null) ? $item['config'] : [];
$columnSpan = max(1, min(4, (int) ($item['column_span'] ?? 1)));
$rowSpan = max(1, min(4, (int) ($item['row_span'] ?? 1)));
$gridStyles = 'grid-column: span ' . $columnSpan . '; grid-row: span ' . $rowSpan . ';';
if (!empty($item['grid_column'])) {
$gridStyles .= 'grid-column-start:' . (int) $item['grid_column'] . ';';
}
if (!empty($item['grid_row'])) {
$gridStyles .= 'grid-row-start:' . (int) $item['grid_row'] . ';';
}
$pageModule = null;
if ($itemType === 'page_module' && !empty($config['page_module_id'])) {
$pageModule = $pageModuleMap[(int) $config['page_module_id']] ?? null;
}
$targetUrl = trim((string) ($config['url'] ?? ''));
if ($pageModule !== null) {
$targetUrl = trim((string) ($pageModule['target_url'] ?? $targetUrl));
}
?>
<article class="card-box dashboard-widget" style="<?= e($gridStyles) ?>">
<div class="dashboard-widget__head">
<div>
<span class="module-admin-meta__label"><?= e(strtoupper($itemType)) ?></span>
<h2><?= e((string) ($item['title'] ?? 'Element')) ?></h2>
<?php if (!empty($item['description'])): ?>
<p><?= e((string) $item['description']) ?></p>
<?php endif; ?>
</div>
<form method="post">
<input type="hidden" name="action" value="delete_item">
<input type="hidden" name="dashboard_id" value="<?= $currentDashboardId ?>">
<input type="hidden" name="item_id" value="<?= (int) ($item['id'] ?? 0) ?>">
<button class="module-button module-button--secondary module-button--small" type="submit">Entfernen</button>
</form>
</div>
<?php if (($itemType === 'iframe' || ($pageModule !== null && (string) ($pageModule['module_type'] ?? '') === 'iframe')) && $targetUrl !== ''): ?>
<iframe class="dashboard-widget__frame" src="<?= e($targetUrl) ?>" loading="lazy" referrerpolicy="no-referrer"></iframe>
<?php elseif ($pageModule !== null): ?>
<div class="dashboard-widget__meta">
<p><?= e((string) ($pageModule['description'] ?? 'Seitenmodul aus der globalen Nexus-Verwaltung.')) ?></p>
<a class="module-button module-button--secondary module-button--small" href="/page-modules/view/<?= (int) ($pageModule['id'] ?? 0) ?>">Öffnen</a>
</div>
<?php elseif ($targetUrl !== ''): ?>
<div class="dashboard-widget__meta">
<p><?= e($targetUrl) ?></p>
<a class="module-button module-button--secondary module-button--small" href="<?= e($targetUrl) ?>" target="_blank" rel="noreferrer">Öffnen</a>
</div>
<?php else: ?>
<div class="dashboard-widget__meta"><p>Für dieses Element ist noch kein Inhalt hinterlegt.</p></div>
<?php endif; ?>
</article>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div></div></div>
<script>
(() => {
const typeSelect = document.querySelector('[data-dashboard-item-type]');
const urlField = document.querySelector('[data-dashboard-target-url]');
const pageModuleField = document.querySelector('[data-dashboard-page-module]');
if (!typeSelect || !urlField || !pageModuleField) return;
const sync = () => {
const isPageModule = typeSelect.value === 'page_module';
urlField.hidden = isPageModule;
pageModuleField.hidden = !isPageModule;
};
typeSelect.addEventListener('change', sync);
sync();
})();
</script>

View File

@@ -0,0 +1,142 @@
<?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">Dashboard-System nicht verfügbar.</section></div></div></div>';
return;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$action = trim((string) ($_POST['action'] ?? ''));
try {
if ($action === 'create_dashboard') {
$service->createDashboard($ownerKey, [
'title' => trim((string) ($_POST['title'] ?? '')),
'slug' => trim((string) ($_POST['slug'] ?? '')),
'description' => trim((string) ($_POST['description'] ?? '')),
'visibility' => trim((string) ($_POST['visibility'] ?? 'private')),
'is_default' => isset($_POST['is_default']),
]);
$notice = 'Dashboard angelegt.';
} elseif ($action === 'set_default') {
$service->setDefaultDashboard($ownerKey, (int) ($_POST['dashboard_id'] ?? 0));
$notice = 'Standard-Dashboard gesetzt.';
} elseif ($action === 'delete_dashboard') {
$service->deleteDashboard((int) ($_POST['dashboard_id'] ?? 0), $ownerKey);
$notice = 'Dashboard gelöscht.';
}
} catch (\Throwable $exception) {
$error = $exception->getMessage();
}
}
$dashboardsList = $service->listDashboardsForOwner($ownerKey);
$GLOBALS['layout_header_base_title'] = 'Nexus';
$GLOBALS['layout_header_title'] = 'Nexus';
$GLOBALS['layout_header_context'] = 'Dashboards';
$GLOBALS['layout_header_text'] = 'Verwaltung persönlicher und später freigebbarer Dashboard-Flächen.';
?>
<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="Dashboard Verwaltung">
<a class="module-button module-button--tab" href="/dashboard">Dashboard</a>
<a class="module-button module-button--tab-active" href="/dashboards">Dashboards</a>
<a class="module-button module-button--tab" 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>Neues Dashboard</h2>
<form method="post" class="setup-form">
<input type="hidden" name="action" value="create_dashboard">
<div class="setup-grid">
<label class="setup-field muted">
<span>Titel</span>
<input type="text" name="title" required>
</label>
<label class="setup-field muted">
<span>Slug optional</span>
<input type="text" name="slug">
</label>
</div>
<div class="setup-grid">
<label class="setup-field muted">
<span>Beschreibung</span>
<input type="text" name="description">
</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>
<label class="setup-field muted">
<input type="checkbox" name="is_default" value="1">
<span>Als Standard-Dashboard setzen</span>
</label>
<div class="setup-actions setup-actions--footer">
<button class="cta-button" type="submit">Dashboard anlegen</button>
</div>
</form>
</section>
<div class="module-admin-grid">
<?php foreach ($dashboardsList as $dashboard): ?>
<article class="card-box module-admin-card">
<div class="module-admin-card__head">
<div class="module-admin-card__title">
<h2><?= e((string) ($dashboard['title'] ?? 'Dashboard')) ?></h2>
<p><?= e((string) ($dashboard['description'] ?? 'Persönliche Dashboard-Fläche.')) ?></p>
</div>
</div>
<div class="module-admin-meta">
<div class="module-admin-meta__item">
<span class="module-admin-meta__label">Sichtbarkeit</span>
<strong class="module-admin-badge"><?= e(ucfirst((string) ($dashboard['visibility'] ?? 'private'))) ?></strong>
</div>
<div class="module-admin-meta__item">
<span class="module-admin-meta__label">Standard</span>
<strong class="module-admin-badge<?= !empty($dashboard['is_default']) ? ' module-admin-badge--success' : '' ?>"><?= !empty($dashboard['is_default']) ? 'Ja' : 'Nein' ?></strong>
</div>
</div>
<div class="module-admin-actions">
<a class="module-button module-button--secondary module-button--small" href="/dashboard?id=<?= (int) ($dashboard['id'] ?? 0) ?>">Öffnen</a>
<?php if (empty($dashboard['is_default'])): ?>
<form method="post">
<input type="hidden" name="action" value="set_default">
<input type="hidden" name="dashboard_id" value="<?= (int) ($dashboard['id'] ?? 0) ?>">
<button class="module-button module-button--secondary module-button--small" type="submit">Als Standard</button>
</form>
<?php endif; ?>
<form method="post">
<input type="hidden" name="action" value="delete_dashboard">
<input type="hidden" name="dashboard_id" value="<?= (int) ($dashboard['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>

219
partials/landingpages/index.php Executable file → Normal file
View File

@@ -3,39 +3,202 @@ declare(strict_types=1);
$auth = app()->auth();
$authUser = $auth->user();
$ownerKey = auth_user_key();
$groups = auth_groups();
$service = dashboards();
$modules = array_values(array_filter(
$auth->filterModules(modules()->all()),
static fn (array $module): bool => !empty($module['enabled'])
));
?>
<section class="module-list-section" data-reveal>
<?php if ($authUser !== null): ?>
<div class="section-head">
<div style="display:flex; gap:10px; flex-wrap:wrap;">
<a class="nav-link" href="/modules">Module verwalten</a>
<?php if (auth_is_admin()): ?>
<a class="nav-link" href="/settings">Nexus Einstellungen</a>
<a class="nav-link" href="/exports/database.sql">SQL-Export</a>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<?php if ($modules === []): ?>
<div class="empty-state" data-reveal>
Keine Module für den aktuellen Zugriff sichtbar.
$dashboardsList = [];
$pageModules = [];
$defaultDashboard = null;
$dashboardItems = [];
if ($authUser !== null && $service->available() && $ownerKey !== '') {
$defaultDashboard = $service->ensureDefaultDashboard($ownerKey, 'Mein Dashboard');
$dashboardsList = $service->listAccessibleDashboards($ownerKey, $groups);
$pageModules = $service->listPageModulesForOwner($ownerKey);
if ($defaultDashboard !== []) {
$dashboardItems = $service->listItems((int) ($defaultDashboard['id'] ?? 0));
}
}
$GLOBALS['layout_header_base_title'] = 'Nexus';
$GLOBALS['layout_header_title'] = 'Nexus';
$GLOBALS['layout_header_context'] = 'Übersicht';
$GLOBALS['layout_header_text'] = $authUser === null
? 'Zentraler Einstieg in Nexus und die verfügbaren Bereiche.'
: 'Persönliche Übersicht aus Dashboards, Seitenmodulen und klassischen Modulen.';
?>
<div class="module-shell"><div class="module-page-bg"><div class="module-page-stack">
<?php if ($authUser !== null): ?>
<header class="module-hero submenu-box">
<div class="module-hero-top module-hero-top--compact">
<nav class="module-tabs" aria-label="Nexus Navigation">
<a class="module-button module-button--tab-active" href="/">Nexus Übersicht</a>
<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" href="/integrations">Integrationen</a>
<a class="module-button module-button--tab" href="/page-modules">Seitenmodule</a>
<?php if (auth_is_admin()): ?>
<a class="module-button module-button--tab" href="/modules">Aktive Module</a>
<?php endif; ?>
</nav>
<div class="module-hero-actions module-submenu-actions">
<a class="module-button module-button--secondary module-button--small" href="/settings">Nexus Einstellungen</a>
</div>
</div>
</header>
<section class="section-box">
<h2>Mein Standard-Dashboard</h2>
<p class="muted">Der schnellste Einstieg in deine wichtigsten Nexus-Inhalte.</p>
<?php if ($defaultDashboard === null || $defaultDashboard === []): ?>
<div class="dashboard-empty">Kein Dashboard verfügbar.</div>
<?php else: ?>
<div class="nexus-quick-grid">
<article class="card-box nexus-stat-card">
<span class="module-admin-meta__label">Dashboard</span>
<strong><?= e((string) ($defaultDashboard['title'] ?? 'Mein Dashboard')) ?></strong>
<p class="muted"><?= e((string) ($defaultDashboard['description'] ?? 'Persönliches Standard-Dashboard')) ?></p>
<a class="module-button module-button--secondary module-button--small" href="/dashboard?id=<?= (int) ($defaultDashboard['id'] ?? 0) ?>">Öffnen</a>
</article>
<article class="card-box nexus-stat-card">
<span class="module-admin-meta__label">Elemente</span>
<strong><?= count($dashboardItems) ?></strong>
<p class="muted">Aktive Dashboard-Elemente im Standard-Dashboard.</p>
</article>
<article class="card-box nexus-stat-card">
<span class="module-admin-meta__label">Seitenmodule</span>
<strong><?= count($pageModules) ?></strong>
<p class="muted">Eigene, on-the-fly angelegte Seitenmodule.</p>
</article>
<article class="card-box nexus-stat-card">
<span class="module-admin-meta__label">Klassische Module</span>
<strong><?= count($modules) ?></strong>
<p class="muted">Aktuell sichtbare, klassische Nexus-Module.</p>
</article>
</div>
<?php endif; ?>
</section>
<section class="section-box">
<h2>Dashboards</h2>
<p class="muted">Eigene und freigegebene Dashboards im globalen Nexus-System.</p>
<div class="module-admin-grid module-admin-grid--compact">
<?php foreach (array_slice($dashboardsList, 0, 6) as $dashboard): ?>
<article class="card-box module-admin-card">
<div class="module-admin-card__head">
<div class="module-admin-card__title">
<h2><?= e((string) ($dashboard['title'] ?? 'Dashboard')) ?></h2>
<p><?= e((string) ($dashboard['description'] ?? 'Flexible Dashboard-Fläche für Widgets und Seitenmodule.')) ?></p>
</div>
</div>
<div class="module-admin-meta">
<div class="module-admin-meta__item">
<span class="module-admin-meta__label">Sichtbarkeit</span>
<strong class="module-admin-badge"><?= e(ucfirst((string) ($dashboard['visibility'] ?? 'private'))) ?></strong>
</div>
</div>
<div class="module-admin-actions">
<a class="module-button module-button--secondary module-button--small" href="/dashboard?id=<?= (int) ($dashboard['id'] ?? 0) ?>">Öffnen</a>
</div>
</article>
<?php endforeach; ?>
</div>
</section>
<div class="module-admin-grid">
<article class="card-box module-admin-card">
<div class="module-admin-card__head">
<div class="module-admin-card__title">
<h2>Seitenmodule</h2>
<p>On-the-fly angelegte Zielseiten und eingebettete Tools.</p>
</div>
</div>
<div class="module-admin-meta">
<div class="module-admin-meta__item">
<span class="module-admin-meta__label">Anzahl</span>
<strong class="module-admin-badge module-admin-badge--success"><?= count($pageModules) ?></strong>
</div>
</div>
<div class="module-admin-actions">
<a class="module-button module-button--secondary module-button--small" href="/page-modules">Verwalten</a>
</div>
</article>
<article class="card-box module-admin-card">
<div class="module-admin-card__head">
<div class="module-admin-card__title">
<h2>Integrationen</h2>
<p>Zentrale Anbindungen an Home Assistant, Pi-hole, Proxmox und andere Systeme.</p>
</div>
</div>
<div class="module-admin-actions">
<a class="module-button module-button--secondary module-button--small" href="/integrations">Verwalten</a>
</div>
</article>
<article class="card-box module-admin-card">
<div class="module-admin-card__head">
<div class="module-admin-card__title">
<h2>Dashboards konfigurieren</h2>
<p>Eigene Dashboard-Flächen, Reihenfolge und Standard-Dashboard verwalten.</p>
</div>
</div>
<div class="module-admin-actions">
<a class="module-button module-button--secondary module-button--small" href="/dashboards">Öffnen</a>
</div>
</article>
</div>
<section class="section-box">
<h2>Klassische Module</h2>
<p class="muted">Die bisherigen Nexus-Module bleiben parallel zum neuen Grundgerüst bestehen.</p>
<div class="module-list">
<?php foreach ($modules as $module): ?>
<a class="module-row" href="<?= e((string) ($module['entry'] ?? ('/module/' . $module['name']))) ?>">
<span class="module-row__icon"><?= e(strtoupper(substr((string) ($module['title'] ?? $module['name']), 0, 1))) ?></span>
<span class="module-row__content">
<strong class="module-title"><?= e((string) ($module['title'] ?? $module['name'] ?? 'Modul')) ?></strong>
<span class="module-desc"><?= e((string) ($module['description'] ?? '')) ?></span>
</span>
</a>
<?php endforeach; ?>
</div>
</section>
<?php else: ?>
<div class="module-list">
<?php foreach ($modules as $module): ?>
<a class="module-row" href="<?= e((string)($module['entry'] ?? ('/module/' . $module['name']))) ?>">
<span class="module-row__icon"><?= e(strtoupper(substr((string)($module['title'] ?? $module['name']), 0, 1))) ?></span>
<span class="module-row__content">
<strong class="module-title"><?= e((string)($module['title'] ?? $module['name'] ?? 'Modul')) ?></strong>
<span class="module-desc"><?= e((string)($module['description'] ?? '')) ?></span>
</span>
</a>
<?php endforeach; ?>
</div>
<section class="section-box">
<h2>Nexus Einstieg</h2>
<p class="muted">Nach der Anmeldung stehen persönliche Dashboards, Integrationen und Seitenmodule bereit.</p>
<div class="module-admin-grid">
<article class="card-box module-admin-card">
<div class="module-admin-card__head">
<div class="module-admin-card__title">
<h2>Persönliche Dashboards</h2>
<p>Mehrere frei konfigurierbare Übersichten pro Benutzer.</p>
</div>
</div>
</article>
<article class="card-box module-admin-card">
<div class="module-admin-card__head">
<div class="module-admin-card__title">
<h2>Integrationen</h2>
<p>Zentrale Anbindungen für Fremdsysteme und externe Datenquellen.</p>
</div>
</div>
</article>
<article class="card-box module-admin-card">
<div class="module-admin-card__head">
<div class="module-admin-card__title">
<h2>Seitenmodule</h2>
<p>On-the-fly angelegte Links und eingebettete Weboberflächen.</p>
</div>
</div>
</article>
</div>
</section>
<?php endif; ?>
</section>
</div></div></div>

View 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>

View File

@@ -0,0 +1,158 @@
<?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">Seitenmodul-System nicht verfügbar.</section></div></div></div>';
return;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$action = trim((string) ($_POST['action'] ?? ''));
try {
if ($action === 'create_page_module') {
$service->createPageModule($ownerKey, [
'title' => trim((string) ($_POST['title'] ?? '')),
'slug' => trim((string) ($_POST['slug'] ?? '')),
'module_type' => trim((string) ($_POST['module_type'] ?? 'link')),
'target_url' => trim((string) ($_POST['target_url'] ?? '')),
'description' => trim((string) ($_POST['description'] ?? '')),
'visibility' => trim((string) ($_POST['visibility'] ?? 'private')),
'open_mode' => trim((string) ($_POST['open_mode'] ?? 'embed')),
'is_active' => isset($_POST['is_active']),
]);
$notice = 'Seitenmodul angelegt.';
} elseif ($action === 'delete_page_module') {
$service->deletePageModule((int) ($_POST['page_module_id'] ?? 0), $ownerKey);
$notice = 'Seitenmodul gelöscht.';
}
} catch (\Throwable $exception) {
$error = $exception->getMessage();
}
}
$pageModules = $service->listPageModulesForOwner($ownerKey);
$GLOBALS['layout_header_base_title'] = 'Nexus';
$GLOBALS['layout_header_title'] = 'Nexus';
$GLOBALS['layout_header_context'] = 'Seitenmodule';
$GLOBALS['layout_header_text'] = 'On-the-fly angelegte Link- und iFrame-Module ohne eigenen Modulordner.';
?>
<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="Seitenmodule 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" href="/integrations">Integrationen</a>
<a class="module-button module-button--tab-active" 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>Neues Seitenmodul</h2>
<form method="post" class="setup-form">
<input type="hidden" name="action" value="create_page_module">
<div class="setup-grid">
<label class="setup-field muted">
<span>Titel</span>
<input type="text" name="title" required>
</label>
<label class="setup-field muted">
<span>Slug optional</span>
<input type="text" name="slug">
</label>
</div>
<div class="setup-grid">
<label class="setup-field muted">
<span>Typ</span>
<select name="module_type">
<option value="link">Link</option>
<option value="iframe">iFrame</option>
</select>
</label>
<label class="setup-field muted">
<span>Ziel-URL</span>
<input type="url" name="target_url" required placeholder="https://...">
</label>
</div>
<div class="setup-grid">
<label class="setup-field muted">
<span>Beschreibung</span>
<input type="text" name="description">
</label>
<label class="setup-field muted">
<span>Öffnen als</span>
<select name="open_mode">
<option value="embed">Im Nexus einbetten</option>
<option value="new_tab">Neuer Tab</option>
<option value="same_tab">Direkt öffnen</option>
</select>
</label>
</div>
<div class="setup-grid">
<label class="setup-field muted">
<span>Sichtbarkeit</span>
<select name="visibility">
<option value="private">Privat</option>
<option value="public">Öffentlich</option>
</select>
</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">Seitenmodul speichern</button>
</div>
</form>
</section>
<div class="module-admin-grid">
<?php foreach ($pageModules as $pageModule): ?>
<article class="card-box module-admin-card">
<div class="module-admin-card__head">
<div class="module-admin-card__title">
<h2><?= e((string) ($pageModule['title'] ?? 'Seitenmodul')) ?></h2>
<p><?= e((string) ($pageModule['description'] ?? ($pageModule['target_url'] ?? ''))) ?></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) ($pageModule['module_type'] ?? 'link')) ?></strong>
</div>
<div class="module-admin-meta__item">
<span class="module-admin-meta__label">Öffnen</span>
<strong class="module-admin-badge"><?= e((string) ($pageModule['open_mode'] ?? 'embed')) ?></strong>
</div>
</div>
<div class="module-admin-actions">
<a class="module-button module-button--secondary module-button--small" href="/page-modules/view/<?= (int) ($pageModule['id'] ?? 0) ?>">Öffnen</a>
<form method="post">
<input type="hidden" name="action" value="delete_page_module">
<input type="hidden" name="page_module_id" value="<?= (int) ($pageModule['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>

View File

@@ -0,0 +1,58 @@
<?php
declare(strict_types=1);
require_auth();
$service = dashboards();
$ownerKey = auth_user_key();
$groups = auth_groups();
$pageModuleId = (int) ($_GET['id'] ?? 0);
$pageModule = $service->getPageModule($pageModuleId, $ownerKey, $groups);
if ($pageModule === null) {
http_response_code(404);
echo '<div class="module-shell"><div class="module-page-bg"><div class="module-page-stack"><section class="section-box">Seitenmodul nicht gefunden.</section></div></div></div>';
return;
}
$targetUrl = trim((string) ($pageModule['target_url'] ?? ''));
$openMode = (string) ($pageModule['open_mode'] ?? 'embed');
if ($targetUrl !== '' && $openMode === 'same_tab') {
redirect($targetUrl);
}
$GLOBALS['layout_header_base_title'] = 'Nexus';
$GLOBALS['layout_header_title'] = 'Nexus';
$GLOBALS['layout_header_context'] = (string) ($pageModule['title'] ?? 'Seitenmodul');
$GLOBALS['layout_header_text'] = (string) ($pageModule['description'] ?? 'On-the-fly angelegtes Seitenmodul.');
?>
<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="Seitenmodul 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" href="/integrations">Integrationen</a>
<a class="module-button module-button--tab-active" 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>
<section class="section-box">
<h2><?= e((string) ($pageModule['title'] ?? 'Seitenmodul')) ?></h2>
<p class="muted"><?= e((string) ($pageModule['description'] ?? '')) ?></p>
<?php if ($targetUrl === ''): ?>
<div class="dashboard-empty">Dieses Seitenmodul hat noch keine Ziel-URL.</div>
<?php elseif ((string) ($pageModule['module_type'] ?? 'link') === 'iframe' || $openMode === 'embed'): ?>
<iframe class="dashboard-widget__frame dashboard-widget__frame--page" src="<?= e($targetUrl) ?>" loading="lazy" referrerpolicy="no-referrer"></iframe>
<?php else: ?>
<div class="dashboard-widget__meta">
<p><?= e($targetUrl) ?></p>
<a class="module-button module-button--secondary module-button--small" href="<?= e($targetUrl) ?>" target="_blank" rel="noreferrer">Extern öffnen</a>
</div>
<?php endif; ?>
</section>
</div></div></div>