deploy
This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
$pdo = app()->basePdo();
|
||||
$error = null;
|
||||
$notice = null;
|
||||
|
||||
require_admin();
|
||||
|
||||
if (!$pdo) {
|
||||
echo '<div class="card">Base-DB nicht aktiviert.</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$action = (string)($_POST['action'] ?? '');
|
||||
|
||||
if ($action === 'add_role') {
|
||||
$role = trim((string)($_POST['role'] ?? ''));
|
||||
$desc = trim((string)($_POST['description'] ?? ''));
|
||||
if ($role === '') {
|
||||
$error = 'Rollenname fehlt.';
|
||||
} else {
|
||||
$stmt = $pdo->prepare(
|
||||
"INSERT INTO nexus_roles (name, description)
|
||||
VALUES (:name, :description)
|
||||
ON CONFLICT(name) DO UPDATE SET description = excluded.description"
|
||||
);
|
||||
$stmt->execute(['name' => $role, 'description' => $desc]);
|
||||
$notice = 'Rolle gespeichert.';
|
||||
}
|
||||
} elseif ($action === 'add_user') {
|
||||
$email = trim((string)($_POST['email'] ?? ''));
|
||||
$password = (string)($_POST['password'] ?? '');
|
||||
$role = trim((string)($_POST['role'] ?? 'user'));
|
||||
|
||||
if ($email === '' || $password === '') {
|
||||
$error = 'E-Mail und Passwort sind erforderlich.';
|
||||
} else {
|
||||
$hash = password_hash($password, PASSWORD_DEFAULT);
|
||||
$pdo->prepare(
|
||||
"INSERT INTO nexus_users (email, password_hash, role, is_active)
|
||||
VALUES (:email, :hash, :role, 1)"
|
||||
)->execute([
|
||||
'email' => $email,
|
||||
'hash' => $hash,
|
||||
'role' => $role !== '' ? $role : 'user',
|
||||
]);
|
||||
|
||||
$pdo->prepare(
|
||||
"INSERT INTO nexus_roles (name) VALUES (:name)
|
||||
ON CONFLICT(name) DO NOTHING"
|
||||
)->execute(['name' => $role !== '' ? $role : 'user']);
|
||||
|
||||
$notice = 'User angelegt.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$roles = $pdo->query("SELECT name, description FROM nexus_roles ORDER BY name")->fetchAll(PDO::FETCH_ASSOC) ?: [];
|
||||
$users = $pdo->query("SELECT id, email, role, is_active, created_at FROM nexus_users ORDER BY id DESC")->fetchAll(PDO::FETCH_ASSOC) ?: [];
|
||||
?>
|
||||
<div class="card">
|
||||
<div class="pill">Userverwaltung</div>
|
||||
<h1 style="margin-top:.75rem;">User & Rollen</h1>
|
||||
<p class="muted">Admin kann Module aktivieren/deaktivieren, Benutzer können Module nutzen.</p>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div class="bg-red-900 border-l-4 border-red-500 text-red-100 p-4 mb-6" role="alert">
|
||||
<?= e($error) ?>
|
||||
</div>
|
||||
<?php elseif ($notice): ?>
|
||||
<div class="card" style="margin-top:1rem; border-color:var(--accent-2);">
|
||||
<?= e($notice) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div style="margin-top:1.5rem;" class="grid">
|
||||
<div class="card" style="background:var(--panel-2);">
|
||||
<strong>Rollen</strong>
|
||||
<ul style="margin-top:.5rem;">
|
||||
<?php foreach ($roles as $r): ?>
|
||||
<li><?= e($r['name']) ?> <span class="muted"><?= e($r['description'] ?? '') ?></span></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
<form method="post" style="margin-top:1rem; display:grid; gap:10px;">
|
||||
<input type="hidden" name="action" value="add_role">
|
||||
<input type="text" name="role" placeholder="Rollenname (z. B. admin)">
|
||||
<input type="text" name="description" placeholder="Beschreibung">
|
||||
<button class="cta-button" type="submit">Rolle hinzufügen</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="card" style="background:var(--panel-2);">
|
||||
<strong>User anlegen</strong>
|
||||
<form method="post" style="margin-top:1rem; display:grid; gap:10px;">
|
||||
<input type="hidden" name="action" value="add_user">
|
||||
<input type="email" name="email" placeholder="E-Mail">
|
||||
<input type="password" name="password" placeholder="Passwort">
|
||||
<input type="text" name="role" placeholder="Rolle (admin|user|...)">
|
||||
<button class="cta-button" type="submit">User anlegen</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3 style="margin-top:1.5rem;">Userliste</h3>
|
||||
<div style="margin-top:.5rem; background:var(--panel-2);" class="card">
|
||||
<table class="min-w-full divide-y divide-gray-700">
|
||||
<thead class="bg-gray-900">
|
||||
<tr>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">E-Mail</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">Rolle</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">Aktiv</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">Erstellt</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="bg-gray-800 divide-y divide-gray-700">
|
||||
<?php foreach ($users as $u): ?>
|
||||
<tr>
|
||||
<td class="px-6 py-4 text-sm"><?= e($u['email']) ?></td>
|
||||
<td class="px-6 py-4 text-sm"><?= e($u['role']) ?></td>
|
||||
<td class="px-6 py-4 text-sm"><?= !empty($u['is_active']) ? 'Ja' : 'Nein' ?></td>
|
||||
<td class="px-6 py-4 text-sm"><?= e((string)$u['created_at']) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
$themes = [
|
||||
'light' => 'Light',
|
||||
'ocean' => 'Ocean',
|
||||
'graphite' => 'Graphite',
|
||||
];
|
||||
|
||||
require_auth();
|
||||
|
||||
$current = user_theme();
|
||||
$timezoneOptions = modules()->timezones();
|
||||
$nexusSettings = nexus_settings();
|
||||
$isAdmin = auth_is_admin();
|
||||
$notice = null;
|
||||
$publicDashboards = $isAdmin ? dashboards()->listPublicDashboards() : [];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$settingsSection = trim((string) ($_POST['settings_section'] ?? 'theme'));
|
||||
if ($settingsSection === 'nexus' && $isAdmin) {
|
||||
$displayTimezoneCustom = isset($_POST['display_timezone_custom']) ? '1' : '0';
|
||||
$displayTimezone = trim((string) ($_POST['display_timezone'] ?? ''));
|
||||
$cronTimezone = trim((string) ($_POST['cron_timezone'] ?? ''));
|
||||
$globalHomeDashboardId = (int) ($_POST['global_home_dashboard_id'] ?? 0);
|
||||
|
||||
foreach (['displayTimezone' => $displayTimezone, 'cronTimezone' => $cronTimezone] as $key => $value) {
|
||||
if ($value !== '') {
|
||||
try {
|
||||
new DateTimeZone($value);
|
||||
} catch (\Throwable) {
|
||||
$$key = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$nexusSettings['display_timezone_custom'] = $displayTimezoneCustom;
|
||||
$nexusSettings['display_timezone'] = $displayTimezoneCustom === '1' ? $displayTimezone : '';
|
||||
$nexusSettings['cron_timezone'] = $cronTimezone;
|
||||
$nexusSettings['global_home_dashboard_id'] = $globalHomeDashboardId > 0 ? (string) $globalHomeDashboardId : '';
|
||||
nexus_save_settings($nexusSettings);
|
||||
$nexusSettings = nexus_settings();
|
||||
$notice = 'Nexus-Einstellungen gespeichert.';
|
||||
} else {
|
||||
$theme = (string)($_POST['theme'] ?? 'light');
|
||||
if (!isset($themes[$theme])) {
|
||||
$theme = 'light';
|
||||
}
|
||||
set_user_theme($theme);
|
||||
$current = $theme;
|
||||
$notice = 'Theme gespeichert.';
|
||||
}
|
||||
}
|
||||
|
||||
$systemTimezone = nexus_system_timezone_name();
|
||||
$effectiveDisplayTimezone = nexus_display_timezone_name();
|
||||
$effectiveCronTimezone = nexus_cron_timezone_name();
|
||||
$displayTimezoneCustom = !empty($nexusSettings['display_timezone_custom']);
|
||||
$savedDisplayTimezone = trim((string) ($nexusSettings['display_timezone'] ?? ''));
|
||||
$savedCronTimezone = trim((string) ($nexusSettings['cron_timezone'] ?? ''));
|
||||
$globalHomeDashboardId = (int) ($nexusSettings['global_home_dashboard_id'] ?? 0);
|
||||
|
||||
$GLOBALS['layout_header_base_title'] = 'Nexus Setup';
|
||||
$GLOBALS['layout_header_title'] = 'Nexus Setup';
|
||||
$GLOBALS['layout_header_context'] = 'Allgemein';
|
||||
$GLOBALS['layout_header_text'] = 'Globale Grundeinstellungen, Home-Dashboard und systemweite Standardwerte.';
|
||||
?>
|
||||
<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="Nexus Setup Navigation">
|
||||
<a class="module-button module-button--tab-active" href="/settings">Allgemein</a>
|
||||
<?php if ($isAdmin): ?>
|
||||
<a class="module-button module-button--tab" href="/settings/widgets">Widgets</a>
|
||||
<a class="module-button module-button--tab" href="/integrations">Integrationen</a>
|
||||
<a class="module-button module-button--tab" href="/settings/search-engines">Suchmaschinen</a>
|
||||
<a class="module-button module-button--tab" href="/settings/apps">Apps</a>
|
||||
<a class="module-button module-button--tab" href="/dashboards">Dashboards</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>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="section-box">
|
||||
<h1>Nexus Einstellungen</h1>
|
||||
<p class="muted">Persönliche Anzeige, Home-Dashboard und systemweite Standardwerte.</p>
|
||||
|
||||
<?php if ($notice): ?>
|
||||
<div class="section-box" style="margin-top:1rem; border-color:var(--accent-2);">
|
||||
<?= e($notice) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="setup-form" style="margin-top:1rem;">
|
||||
<section class="section-box setup-panel">
|
||||
<div class="setup-panel__head">
|
||||
<div>
|
||||
<span class="pill">Benutzer</span>
|
||||
<h2>Persönliches Design</h2>
|
||||
</div>
|
||||
</div>
|
||||
<form method="post" class="setup-form">
|
||||
<input type="hidden" name="settings_section" value="theme">
|
||||
<div class="setup-grid">
|
||||
<label class="setup-field muted">
|
||||
<span>Farbpalette</span>
|
||||
<select name="theme">
|
||||
<?php foreach ($themes as $key => $label): ?>
|
||||
<option value="<?= e($key) ?>" <?= $current === $key ? 'selected' : '' ?>>
|
||||
<?= e($label) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div class="setup-actions setup-actions--footer">
|
||||
<button class="cta-button" type="submit">Design speichern</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<?php if ($isAdmin): ?>
|
||||
<section class="section-box setup-panel">
|
||||
<div class="setup-panel__head">
|
||||
<div>
|
||||
<span class="pill">Nexus</span>
|
||||
<h2>Standard-Zeitzonen</h2>
|
||||
<p class="muted">Diese Werte werden von Modulen als Default übernommen, sofern dort kein eigener Override gesetzt ist.</p>
|
||||
</div>
|
||||
</div>
|
||||
<form method="post" class="setup-form">
|
||||
<input type="hidden" name="settings_section" value="nexus">
|
||||
<datalist id="nexus-timezone-options">
|
||||
<?php foreach ($timezoneOptions as $timezoneOption): ?>
|
||||
<option value="<?= e((string) $timezoneOption['value']) ?>"><?= e((string) $timezoneOption['label']) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</datalist>
|
||||
<div class="setup-grid">
|
||||
<div class="setup-field muted">
|
||||
<span>System-Zeitzone</span>
|
||||
<div><?= e($systemTimezone) ?></div>
|
||||
<small class="muted">Diese Zeitzone wird genutzt, wenn keine globale Anzeige-Zeitzone gesetzt ist.</small>
|
||||
</div>
|
||||
<label class="setup-field muted">
|
||||
<span>Öffentliches Home-Dashboard</span>
|
||||
<select name="global_home_dashboard_id">
|
||||
<option value="0">Kein öffentliches Home-Dashboard</option>
|
||||
<?php foreach ($publicDashboards as $dashboard): ?>
|
||||
<option value="<?= (int) ($dashboard['id'] ?? 0) ?>" <?= (int) ($dashboard['id'] ?? 0) === $globalHomeDashboardId ? 'selected' : '' ?>>
|
||||
<?= e((string) ($dashboard['title'] ?? 'Dashboard')) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<small class="muted">Dieses öffentliche Dashboard wird am Root-Pfad angezeigt, wenn Nutzer nicht eingeloggt sind.</small>
|
||||
</label>
|
||||
<div class="setup-field muted">
|
||||
<span>Anzeige-Zeitzone</span>
|
||||
<label style="display:flex; align-items:center; gap:10px;">
|
||||
<input type="checkbox" name="display_timezone_custom" value="1" <?= $displayTimezoneCustom ? 'checked' : '' ?> data-global-display-tz-toggle>
|
||||
<span>Custom-Zeitzone verwenden</span>
|
||||
</label>
|
||||
<div class="setup-db-message setup-db-message--hint">Aktiv: <?= e($effectiveDisplayTimezone) ?></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="setup-grid" data-global-display-tz-panel <?= $displayTimezoneCustom ? '' : 'hidden' ?>>
|
||||
<label class="setup-field muted">
|
||||
<span>Custom Anzeige-Zeitzone</span>
|
||||
<input type="text" name="display_timezone" value="<?= e($savedDisplayTimezone !== '' ? $savedDisplayTimezone : $effectiveDisplayTimezone) ?>" list="nexus-timezone-options" autocomplete="off">
|
||||
</label>
|
||||
</div>
|
||||
<div class="setup-grid">
|
||||
<label class="setup-field muted">
|
||||
<span>Standard-Zeitzone für Crons</span>
|
||||
<input type="text" name="cron_timezone" value="<?= e($savedCronTimezone !== '' ? $savedCronTimezone : $effectiveCronTimezone) ?>" list="nexus-timezone-options" autocomplete="off">
|
||||
<small class="muted">Wird in Modul-Crons als Standard verwendet. Einzelne Module oder Einträge können das übersteuern.</small>
|
||||
</label>
|
||||
</div>
|
||||
<div class="setup-actions setup-actions--footer">
|
||||
<button class="cta-button" type="submit">Nexus-Einstellungen speichern</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
</div></div></div>
|
||||
<?php if ($isAdmin): ?>
|
||||
<script>
|
||||
(() => {
|
||||
const toggle = document.querySelector('[data-global-display-tz-toggle]');
|
||||
const panel = document.querySelector('[data-global-display-tz-panel]');
|
||||
if (!toggle || !panel) return;
|
||||
const sync = () => {
|
||||
panel.hidden = !toggle.checked;
|
||||
};
|
||||
toggle.addEventListener('change', sync);
|
||||
sync();
|
||||
})();
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
require_admin();
|
||||
|
||||
$service = dashboards();
|
||||
$ownerKey = 'system';
|
||||
$notice = null;
|
||||
$error = null;
|
||||
$integrations = $service->listIntegrationsForOwner($ownerKey);
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$action = trim((string) ($_POST['action'] ?? ''));
|
||||
try {
|
||||
if ($action === 'create_app') {
|
||||
$service->createApp($ownerKey, [
|
||||
'name' => trim((string) ($_POST['name'] ?? '')),
|
||||
'description' => trim((string) ($_POST['description'] ?? '')),
|
||||
'app_url' => trim((string) ($_POST['app_url'] ?? '')),
|
||||
'icon_url' => trim((string) ($_POST['icon_url'] ?? '')),
|
||||
'integration_id' => (int) ($_POST['integration_id'] ?? 0),
|
||||
'visibility' => 'public',
|
||||
]);
|
||||
$notice = 'App gespeichert.';
|
||||
} elseif ($action === 'delete_app') {
|
||||
$service->deleteApp((int) ($_POST['app_id'] ?? 0), $ownerKey);
|
||||
$notice = 'App gelöscht.';
|
||||
}
|
||||
} catch (\Throwable $exception) {
|
||||
$error = $exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
$apps = $service->listApps($ownerKey, true);
|
||||
|
||||
$GLOBALS['layout_header_base_title'] = 'Nexus Setup';
|
||||
$GLOBALS['layout_header_title'] = 'Nexus Setup';
|
||||
$GLOBALS['layout_header_context'] = 'Apps';
|
||||
$GLOBALS['layout_header_text'] = 'Globale Apps, die Nutzer später ihren Dashboards hinzufügen können.';
|
||||
?>
|
||||
<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="Nexus Setup Navigation">
|
||||
<a class="module-button module-button--tab" href="/settings">Allgemein</a>
|
||||
<a class="module-button module-button--tab" href="/settings/widgets">Widgets</a>
|
||||
<a class="module-button module-button--tab" href="/integrations">Integrationen</a>
|
||||
<a class="module-button module-button--tab" href="/settings/search-engines">Suchmaschinen</a>
|
||||
<a class="module-button module-button--tab-active" href="/settings/apps">Apps</a>
|
||||
<a class="module-button module-button--tab" href="/dashboards">Dashboards</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 App</h2>
|
||||
<form method="post" class="setup-form">
|
||||
<input type="hidden" name="action" value="create_app">
|
||||
<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>App-URL</span>
|
||||
<input type="url" name="app_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>Icon-URL optional</span>
|
||||
<input type="url" name="icon_url" placeholder="https://.../icon.png">
|
||||
</label>
|
||||
</div>
|
||||
<div class="setup-grid">
|
||||
<label class="setup-field muted">
|
||||
<span>Integration optional</span>
|
||||
<select name="integration_id">
|
||||
<option value="0">Keine Integration</option>
|
||||
<?php foreach ($integrations as $integration): ?>
|
||||
<option value="<?= (int) ($integration['id'] ?? 0) ?>"><?= e((string) ($integration['name'] ?? 'Integration')) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div class="setup-actions setup-actions--footer">
|
||||
<button class="cta-button" type="submit">App speichern</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<div class="module-admin-grid">
|
||||
<?php foreach ($apps as $appEntry): ?>
|
||||
<article class="card-box module-admin-card">
|
||||
<div class="module-admin-card__head">
|
||||
<div class="module-admin-card__title">
|
||||
<h2><?= e((string) ($appEntry['name'] ?? 'App')) ?></h2>
|
||||
<p><?= e((string) ($appEntry['description'] ?? ($appEntry['app_url'] ?? ''))) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="module-admin-actions">
|
||||
<a class="module-button module-button--secondary module-button--small" href="<?= e((string) ($appEntry['app_url'] ?? '#')) ?>" target="_blank" rel="noreferrer">Öffnen</a>
|
||||
<form method="post">
|
||||
<input type="hidden" name="action" value="delete_app">
|
||||
<input type="hidden" name="app_id" value="<?= (int) ($appEntry['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>
|
||||
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
require_admin();
|
||||
|
||||
$service = dashboards();
|
||||
$ownerKey = 'system';
|
||||
$notice = null;
|
||||
$error = null;
|
||||
$integrations = $service->listIntegrationsForOwner($ownerKey);
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$action = trim((string) ($_POST['action'] ?? ''));
|
||||
try {
|
||||
if ($action === 'create_search_engine') {
|
||||
$service->createSearchEngine($ownerKey, [
|
||||
'name' => trim((string) ($_POST['name'] ?? '')),
|
||||
'short_code' => trim((string) ($_POST['short_code'] ?? '')),
|
||||
'engine_type' => trim((string) ($_POST['engine_type'] ?? 'template')),
|
||||
'template_url' => trim((string) ($_POST['template_url'] ?? '')),
|
||||
'integration_id' => (int) ($_POST['integration_id'] ?? 0),
|
||||
'visibility' => 'public',
|
||||
'is_default' => isset($_POST['is_default']),
|
||||
]);
|
||||
$notice = 'Suchmaschine gespeichert.';
|
||||
} elseif ($action === 'delete_search_engine') {
|
||||
$service->deleteSearchEngine((int) ($_POST['engine_id'] ?? 0), $ownerKey);
|
||||
$notice = 'Suchmaschine gelöscht.';
|
||||
}
|
||||
} catch (\Throwable $exception) {
|
||||
$error = $exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
$engines = $service->listSearchEngines($ownerKey, true);
|
||||
|
||||
$GLOBALS['layout_header_base_title'] = 'Nexus Setup';
|
||||
$GLOBALS['layout_header_title'] = 'Nexus Setup';
|
||||
$GLOBALS['layout_header_context'] = 'Suchmaschinen';
|
||||
$GLOBALS['layout_header_text'] = 'Globale Suchmaschinen für die spätere Suche im Nexus-System.';
|
||||
?>
|
||||
<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="Nexus Setup Navigation">
|
||||
<a class="module-button module-button--tab" href="/settings">Allgemein</a>
|
||||
<a class="module-button module-button--tab" href="/settings/widgets">Widgets</a>
|
||||
<a class="module-button module-button--tab" href="/integrations">Integrationen</a>
|
||||
<a class="module-button module-button--tab-active" href="/settings/search-engines">Suchmaschinen</a>
|
||||
<a class="module-button module-button--tab" href="/settings/apps">Apps</a>
|
||||
<a class="module-button module-button--tab" href="/dashboards">Dashboards</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 Suchmaschine</h2>
|
||||
<form method="post" class="setup-form">
|
||||
<input type="hidden" name="action" value="create_search_engine">
|
||||
<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>Kurzcode</span>
|
||||
<input type="text" name="short_code" placeholder="g" required>
|
||||
</label>
|
||||
</div>
|
||||
<div class="setup-grid">
|
||||
<label class="setup-field muted">
|
||||
<span>Typ</span>
|
||||
<select name="engine_type">
|
||||
<option value="template">Such-Template</option>
|
||||
<option value="integration">Integration</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="setup-field muted">
|
||||
<span>Such-URL</span>
|
||||
<input type="url" name="template_url" placeholder="https://www.google.com/search?q=%s">
|
||||
</label>
|
||||
</div>
|
||||
<div class="setup-grid">
|
||||
<label class="setup-field muted">
|
||||
<span>Integration optional</span>
|
||||
<select name="integration_id">
|
||||
<option value="0">Keine Integration</option>
|
||||
<?php foreach ($integrations as $integration): ?>
|
||||
<option value="<?= (int) ($integration['id'] ?? 0) ?>"><?= e((string) ($integration['name'] ?? 'Integration')) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</label>
|
||||
<label class="setup-field muted">
|
||||
<input type="checkbox" name="is_default" value="1">
|
||||
<span>Als globale Standard-Suche setzen</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="setup-actions setup-actions--footer">
|
||||
<button class="cta-button" type="submit">Suchmaschine speichern</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<div class="module-admin-grid">
|
||||
<?php foreach ($engines as $engine): ?>
|
||||
<article class="card-box module-admin-card">
|
||||
<div class="module-admin-card__head">
|
||||
<div class="module-admin-card__title">
|
||||
<h2><?= e((string) ($engine['name'] ?? 'Suche')) ?></h2>
|
||||
<p><?= e((string) (($engine['template_url'] ?? '') ?: 'Integration-basierte Suche.')) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="module-admin-meta">
|
||||
<div class="module-admin-meta__item">
|
||||
<span class="module-admin-meta__label">Kurzcode</span>
|
||||
<strong class="module-admin-badge"><?= e((string) ($engine['short_code'] ?? '')) ?></strong>
|
||||
</div>
|
||||
<div class="module-admin-meta__item">
|
||||
<span class="module-admin-meta__label">Standard</span>
|
||||
<strong class="module-admin-badge<?= !empty($engine['is_default']) ? ' module-admin-badge--success' : '' ?>"><?= !empty($engine['is_default']) ? 'Ja' : 'Nein' ?></strong>
|
||||
</div>
|
||||
</div>
|
||||
<div class="module-admin-actions">
|
||||
<form method="post">
|
||||
<input type="hidden" name="action" value="delete_search_engine">
|
||||
<input type="hidden" name="engine_id" value="<?= (int) ($engine['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>
|
||||
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
require_admin();
|
||||
|
||||
$service = dashboards();
|
||||
$ownerKey = 'system';
|
||||
$notice = null;
|
||||
$error = null;
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$action = trim((string) ($_POST['action'] ?? ''));
|
||||
try {
|
||||
if ($action === 'create_widget') {
|
||||
$service->createWidgetTemplate($ownerKey, [
|
||||
'name' => trim((string) ($_POST['name'] ?? '')),
|
||||
'widget_type' => trim((string) ($_POST['widget_type'] ?? 'link')),
|
||||
'description' => trim((string) ($_POST['description'] ?? '')),
|
||||
'visibility' => 'public',
|
||||
'config' => [
|
||||
'url' => trim((string) ($_POST['target_url'] ?? '')),
|
||||
'bookmarks' => trim((string) ($_POST['bookmarks'] ?? '')),
|
||||
],
|
||||
]);
|
||||
$notice = 'Widget-Vorlage gespeichert.';
|
||||
} elseif ($action === 'delete_widget') {
|
||||
$service->deleteWidgetTemplate((int) ($_POST['widget_id'] ?? 0), $ownerKey);
|
||||
$notice = 'Widget-Vorlage gelöscht.';
|
||||
}
|
||||
} catch (\Throwable $exception) {
|
||||
$error = $exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
$widgets = $service->listWidgetTemplates($ownerKey, true);
|
||||
|
||||
$GLOBALS['layout_header_base_title'] = 'Nexus Setup';
|
||||
$GLOBALS['layout_header_title'] = 'Nexus Setup';
|
||||
$GLOBALS['layout_header_context'] = 'Widgets';
|
||||
$GLOBALS['layout_header_text'] = 'Globale Widget-Vorlagen, die andere Nutzer in ihre Dashboards übernehmen können.';
|
||||
?>
|
||||
<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="Nexus Setup Navigation">
|
||||
<a class="module-button module-button--tab" href="/settings">Allgemein</a>
|
||||
<a class="module-button module-button--tab-active" href="/settings/widgets">Widgets</a>
|
||||
<a class="module-button module-button--tab" href="/integrations">Integrationen</a>
|
||||
<a class="module-button module-button--tab" href="/settings/search-engines">Suchmaschinen</a>
|
||||
<a class="module-button module-button--tab" href="/settings/apps">Apps</a>
|
||||
<a class="module-button module-button--tab" href="/dashboards">Dashboards</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 Widget-Vorlage</h2>
|
||||
<form method="post" class="setup-form">
|
||||
<input type="hidden" name="action" value="create_widget">
|
||||
<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="widget_type">
|
||||
<option value="link">Link</option>
|
||||
<option value="iframe">iFrame</option>
|
||||
<option value="bookmark_group">Linkliste</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">
|
||||
<span>Ziel-URL</span>
|
||||
<input type="url" name="target_url" placeholder="https://...">
|
||||
</label>
|
||||
</div>
|
||||
<div class="setup-grid">
|
||||
<label class="setup-field muted">
|
||||
<span>Linkliste optional</span>
|
||||
<textarea name="bookmarks" rows="5" placeholder="Name | https://ziel.example Monitoring | https://grafana.example"></textarea>
|
||||
</label>
|
||||
</div>
|
||||
<div class="setup-actions setup-actions--footer">
|
||||
<button class="cta-button" type="submit">Widget speichern</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<div class="module-admin-grid">
|
||||
<?php foreach ($widgets as $widget): ?>
|
||||
<article class="card-box module-admin-card">
|
||||
<div class="module-admin-card__head">
|
||||
<div class="module-admin-card__title">
|
||||
<h2><?= e((string) ($widget['name'] ?? 'Widget')) ?></h2>
|
||||
<p><?= e((string) ($widget['description'] ?? 'Globale Widget-Vorlage.')) ?></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) ($widget['widget_type'] ?? 'link')) ?></strong>
|
||||
</div>
|
||||
</div>
|
||||
<div class="module-admin-actions">
|
||||
<form method="post">
|
||||
<input type="hidden" name="action" value="delete_widget">
|
||||
<input type="hidden" name="widget_id" value="<?= (int) ($widget['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