nexus basic

This commit is contained in:
2026-06-04 22:07:25 +02:00
parent aa7ec1d321
commit 3c1cc30fe9
11 changed files with 1222 additions and 197 deletions

View File

@@ -23,6 +23,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$config = [];
if ($itemType === 'page_module') {
$config['page_module_id'] = (int) ($_POST['page_module_id'] ?? 0);
} elseif ($itemType === 'app') {
$config['app_id'] = (int) ($_POST['app_id'] ?? 0);
} elseif ($itemType === 'widget_template') {
$config['widget_template_id'] = (int) ($_POST['widget_template_id'] ?? 0);
} elseif ($itemType === 'bookmark_group') {
$config['bookmarks'] = trim((string) ($_POST['bookmarks'] ?? ''));
} else {
$config['url'] = trim((string) ($_POST['target_url'] ?? ''));
}
@@ -61,10 +67,20 @@ if ($currentDashboard === null) {
$currentDashboardId = (int) ($currentDashboard['id'] ?? 0);
$dashboardItems = $service->listItems($currentDashboardId);
$ownPageModules = $service->listPageModulesForOwner($ownerKey);
$availableApps = $service->listApps($ownerKey, true);
$availableWidgetTemplates = $service->listWidgetTemplates($ownerKey, true);
$pageModuleMap = [];
foreach ($ownPageModules as $pageModule) {
$pageModuleMap[(int) ($pageModule['id'] ?? 0)] = $pageModule;
}
$appMap = [];
foreach ($availableApps as $appEntry) {
$appMap[(int) ($appEntry['id'] ?? 0)] = $appEntry;
}
$widgetTemplateMap = [];
foreach ($availableWidgetTemplates as $template) {
$widgetTemplateMap[(int) ($template['id'] ?? 0)] = $template;
}
$GLOBALS['layout_header_base_title'] = 'Nexus';
$GLOBALS['layout_header_title'] = 'Nexus';
@@ -115,7 +131,7 @@ $GLOBALS['layout_header_text'] = 'Persönliche Arbeitsfläche mit frei platzierb
<section class="section-box">
<h2>Element hinzufügen</h2>
<p class="muted">V1 unterstützt direkte Links, iFrames und gespeicherte Seitenmodule.</p>
<p class="muted">Verfügbar sind direkte Links, iFrames, persönliche Linklisten, globale Apps, Seitenmodule und wiederverwendbare Widgets.</p>
<form method="post" class="setup-form">
<input type="hidden" name="action" value="add_item">
<input type="hidden" name="dashboard_id" value="<?= $currentDashboardId ?>">
@@ -129,7 +145,10 @@ $GLOBALS['layout_header_text'] = 'Persönliche Arbeitsfläche mit frei platzierb
<select name="item_type" data-dashboard-item-type>
<option value="link">Link</option>
<option value="iframe">iFrame</option>
<option value="bookmark_group">Linkliste</option>
<option value="app">App</option>
<option value="page_module">Seitenmodul</option>
<option value="widget_template">Widget-Vorlage</option>
</select>
</label>
</div>
@@ -142,6 +161,19 @@ $GLOBALS['layout_header_text'] = 'Persönliche Arbeitsfläche mit frei platzierb
<span>Ziel-URL</span>
<input type="url" name="target_url" placeholder="https://...">
</label>
<label class="setup-field muted" data-dashboard-bookmarks hidden>
<span>Linkliste</span>
<textarea name="bookmarks" rows="5" placeholder="Bezeichnung | https://ziel.example&#10;Nexus | /dashboard"></textarea>
</label>
<label class="setup-field muted" data-dashboard-app hidden>
<span>App</span>
<select name="app_id">
<option value="0">Bitte wählen</option>
<?php foreach ($availableApps as $appEntry): ?>
<option value="<?= (int) ($appEntry['id'] ?? 0) ?>"><?= e((string) ($appEntry['name'] ?? 'App')) ?></option>
<?php endforeach; ?>
</select>
</label>
<label class="setup-field muted" data-dashboard-page-module hidden>
<span>Seitenmodul</span>
<select name="page_module_id">
@@ -151,6 +183,15 @@ $GLOBALS['layout_header_text'] = 'Persönliche Arbeitsfläche mit frei platzierb
<?php endforeach; ?>
</select>
</label>
<label class="setup-field muted" data-dashboard-widget-template hidden>
<span>Widget-Vorlage</span>
<select name="widget_template_id">
<option value="0">Bitte wählen</option>
<?php foreach ($availableWidgetTemplates as $template): ?>
<option value="<?= (int) ($template['id'] ?? 0) ?>"><?= e((string) ($template['name'] ?? 'Widget')) ?></option>
<?php endforeach; ?>
</select>
</label>
</div>
<div class="setup-grid">
<label class="setup-field muted">
@@ -189,6 +230,11 @@ $GLOBALS['layout_header_text'] = 'Persönliche Arbeitsfläche mit frei platzierb
<?php
$itemType = (string) ($item['item_type'] ?? 'link');
$config = is_array($item['config'] ?? null) ? $item['config'] : [];
if ($itemType === 'widget_template' && !empty($config['widget_template_id']) && isset($widgetTemplateMap[(int) $config['widget_template_id']])) {
$template = $widgetTemplateMap[(int) $config['widget_template_id']];
$itemType = (string) ($template['widget_type'] ?? $itemType);
$config = array_merge(is_array($template['config'] ?? null) ? $template['config'] : [], $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 . ';';
@@ -202,10 +248,30 @@ $GLOBALS['layout_header_text'] = 'Persönliche Arbeitsfläche mit frei platzierb
if ($itemType === 'page_module' && !empty($config['page_module_id'])) {
$pageModule = $pageModuleMap[(int) $config['page_module_id']] ?? null;
}
$appEntry = null;
if ($itemType === 'app' && !empty($config['app_id'])) {
$appEntry = $appMap[(int) $config['app_id']] ?? null;
}
$targetUrl = trim((string) ($config['url'] ?? ''));
if ($pageModule !== null) {
$targetUrl = trim((string) ($pageModule['target_url'] ?? $targetUrl));
}
if ($appEntry !== null) {
$targetUrl = trim((string) ($appEntry['app_url'] ?? $targetUrl));
}
$bookmarks = [];
if ($itemType === 'bookmark_group') {
foreach (preg_split('/\r\n|\r|\n/', trim((string) ($config['bookmarks'] ?? ''))) ?: [] as $line) {
$line = trim($line);
if ($line === '') {
continue;
}
[$label, $url] = array_pad(array_map('trim', explode('|', $line, 2)), 2, '');
if ($label !== '' && $url !== '') {
$bookmarks[] = ['label' => $label, 'url' => $url];
}
}
}
?>
<article class="card-box dashboard-widget" style="<?= e($gridStyles) ?>">
<div class="dashboard-widget__head">
@@ -224,8 +290,22 @@ $GLOBALS['layout_header_text'] = 'Persönliche Arbeitsfläche mit frei platzierb
</form>
</div>
<?php if (($itemType === 'iframe' || ($pageModule !== null && (string) ($pageModule['module_type'] ?? '') === 'iframe')) && $targetUrl !== ''): ?>
<?php if ($itemType === 'bookmark_group' && $bookmarks !== []): ?>
<div class="dashboard-links">
<?php foreach ($bookmarks as $bookmark): ?>
<a class="module-button module-button--secondary module-button--small" href="<?= e($bookmark['url']) ?>" target="_blank" rel="noreferrer"><?= e($bookmark['label']) ?></a>
<?php endforeach; ?>
</div>
<?php elseif (($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 ($appEntry !== null): ?>
<div class="dashboard-widget__meta">
<?php if (!empty($appEntry['icon_url'])): ?>
<img class="dashboard-app-icon" src="<?= e((string) $appEntry['icon_url']) ?>" alt="">
<?php endif; ?>
<p><?= e((string) ($appEntry['description'] ?? $targetUrl)) ?></p>
<a class="module-button module-button--secondary module-button--small" href="<?= e($targetUrl) ?>" target="_blank" rel="noreferrer">App öffnen</a>
</div>
<?php elseif ($pageModule !== null): ?>
<div class="dashboard-widget__meta">
<p><?= e((string) ($pageModule['description'] ?? 'Seitenmodul aus der globalen Nexus-Verwaltung.')) ?></p>
@@ -249,11 +329,17 @@ $GLOBALS['layout_header_text'] = 'Persönliche Arbeitsfläche mit frei platzierb
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 bookmarksField = document.querySelector('[data-dashboard-bookmarks]');
const appField = document.querySelector('[data-dashboard-app]');
const widgetTemplateField = document.querySelector('[data-dashboard-widget-template]');
if (!typeSelect || !urlField || !pageModuleField || !bookmarksField || !appField || !widgetTemplateField) return;
const sync = () => {
const isPageModule = typeSelect.value === 'page_module';
urlField.hidden = isPageModule;
pageModuleField.hidden = !isPageModule;
const value = typeSelect.value;
urlField.hidden = !['link', 'iframe'].includes(value);
pageModuleField.hidden = value !== 'page_module';
bookmarksField.hidden = value !== 'bookmark_group';
appField.hidden = value !== 'app';
widgetTemplateField.hidden = value !== 'widget_template';
};
typeSelect.addEventListener('change', sync);
sync();