126 lines
5.1 KiB
PHP
126 lines
5.1 KiB
PHP
<?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>
|