asdasd
This commit is contained in:
@@ -4,377 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__, 3) . '/src/App/bootstrap.php';
|
||||
|
||||
use App\ConfigLoader;
|
||||
use App\CronManagementService;
|
||||
use App\KeycloakAuth;
|
||||
use ModulesCore\ModuleRegistry;
|
||||
use App\AppPaths;
|
||||
|
||||
if (session_status() !== PHP_SESSION_ACTIVE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
$projectRoot = dirname(__DIR__, 3);
|
||||
$auth = new KeycloakAuth(ConfigLoader::load($projectRoot, 'keycloak'));
|
||||
if (!$auth->isAuthenticated()) {
|
||||
header('Location: /auth/keycloak', true, 302);
|
||||
exit;
|
||||
}
|
||||
|
||||
$currentUser = is_array($_SESSION['desktop_auth']['user'] ?? null) ? $_SESSION['desktop_auth']['user'] : [];
|
||||
$currentGroups = array_map(
|
||||
static fn (string $group): string => strtolower(trim($group, '/')),
|
||||
array_values(array_map('strval', (array) ($currentUser['groups'] ?? [])))
|
||||
);
|
||||
$isPartial = !empty($_GET['partial']);
|
||||
|
||||
if (!in_array('administrators', $currentGroups, true)) {
|
||||
http_response_code(403);
|
||||
$forbidden = '<div class="window-app-shell cm-shell"><div class="window-app-frame cm-frame"><main class="window-app-main cm-main"><div class="window-app-panel cm-panel"><section class="window-app-card cm-card"><p class="cm-message is-error">Kein Zugriff auf Cron Tool.</p></section></div></main></div></div>';
|
||||
if ($isPartial) {
|
||||
echo $forbidden;
|
||||
return;
|
||||
}
|
||||
|
||||
?><!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Cron Tool</title>
|
||||
<link rel="stylesheet" href="/assets/desktop/desktop.css">
|
||||
<link rel="stylesheet" href="/assets/apps/cron-management/app.css">
|
||||
</head>
|
||||
<body><?= $forbidden ?></body>
|
||||
</html><?php
|
||||
return;
|
||||
}
|
||||
|
||||
$csrfToken = (string) ($_SESSION['cron_management_token'] ?? '');
|
||||
if ($csrfToken === '') {
|
||||
$csrfToken = bin2hex(random_bytes(16));
|
||||
$_SESSION['cron_management_token'] = $csrfToken;
|
||||
}
|
||||
|
||||
$baseUrlFallback = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http')
|
||||
. '://'
|
||||
. ($_SERVER['HTTP_HOST'] ?? 'localhost');
|
||||
|
||||
$service = new CronManagementService($projectRoot, new ModuleRegistry($projectRoot . '/modules'));
|
||||
$messages = [];
|
||||
$errors = [];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$postedToken = (string) ($_POST['csrf_token'] ?? '');
|
||||
|
||||
if ($postedToken === '' || !hash_equals($csrfToken, $postedToken)) {
|
||||
$errors[] = 'Die Formularpruefung ist fehlgeschlagen.';
|
||||
} else {
|
||||
$action = (string) ($_POST['action'] ?? '');
|
||||
|
||||
try {
|
||||
if ($action === 'save-global') {
|
||||
$service->saveGlobal([
|
||||
'base_url' => (string) ($_POST['base_url'] ?? ''),
|
||||
'default_timezone' => (string) ($_POST['default_timezone'] ?? ''),
|
||||
], $baseUrlFallback);
|
||||
$messages[] = 'Globale Cron-Einstellungen gespeichert.';
|
||||
} elseif ($action === 'regenerate-token') {
|
||||
$service->regenerateToken($baseUrlFallback);
|
||||
$messages[] = 'Cron-Token wurde neu erzeugt.';
|
||||
} elseif ($action === 'run-due') {
|
||||
$results = $service->runDue($baseUrlFallback);
|
||||
if ($results === []) {
|
||||
$messages[] = 'Aktuell war kein Cron-Job faellig.';
|
||||
} else {
|
||||
foreach ($results as $result) {
|
||||
$messages[] = sprintf(
|
||||
'%s: %s',
|
||||
(string) ($result['job_key'] ?? 'Cron-Job'),
|
||||
(string) ($result['message'] ?? '')
|
||||
);
|
||||
}
|
||||
}
|
||||
} elseif ($action === 'save-job') {
|
||||
$jobKey = (string) ($_POST['job_key'] ?? '');
|
||||
$service->saveJob($jobKey, [
|
||||
'enabled' => !empty($_POST['enabled']),
|
||||
'cron_expression' => (string) ($_POST['cron_expression'] ?? ''),
|
||||
'timezone' => (string) ($_POST['timezone'] ?? ''),
|
||||
], $baseUrlFallback);
|
||||
$messages[] = 'Cron-Job gespeichert: ' . $jobKey;
|
||||
} elseif ($action === 'toggle-job') {
|
||||
$jobKey = (string) ($_POST['job_key'] ?? '');
|
||||
$service->saveJob($jobKey, [
|
||||
'enabled' => !empty($_POST['enabled']),
|
||||
'cron_expression' => (string) ($_POST['cron_expression'] ?? ''),
|
||||
'timezone' => (string) ($_POST['timezone'] ?? ''),
|
||||
], $baseUrlFallback);
|
||||
$messages[] = 'Status aktualisiert: ' . $jobKey;
|
||||
} elseif ($action === 'run-now') {
|
||||
$jobKey = (string) ($_POST['job_key'] ?? '');
|
||||
$result = $service->runNow($jobKey, $baseUrlFallback);
|
||||
if (!empty($result['ok'])) {
|
||||
$messages[] = (string) ($result['message'] ?? 'Cron-Job ausgefuehrt.');
|
||||
} else {
|
||||
$errors[] = (string) ($result['message'] ?? 'Cron-Job fehlgeschlagen.');
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $exception) {
|
||||
$errors[] = $exception->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$bootstrap = $service->bootstrap($baseUrlFallback);
|
||||
$settings = is_array($bootstrap['settings'] ?? null) ? $bootstrap['settings'] : [];
|
||||
$jobs = is_array($bootstrap['jobs'] ?? null) ? $bootstrap['jobs'] : [];
|
||||
$h = static fn (?string $value): string => htmlspecialchars($value ?? '', ENT_QUOTES);
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<div id="cron-management-app" class="window-app-shell cm-shell">
|
||||
<div class="window-app-frame cm-frame">
|
||||
<aside class="window-app-sidebar cm-sidebar">
|
||||
<div class="window-app-brand cm-brand">
|
||||
<p class="window-app-kicker cm-kicker">Systemtool</p>
|
||||
<h1>Cron Tool</h1>
|
||||
<p class="window-app-copy cm-copy">Zentrale Verwaltung fuer modulweite Cron-Jobs, Zeitplaene und manuelle Testlaeufe.</p>
|
||||
</div>
|
||||
|
||||
<section class="window-app-card cm-card">
|
||||
<strong class="cm-side-title">Schnellstatus</strong>
|
||||
<div class="cm-side-metric">
|
||||
<span>Definierte Jobs</span>
|
||||
<strong><?= count($jobs) ?></strong>
|
||||
</div>
|
||||
<div class="cm-side-metric">
|
||||
<span>Faellige Jobs</span>
|
||||
<strong><?= count(array_filter($jobs, static fn (array $job): bool => !empty($job['is_due']))) ?></strong>
|
||||
</div>
|
||||
<div class="cm-side-metric">
|
||||
<span>Standard-Zeitzone</span>
|
||||
<strong><?= $h((string) ($settings['default_timezone'] ?? 'Europe/Berlin')) ?></strong>
|
||||
</div>
|
||||
</section>
|
||||
</aside>
|
||||
|
||||
<main class="window-app-main cm-main">
|
||||
<div class="window-app-panel cm-panel">
|
||||
<section class="window-app-hero cm-hero">
|
||||
<div>
|
||||
<p class="window-app-kicker cm-kicker">Cron Registry</p>
|
||||
<h2 class="window-app-title">Globale Scheduler-Verwaltung</h2>
|
||||
<p class="window-app-copy cm-copy">Module hinterlegen ihre Cron-Endpunkte in der Manifest-Datei. Dieses Systemtool sammelt sie automatisch und verwaltet Zeitplaene zentral.</p>
|
||||
</div>
|
||||
<div class="window-app-pill-row cm-pill-row">
|
||||
<span class="window-app-pill">Base URL: <?= $h((string) ($settings['base_url'] ?? '')) ?></span>
|
||||
<span class="window-app-pill">Token aktiv</span>
|
||||
<span class="window-app-pill">Admin only</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php if ($messages !== []): ?>
|
||||
<section class="window-app-card cm-card">
|
||||
<div class="cm-message is-success">
|
||||
<strong>Ergebnis</strong>
|
||||
<ul class="cm-list">
|
||||
<?php foreach ($messages as $message): ?>
|
||||
<li><?= $h($message) ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($errors !== []): ?>
|
||||
<section class="window-app-card cm-card">
|
||||
<div class="cm-message is-error">
|
||||
<strong>Bitte pruefen</strong>
|
||||
<ul class="cm-list">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<li><?= $h($error) ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<section class="window-app-card cm-card">
|
||||
<div class="cm-section-head">
|
||||
<div>
|
||||
<p class="window-app-kicker cm-kicker">Global</p>
|
||||
<h3 class="cm-section-title">Runner-Einstellungen</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form class="cm-form cm-form--global" method="post" action="/admin/cron/">
|
||||
<input type="hidden" name="csrf_token" value="<?= $h($csrfToken) ?>">
|
||||
<input type="hidden" name="action" value="save-global">
|
||||
<label class="cm-field">
|
||||
<span>Base URL fuer Cron-Aufrufe</span>
|
||||
<input type="text" name="base_url" value="<?= $h((string) ($settings['base_url'] ?? '')) ?>" placeholder="https://staging.desktop.kusche.berlin">
|
||||
</label>
|
||||
<label class="cm-field">
|
||||
<span>Standard-Zeitzone</span>
|
||||
<input type="text" name="default_timezone" value="<?= $h((string) ($settings['default_timezone'] ?? 'Europe/Berlin')) ?>" list="timezone-options">
|
||||
</label>
|
||||
<div class="cm-token-box">
|
||||
<strong>Cron-Token</strong>
|
||||
<code><?= $h((string) ($settings['cron_token'] ?? '')) ?></code>
|
||||
<p>Der Token wird fuer interne Cron-Aufrufe per `X-Desktop-Cron-Token` genutzt.</p>
|
||||
</div>
|
||||
<div class="cm-actions">
|
||||
<button class="window-app-nav-button cm-primary" type="submit">Globale Einstellungen speichern</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<form class="cm-inline-form" method="post" action="/admin/cron/">
|
||||
<input type="hidden" name="csrf_token" value="<?= $h($csrfToken) ?>">
|
||||
<input type="hidden" name="action" value="regenerate-token">
|
||||
<button class="window-app-nav-button cm-secondary" type="submit">Cron-Token neu erzeugen</button>
|
||||
</form>
|
||||
|
||||
<form class="cm-inline-form" method="post" action="/admin/cron/">
|
||||
<input type="hidden" name="csrf_token" value="<?= $h($csrfToken) ?>">
|
||||
<input type="hidden" name="action" value="run-due">
|
||||
<button class="window-app-nav-button cm-secondary" type="submit">Faellige Jobs jetzt ausfuehren</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section class="window-app-card cm-card">
|
||||
<div class="cm-section-head">
|
||||
<div>
|
||||
<p class="window-app-kicker cm-kicker">Jobs</p>
|
||||
<h3 class="cm-section-title">Erkannte Modul-Crons</h3>
|
||||
<p class="cm-copy">Neue Cronjob-Typen entstehen ueber Modul-Metadaten. Ein einzelner Job kann hier angelegt, aktiviert und spaeter bearbeitet werden.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cm-job-list">
|
||||
<?php foreach ($jobs as $job): ?>
|
||||
<article class="window-app-card cm-job-card">
|
||||
<div class="cm-job-head">
|
||||
<div>
|
||||
<strong><?= $h((string) ($job['label'] ?? $job['job_key'] ?? 'Cron-Job')) ?></strong>
|
||||
<p><?= $h((string) ($job['description'] ?? '')) ?></p>
|
||||
</div>
|
||||
<div class="cm-job-meta">
|
||||
<span class="window-app-pill"><?= $h((string) ($job['module_id'] ?? 'module')) ?></span>
|
||||
<span class="window-app-pill"><?= $h((string) ($job['method'] ?? 'POST')) ?></span>
|
||||
<?php if (empty($job['configured'])): ?>
|
||||
<span class="window-app-pill">nicht angelegt</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cm-job-summary">
|
||||
<div class="cm-job-summary-item">
|
||||
<span>Status</span>
|
||||
<strong><?= $h((string) (($job['state']['last_status'] ?? '') ?: ($job['enabled'] ? 'aktiv' : 'inaktiv'))) ?></strong>
|
||||
</div>
|
||||
<div class="cm-job-summary-item">
|
||||
<span>Zeitplan</span>
|
||||
<strong><?= $h((string) ($job['cron_human'] ?? 'n/a')) ?></strong>
|
||||
</div>
|
||||
<div class="cm-job-summary-item">
|
||||
<span>Naechster Lauf</span>
|
||||
<strong><?= $h((string) (($job['next_due_at_local'] ?? '') ?: 'n/a')) ?></strong>
|
||||
</div>
|
||||
<div class="cm-job-summary-item">
|
||||
<span>Letzter Erfolg</span>
|
||||
<strong><?= $h((string) (($job['state_local']['last_success_at'] ?? '') ?: 'n/a')) ?></strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cm-job-inline-meta">
|
||||
<span><strong>Cron</strong> <?= $h((string) ($job['cron_expression'] ?? '')) ?></span>
|
||||
<span><strong>Zeitzone</strong> <?= $h((string) ($job['timezone'] ?? ($settings['default_timezone'] ?? 'Europe/Berlin'))) ?></span>
|
||||
<span><strong>Endpoint</strong> <?= $h((string) ($job['endpoint_path'] ?? '')) ?></span>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($job['parse_error'])): ?>
|
||||
<p class="cm-parse-error">Cron-Fehler: <?= $h((string) $job['parse_error']) ?></p>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($job['state']['last_message'])): ?>
|
||||
<p class="cm-job-message"><?= $h((string) $job['state']['last_message']) ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="cm-job-toolbar">
|
||||
<form class="cm-inline-form" method="post" action="/admin/cron/">
|
||||
<input type="hidden" name="csrf_token" value="<?= $h($csrfToken) ?>">
|
||||
<input type="hidden" name="action" value="toggle-job">
|
||||
<input type="hidden" name="job_key" value="<?= $h((string) ($job['job_key'] ?? '')) ?>">
|
||||
<input type="hidden" name="enabled" value="<?= empty($job['enabled']) ? '1' : '0' ?>">
|
||||
<input type="hidden" name="cron_expression" value="<?= $h((string) ($job['cron_expression'] ?? '0 * * * *')) ?>">
|
||||
<input type="hidden" name="timezone" value="<?= $h((string) ($job['timezone'] ?? ($settings['default_timezone'] ?? 'Europe/Berlin'))) ?>">
|
||||
<button class="window-app-nav-button cm-secondary" type="submit"><?= !empty($job['enabled']) ? 'Deaktivieren' : 'Aktivieren' ?></button>
|
||||
</form>
|
||||
|
||||
<form class="cm-inline-form" method="post" action="/admin/cron/">
|
||||
<input type="hidden" name="csrf_token" value="<?= $h($csrfToken) ?>">
|
||||
<input type="hidden" name="action" value="run-now">
|
||||
<input type="hidden" name="job_key" value="<?= $h((string) ($job['job_key'] ?? '')) ?>">
|
||||
<button class="window-app-nav-button cm-secondary" type="submit">Jetzt ausfuehren</button>
|
||||
</form>
|
||||
|
||||
<button class="window-app-nav-button cm-secondary" type="button" data-cm-edit-toggle="job-<?= $h((string) ($job['job_key'] ?? '')) ?>"><?= empty($job['configured']) ? 'Cronjob anlegen' : 'Bearbeiten' ?></button>
|
||||
</div>
|
||||
|
||||
<form class="cm-form cm-form--job" method="post" action="/admin/cron/" data-cm-edit-target="job-<?= $h((string) ($job['job_key'] ?? '')) ?>" hidden>
|
||||
<input type="hidden" name="csrf_token" value="<?= $h($csrfToken) ?>">
|
||||
<input type="hidden" name="action" value="save-job">
|
||||
<input type="hidden" name="job_key" value="<?= $h((string) ($job['job_key'] ?? '')) ?>">
|
||||
<input type="hidden" name="enabled" value="<?= !empty($job['enabled']) ? '1' : '0' ?>">
|
||||
<label class="cm-field">
|
||||
<span>Cron-Ausdruck</span>
|
||||
<input type="text" name="cron_expression" value="<?= $h((string) ($job['cron_expression'] ?? '0 * * * *')) ?>">
|
||||
</label>
|
||||
<label class="cm-field">
|
||||
<span>Zeitzone</span>
|
||||
<input type="text" name="timezone" value="<?= $h((string) ($job['timezone'] ?? ($settings['default_timezone'] ?? 'Europe/Berlin'))) ?>" list="timezone-options">
|
||||
</label>
|
||||
<div class="cm-actions">
|
||||
<button class="window-app-nav-button cm-primary" type="submit">Zeitplan speichern</button>
|
||||
<button class="window-app-nav-button cm-secondary" type="button" data-cm-edit-close="job-<?= $h((string) ($job['job_key'] ?? '')) ?>">Abbrechen</button>
|
||||
</div>
|
||||
</form>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($jobs === []): ?>
|
||||
<div class="cm-empty">Aktuell wurden noch keine Cron-Jobs aus Modulen registriert.</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
<datalist id="timezone-options">
|
||||
<?php foreach (DateTimeZone::listIdentifiers() as $timezone): ?>
|
||||
<option value="<?= $h($timezone) ?>"></option>
|
||||
<?php endforeach; ?>
|
||||
</datalist>
|
||||
<?php
|
||||
$pageContent = (string) ob_get_clean();
|
||||
|
||||
if ($isPartial) {
|
||||
echo $pageContent;
|
||||
return;
|
||||
}
|
||||
?><!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Cron Tool</title>
|
||||
<link rel="stylesheet" href="/assets/desktop/desktop.css">
|
||||
<link rel="stylesheet" href="/assets/apps/cron-management/app.css">
|
||||
</head>
|
||||
<body>
|
||||
<?= $pageContent ?>
|
||||
<script src="/assets/apps/cron-management/app.js"></script>
|
||||
<script>
|
||||
window.initCronManagementApp?.(document.getElementById('cron-management-app'), { standalone: true });
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
require AppPaths::systemAppPath(dirname(__DIR__, 3), 'cron-management') . '/page.php';
|
||||
|
||||
@@ -4,441 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__, 3) . '/src/App/bootstrap.php';
|
||||
|
||||
use App\AccountGate;
|
||||
use App\ConfigLoader;
|
||||
use App\RegistrationService;
|
||||
use ModulesCore\ModuleHttp;
|
||||
use App\AppPaths;
|
||||
|
||||
if (session_status() !== PHP_SESSION_ACTIVE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
$projectRoot = dirname(__DIR__, 3);
|
||||
ModuleHttp::requireDesktopAccess($projectRoot);
|
||||
|
||||
$accountGate = new AccountGate(ConfigLoader::load($projectRoot, 'registration'));
|
||||
$registration = new RegistrationService($projectRoot, ConfigLoader::load($projectRoot, 'registration'));
|
||||
|
||||
$currentUser = is_array($_SESSION['desktop_auth']['user'] ?? null) ? $_SESSION['desktop_auth']['user'] : [];
|
||||
$currentGroups = array_map(
|
||||
static fn (string $group): string => strtolower(trim($group, '/')),
|
||||
array_values(array_map('strval', (array) ($currentUser['groups'] ?? [])))
|
||||
);
|
||||
$isPartial = !empty($_GET['partial']);
|
||||
|
||||
if (!in_array('administrators', $currentGroups, true)) {
|
||||
http_response_code(403);
|
||||
$forbidden = '<div class="window-app-shell um-shell"><div class="window-app-frame um-frame"><main class="window-app-main um-main"><div class="window-app-panel um-panel"><section class="window-app-card um-card"><p class="um-message is-error">Kein Zugriff auf User Management.</p></section></div></main></div></div>';
|
||||
if ($isPartial) {
|
||||
echo $forbidden;
|
||||
return;
|
||||
}
|
||||
|
||||
?><!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>User Management</title>
|
||||
<link rel="stylesheet" href="/assets/desktop/desktop.css">
|
||||
<link rel="stylesheet" href="/assets/apps/user-management/app.css">
|
||||
</head>
|
||||
<body><?= $forbidden ?></body>
|
||||
</html><?php
|
||||
return;
|
||||
}
|
||||
|
||||
$csrfToken = (string) ($_SESSION['user_management_token'] ?? '');
|
||||
if ($csrfToken === '') {
|
||||
$csrfToken = bin2hex(random_bytes(16));
|
||||
$_SESSION['user_management_token'] = $csrfToken;
|
||||
}
|
||||
|
||||
$section = trim((string) ($_GET['section'] ?? $_POST['active_section'] ?? 'pending'));
|
||||
$allowedSections = ['pending', 'users', 'reset'];
|
||||
if (!in_array($section, $allowedSections, true)) {
|
||||
$section = 'pending';
|
||||
}
|
||||
|
||||
$messages = [];
|
||||
$errors = [];
|
||||
$selectedId = trim((string) ($_GET['id'] ?? $_POST['selected_id'] ?? ''));
|
||||
$manualUsername = trim((string) ($_POST['manual_username'] ?? ''));
|
||||
$manualResetUsername = trim((string) ($_POST['reset_username'] ?? ''));
|
||||
$manualResetPassword = (string) ($_POST['reset_password'] ?? '');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$postedToken = (string) ($_POST['csrf_token'] ?? '');
|
||||
|
||||
if ($postedToken === '' || !hash_equals($csrfToken, $postedToken)) {
|
||||
$errors[] = 'Die Formularpruefung ist fehlgeschlagen.';
|
||||
} else {
|
||||
$action = (string) ($_POST['action'] ?? '');
|
||||
|
||||
if ($action === 'approve-registration') {
|
||||
$groupDns = array_values(array_filter(array_map('strval', (array) ($_POST['group_dns'] ?? []))));
|
||||
$memberOfList = implode(PHP_EOL, $groupDns);
|
||||
$result = $registration->approve($selectedId, [
|
||||
'member_of_list' => $memberOfList,
|
||||
'admin_note' => (string) ($_POST['admin_note'] ?? ''),
|
||||
], (string) ($currentUser['username'] ?? 'administrator'));
|
||||
|
||||
if (($result['success'] ?? false) !== true) {
|
||||
$errors = array_merge($errors, array_values(array_map('strval', (array) ($result['errors'] ?? []))));
|
||||
} else {
|
||||
$messages[] = 'Registrierung wurde freigeschaltet.';
|
||||
}
|
||||
$section = 'pending';
|
||||
} elseif ($action === 'deactivate-user') {
|
||||
$result = $registration->deactivateUser($manualUsername);
|
||||
if (($result['success'] ?? false) === true) {
|
||||
$messages[] = (string) ($result['message'] ?? '');
|
||||
} else {
|
||||
$errors[] = (string) ($result['message'] ?? '');
|
||||
}
|
||||
$section = 'users';
|
||||
} elseif ($action === 'activate-user') {
|
||||
$groupDns = array_values(array_filter(array_map('strval', (array) ($_POST['manual_group_dns'] ?? []))));
|
||||
$result = $registration->activateExistingUser($manualUsername, $groupDns);
|
||||
if (($result['success'] ?? false) === true) {
|
||||
$messages[] = (string) ($result['message'] ?? '');
|
||||
} else {
|
||||
$errors[] = (string) ($result['message'] ?? '');
|
||||
}
|
||||
$section = 'users';
|
||||
} elseif ($action === 'send-reset-mail') {
|
||||
$origin = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http') . '://' . ($_SERVER['HTTP_HOST'] ?? 'localhost');
|
||||
$result = $registration->sendPasswordReset($manualResetUsername, $origin);
|
||||
if (($result['success'] ?? false) === true) {
|
||||
$messages[] = (string) ($result['message'] ?? '');
|
||||
} else {
|
||||
$errors[] = (string) ($result['message'] ?? '');
|
||||
}
|
||||
$section = 'reset';
|
||||
} elseif ($action === 'set-password') {
|
||||
if (strlen($manualResetPassword) < 12) {
|
||||
$errors[] = 'Das neue Passwort muss mindestens 12 Zeichen lang sein.';
|
||||
} else {
|
||||
$result = $registration->setUserPassword($manualResetUsername, $manualResetPassword);
|
||||
if (($result['success'] ?? false) === true) {
|
||||
$messages[] = (string) ($result['message'] ?? '');
|
||||
} else {
|
||||
$errors[] = (string) ($result['message'] ?? '');
|
||||
}
|
||||
}
|
||||
$section = 'reset';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$pendingRequests = $registration->pendingApprovals();
|
||||
$availableGroups = $registration->availableGroups();
|
||||
$existingUsers = $registration->searchExistingUsers('', 250);
|
||||
$selectedExistingUser = null;
|
||||
if ($manualUsername !== '') {
|
||||
foreach ($existingUsers as $existingUser) {
|
||||
if (strtolower((string) ($existingUser['username'] ?? '')) === strtolower($manualUsername)) {
|
||||
$selectedExistingUser = $existingUser;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$selected = $selectedId !== ''
|
||||
? $registration->find($selectedId)
|
||||
: ($pendingRequests[0] ?? null);
|
||||
|
||||
if ($selectedId === '' && is_array($selected) && isset($selected['id'])) {
|
||||
$selectedId = (string) $selected['id'];
|
||||
}
|
||||
|
||||
$h = static fn (?string $value): string => htmlspecialchars($value ?? '', ENT_QUOTES);
|
||||
$sectionUrl = static function (string $targetSection, string $requestId = ''): string {
|
||||
$query = ['section' => $targetSection];
|
||||
if ($requestId !== '') {
|
||||
$query['id'] = $requestId;
|
||||
}
|
||||
|
||||
return '/admin/users/?' . http_build_query($query, '', '&', PHP_QUERY_RFC3986);
|
||||
};
|
||||
|
||||
$sectionMeta = [
|
||||
'pending' => [
|
||||
'label' => 'Freischaltungen',
|
||||
'title' => 'Offene Registrierungen',
|
||||
'description' => 'Neue Registrierungen pruefen, Gruppen zuweisen und Freischaltungen sauber dokumentieren.',
|
||||
'nav' => 'Anfragen sichten und direkt freigeben.',
|
||||
],
|
||||
'users' => [
|
||||
'label' => 'Benutzerstatus',
|
||||
'title' => 'Bestehende Benutzer',
|
||||
'description' => 'LDAP-Benutzer aktivieren, deaktivieren und Gruppen fuer die Desktop-Nutzung zuweisen.',
|
||||
'nav' => 'Aktivierung und Sperrung vorhandener Konten.',
|
||||
],
|
||||
'reset' => [
|
||||
'label' => 'Passwort-Reset',
|
||||
'title' => 'Passwortverwaltung',
|
||||
'description' => 'Reset-Mails ausloesen oder ein Passwort direkt als Administrator setzen.',
|
||||
'nav' => 'Ruecksetzen oder direkt neu vergeben.',
|
||||
],
|
||||
];
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<div id="user-management-app" class="window-app-shell um-shell">
|
||||
<div class="window-app-frame um-frame">
|
||||
<aside class="window-app-sidebar um-sidebar">
|
||||
<div class="window-app-brand um-brand">
|
||||
<p class="window-app-kicker um-kicker">Administration</p>
|
||||
<h1>User Management</h1>
|
||||
<p class="window-app-copy um-copy">Freischaltungen, Benutzerstatus und Passwort-Reset im gemeinsamen Desktop-Standard.</p>
|
||||
</div>
|
||||
|
||||
<div class="window-app-nav-list um-nav-list">
|
||||
<?php foreach ($sectionMeta as $sectionId => $meta): ?>
|
||||
<a class="window-app-nav-button um-nav-button<?= $section === $sectionId ? ' is-active' : '' ?>" href="<?= $h($sectionUrl($sectionId, $sectionId === 'pending' ? $selectedId : '')) ?>">
|
||||
<strong><?= $h($meta['label']) ?></strong>
|
||||
<span class="window-app-meta um-meta"><?= $h($meta['nav']) ?></span>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<section class="window-app-card um-side-card">
|
||||
<strong class="um-side-title">Schnellstatus</strong>
|
||||
<div class="um-side-metric">
|
||||
<span>Offene Anfragen</span>
|
||||
<strong><?= count($pendingRequests) ?></strong>
|
||||
</div>
|
||||
<div class="um-side-metric">
|
||||
<span>Admin</span>
|
||||
<strong><?= $h((string) ($currentUser['username'] ?? 'administrator')) ?></strong>
|
||||
</div>
|
||||
</section>
|
||||
</aside>
|
||||
|
||||
<main class="window-app-main um-main">
|
||||
<div class="window-app-panel um-panel">
|
||||
<section class="window-app-hero um-hero">
|
||||
<div>
|
||||
<p class="window-app-kicker um-kicker">User Management</p>
|
||||
<h2 class="window-app-title"><?= $h($sectionMeta[$section]['title']) ?></h2>
|
||||
<p class="window-app-copy um-copy"><?= $h($sectionMeta[$section]['description']) ?></p>
|
||||
</div>
|
||||
<div class="window-app-pill-row um-pill-row">
|
||||
<span class="window-app-pill">Administrators only</span>
|
||||
<span class="window-app-pill">Desktop Auth</span>
|
||||
<span class="window-app-pill">Section: <?= $h($sectionMeta[$section]['label']) ?></span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php if ($messages !== []): ?>
|
||||
<section class="window-app-card um-card">
|
||||
<div class="um-message is-success">
|
||||
<strong>Ergebnis</strong>
|
||||
<ul class="um-list">
|
||||
<?php foreach ($messages as $message): ?>
|
||||
<li><?= $h($message) ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($errors !== []): ?>
|
||||
<section class="window-app-card um-card">
|
||||
<div class="um-message is-error">
|
||||
<strong>Bitte pruefen</strong>
|
||||
<ul class="um-list">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<li><?= $h($error) ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<script id="um-existing-users-data" type="application/json"><?= json_encode($existingUsers, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?></script>
|
||||
|
||||
<?php if ($section === 'pending'): ?>
|
||||
<div class="window-app-grid um-grid um-grid--split">
|
||||
<section class="window-app-card um-card">
|
||||
<div class="um-section-head">
|
||||
<div>
|
||||
<p class="window-app-kicker um-kicker">Queue</p>
|
||||
<h3 class="um-section-title">Wartende Registrierungen</h3>
|
||||
</div>
|
||||
<span class="window-app-meta um-meta"><?= count($pendingRequests) ?> offen</span>
|
||||
</div>
|
||||
|
||||
<div class="um-request-list">
|
||||
<?php if ($pendingRequests === []): ?>
|
||||
<div class="um-empty">Aktuell gibt es keine offenen Registrierungen.</div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($pendingRequests as $request): ?>
|
||||
<a class="um-request-card<?= (($selected['id'] ?? '') === ($request['id'] ?? '')) ? ' is-active' : '' ?>" href="<?= $h($sectionUrl('pending', (string) ($request['id'] ?? ''))) ?>">
|
||||
<strong><?= $h((string) ($request['username'] ?? '')) ?></strong>
|
||||
<span><?= $h((string) ($request['email'] ?? '')) ?></span>
|
||||
<span class="um-request-status"><?= $h((string) ($request['status'] ?? 'pending')) ?></span>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="window-app-card um-card">
|
||||
<div class="um-section-head">
|
||||
<div>
|
||||
<p class="window-app-kicker um-kicker">Approval</p>
|
||||
<h3 class="um-section-title">Freischaltung</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (is_array($selected)): ?>
|
||||
<div class="um-summary-grid">
|
||||
<div class="um-summary-item"><span>Benutzer</span><strong><?= $h((string) ($selected['username'] ?? '')) ?></strong></div>
|
||||
<div class="um-summary-item"><span>E-Mail</span><strong><?= $h((string) ($selected['email'] ?? '')) ?></strong></div>
|
||||
<div class="um-summary-item"><span>Status</span><strong><?= $h((string) ($selected['status'] ?? '')) ?></strong></div>
|
||||
</div>
|
||||
|
||||
<form class="um-form" method="post" action="/admin/users/">
|
||||
<input type="hidden" name="csrf_token" value="<?= $h($csrfToken) ?>">
|
||||
<input type="hidden" name="selected_id" value="<?= $h((string) ($selected['id'] ?? '')) ?>">
|
||||
<input type="hidden" name="action" value="approve-registration">
|
||||
<input type="hidden" name="active_section" value="pending">
|
||||
|
||||
<fieldset class="um-fieldset">
|
||||
<legend>Gruppen fuer Freischaltung</legend>
|
||||
<div class="um-checkbox-grid">
|
||||
<?php foreach ($availableGroups as $group): ?>
|
||||
<label class="window-app-item um-checkbox-item">
|
||||
<input type="checkbox" name="group_dns[]" value="<?= $h((string) ($group['dn'] ?? '')) ?>">
|
||||
<span class="window-app-item-main">
|
||||
<strong><?= $h((string) ($group['label'] ?? '')) ?></strong>
|
||||
<p><?= $h((string) ($group['dn'] ?? '')) ?></p>
|
||||
</span>
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<label class="um-field">
|
||||
<span>Admin-Notiz</span>
|
||||
<textarea name="admin_note" rows="4"></textarea>
|
||||
</label>
|
||||
|
||||
<div class="um-actions">
|
||||
<button class="window-app-nav-button um-primary" type="submit">Freischaltung bestaetigen</button>
|
||||
</div>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<div class="um-empty">Keine Anfrage ausgewaehlt.</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
</div>
|
||||
<?php elseif ($section === 'users'): ?>
|
||||
<section class="window-app-card um-card">
|
||||
<div class="um-section-head">
|
||||
<div>
|
||||
<p class="window-app-kicker um-kicker">Existing User</p>
|
||||
<h3 class="um-section-title">Bestehenden Benutzer verwalten</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form class="um-form" method="post" action="/admin/users/">
|
||||
<input type="hidden" name="csrf_token" value="<?= $h($csrfToken) ?>">
|
||||
<input type="hidden" name="active_section" value="users">
|
||||
|
||||
<label class="um-field">
|
||||
<span>Benutzername</span>
|
||||
<div class="um-user-picker" data-user-picker>
|
||||
<input type="text" name="manual_username" value="<?= $h($manualUsername) ?>" required autocomplete="off" data-user-picker-input>
|
||||
<div class="um-user-picker-list" data-user-picker-list hidden></div>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<fieldset class="um-fieldset">
|
||||
<legend>Gruppen fuer Aktivierung</legend>
|
||||
<div class="um-checkbox-grid">
|
||||
<?php foreach ($availableGroups as $group): ?>
|
||||
<?php
|
||||
$groupDn = (string) ($group['dn'] ?? '');
|
||||
$selectedGroupDns = array_values(array_map('strval', (array) ($selectedExistingUser['group_dns'] ?? [])));
|
||||
$isChecked = in_array($groupDn, $selectedGroupDns, true);
|
||||
?>
|
||||
<label class="window-app-item um-checkbox-item">
|
||||
<input type="checkbox" name="manual_group_dns[]" value="<?= $h($groupDn) ?>" <?= $isChecked ? 'checked' : '' ?>>
|
||||
<span class="window-app-item-main">
|
||||
<strong><?= $h((string) ($group['label'] ?? '')) ?></strong>
|
||||
<p><?= $h($groupDn) ?></p>
|
||||
</span>
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div class="um-actions">
|
||||
<button class="window-app-nav-button um-primary" type="submit" name="action" value="activate-user">Benutzer aktivieren</button>
|
||||
<button class="window-app-nav-button um-danger" type="submit" name="action" value="deactivate-user">Benutzer deaktivieren</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
<?php else: ?>
|
||||
<section class="window-app-card um-card">
|
||||
<div class="um-section-head">
|
||||
<div>
|
||||
<p class="window-app-kicker um-kicker">Reset</p>
|
||||
<h3 class="um-section-title">Passwort zuruecksetzen</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form class="um-form" method="post" action="/admin/users/">
|
||||
<input type="hidden" name="csrf_token" value="<?= $h($csrfToken) ?>">
|
||||
<input type="hidden" name="active_section" value="reset">
|
||||
|
||||
<label class="um-field">
|
||||
<span>Benutzername</span>
|
||||
<div class="um-user-picker" data-user-picker>
|
||||
<input type="text" name="reset_username" value="<?= $h($manualResetUsername) ?>" required autocomplete="off" data-user-picker-input>
|
||||
<div class="um-user-picker-list" data-user-picker-list hidden></div>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<label class="um-field">
|
||||
<span>Neues Passwort fuer direkten Reset</span>
|
||||
<input type="password" name="reset_password" value="" placeholder="Optional fuer direkten Admin-Reset">
|
||||
</label>
|
||||
|
||||
<div class="um-actions">
|
||||
<button class="window-app-nav-button um-secondary" type="submit" name="action" value="send-reset-mail">Reset-Mail senden</button>
|
||||
<button class="window-app-nav-button um-primary" type="submit" name="action" value="set-password">Passwort direkt setzen</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$pageContent = (string) ob_get_clean();
|
||||
|
||||
if ($isPartial) {
|
||||
echo $pageContent;
|
||||
return;
|
||||
}
|
||||
?><!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>User Management</title>
|
||||
<link rel="stylesheet" href="/assets/desktop/desktop.css">
|
||||
<link rel="stylesheet" href="/assets/apps/user-management/app.css">
|
||||
</head>
|
||||
<body>
|
||||
<?= $pageContent ?>
|
||||
<script src="/assets/apps/user-management/app.js"></script>
|
||||
<script>
|
||||
window.initUserManagementApp?.(document.getElementById('user-management-app'), { standalone: true });
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
require AppPaths::systemAppPath(dirname(__DIR__, 3), 'user-management') . '/page.php';
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__, 3) . '/src/App/bootstrap.php';
|
||||
|
||||
use App\AppPaths;
|
||||
use App\CronAuth;
|
||||
use ModulesCore\ModuleHttp;
|
||||
|
||||
@@ -32,4 +33,4 @@ if (!(in_array($normalizedPath, $cronPaths, true) && CronAuth::isAuthorizedReque
|
||||
ModuleHttp::requireDesktopAccess($projectRoot, true);
|
||||
}
|
||||
|
||||
require dirname(__DIR__, 3) . '/modules/boersenchecker/api/index.php';
|
||||
require AppPaths::customAppPath(dirname(__DIR__, 3), 'boersenchecker') . '/api/index.php';
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__, 3) . '/src/App/bootstrap.php';
|
||||
|
||||
use App\AppPaths;
|
||||
use App\CronAuth;
|
||||
use ModulesCore\ModuleHttp;
|
||||
|
||||
@@ -31,4 +32,4 @@ if (!(in_array($normalizedPath, $cronPaths, true) && CronAuth::isAuthorizedReque
|
||||
ModuleHttp::requireDesktopAccess($projectRoot, true);
|
||||
}
|
||||
|
||||
require $projectRoot . '/modules/fx-rates/api/index.php';
|
||||
require AppPaths::customAppPath($projectRoot, 'fx-rates') . '/api/index.php';
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__, 3) . '/src/App/bootstrap.php';
|
||||
|
||||
use App\AppPaths;
|
||||
use ModulesCore\ModuleHttp;
|
||||
|
||||
session_start();
|
||||
@@ -11,4 +12,4 @@ session_start();
|
||||
$projectRoot = dirname(__DIR__, 3);
|
||||
ModuleHttp::requireDesktopAccess($projectRoot, true);
|
||||
|
||||
require $projectRoot . '/modules/mining-checker/api/index.php';
|
||||
require AppPaths::customAppPath($projectRoot, 'mining-checker') . '/api/index.php';
|
||||
|
||||
@@ -3,7 +3,10 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__, 5) . '/src/App/bootstrap.php';
|
||||
require_once dirname(__DIR__, 5) . '/modules/mining-checker/bootstrap.php';
|
||||
|
||||
use App\AppPaths;
|
||||
|
||||
require_once AppPaths::customAppPath(dirname(__DIR__, 5), 'mining-checker') . '/bootstrap.php';
|
||||
|
||||
use Modules\MiningChecker\Legacy\LegacyModuleStore;
|
||||
use Modules\MiningChecker\Legacy\UserScope;
|
||||
|
||||
@@ -2,4 +2,8 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require dirname(__DIR__, 3) . '/modules/pihole/api/index.php';
|
||||
require_once dirname(__DIR__, 3) . '/src/App/bootstrap.php';
|
||||
|
||||
use App\AppPaths;
|
||||
|
||||
require AppPaths::customAppPath(dirname(__DIR__, 3), 'pihole') . '/api/index.php';
|
||||
|
||||
@@ -4,107 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__, 3) . '/src/App/bootstrap.php';
|
||||
|
||||
use App\ConfigLoader;
|
||||
use App\KeycloakAuth;
|
||||
use App\LdapProvisioner;
|
||||
use App\UserSelfManagementService;
|
||||
use Desktop\AppRegistry;
|
||||
use Desktop\AppVisibility;
|
||||
use Desktop\SkinResolver;
|
||||
use Desktop\WidgetRegistry;
|
||||
use ModulesCore\ModuleRegistry;
|
||||
use App\AppPaths;
|
||||
|
||||
session_start();
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
$projectRoot = dirname(__DIR__, 3);
|
||||
$method = strtoupper($_SERVER['REQUEST_METHOD'] ?? 'GET');
|
||||
|
||||
if ($method === 'OPTIONS') {
|
||||
header('Allow: GET, PUT, OPTIONS');
|
||||
exit;
|
||||
}
|
||||
|
||||
$keycloakConfig = ConfigLoader::load($projectRoot, 'keycloak');
|
||||
$auth = new KeycloakAuth($keycloakConfig);
|
||||
$moduleRegistry = new ModuleRegistry($projectRoot . '/modules');
|
||||
$registry = new AppRegistry($projectRoot . '/config/apps.php', $moduleRegistry->desktopApps());
|
||||
$widgetRegistry = new WidgetRegistry($projectRoot . '/config/widgets.php');
|
||||
$service = new UserSelfManagementService($projectRoot);
|
||||
$registrationConfig = ConfigLoader::load($projectRoot, 'registration');
|
||||
$ldap = new LdapProvisioner($registrationConfig);
|
||||
$isAuthenticated = $auth->isAuthenticated();
|
||||
$authUser = $isAuthenticated && is_array($_SESSION['desktop_auth']['user'] ?? null)
|
||||
? $_SESSION['desktop_auth']['user']
|
||||
: [];
|
||||
$authGroups = array_values(array_map('strval', (array) ($authUser['groups'] ?? [])));
|
||||
$visibleApps = AppVisibility::filterByGroups($registry->all(), $authGroups);
|
||||
$widgets = $widgetRegistry->all();
|
||||
$skins = SkinResolver::all();
|
||||
|
||||
if ($method === 'GET') {
|
||||
respond($service->buildBootstrapPayload($authUser, $visibleApps, $widgets, $skins));
|
||||
}
|
||||
|
||||
if ($method !== 'PUT') {
|
||||
respond(['error' => 'Method not allowed.'], 405);
|
||||
}
|
||||
|
||||
$rawBody = file_get_contents('php://input');
|
||||
$decoded = json_decode($rawBody !== false ? $rawBody : '', true);
|
||||
|
||||
if (!is_array($decoded)) {
|
||||
respond(['error' => 'Invalid JSON payload.'], 400);
|
||||
}
|
||||
|
||||
$before = $service->load($authUser, $visibleApps, $widgets, $skins);
|
||||
$after = $service->save($decoded, $authUser, $visibleApps, $widgets, $skins);
|
||||
$payload = $service->buildBootstrapPayload($authUser, $visibleApps, $widgets, $skins);
|
||||
$payload['preferences'] = $after;
|
||||
$payload['meta']['requires_reload'] = requiresReload($before, $after);
|
||||
$payload['meta']['ldap_profile_sync'] = [
|
||||
'attempted' => false,
|
||||
'success' => false,
|
||||
'message' => 'LDAP-Sync nicht ausgefuehrt.',
|
||||
];
|
||||
|
||||
$username = trim((string) ($authUser['username'] ?? ''));
|
||||
if ($username !== '' && $ldap->isEnabled()) {
|
||||
$payload['meta']['ldap_profile_sync']['attempted'] = true;
|
||||
$ldapResult = $ldap->updateUserProfile($username, is_array($after['profile'] ?? null) ? $after['profile'] : []);
|
||||
$payload['meta']['ldap_profile_sync']['success'] = (bool) ($ldapResult['success'] ?? false);
|
||||
$payload['meta']['ldap_profile_sync']['message'] = (string) ($ldapResult['message'] ?? 'LDAP-Sync ohne Rueckmeldung.');
|
||||
if (isset($ldapResult['updated_fields']) && is_array($ldapResult['updated_fields'])) {
|
||||
$payload['meta']['ldap_profile_sync']['updated_fields'] = array_values(array_map('strval', $ldapResult['updated_fields']));
|
||||
}
|
||||
}
|
||||
|
||||
respond($payload);
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $payload
|
||||
*/
|
||||
function respond(array $payload, int $statusCode = 200): never
|
||||
{
|
||||
http_response_code($statusCode);
|
||||
echo json_encode($payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR);
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $before
|
||||
* @param array<string, mixed> $after
|
||||
*/
|
||||
function requiresReload(array $before, array $after): bool
|
||||
{
|
||||
$beforeSkin = (string) ($before['desktop']['active_skin'] ?? '');
|
||||
$afterSkin = (string) ($after['desktop']['active_skin'] ?? '');
|
||||
$beforeApps = array_values(array_map('strval', (array) ($before['apps']['enabled_ids'] ?? [])));
|
||||
$afterApps = array_values(array_map('strval', (array) ($after['apps']['enabled_ids'] ?? [])));
|
||||
|
||||
sort($beforeApps);
|
||||
sort($afterApps);
|
||||
|
||||
return $beforeSkin !== $afterSkin || $beforeApps !== $afterApps;
|
||||
}
|
||||
require AppPaths::systemAppPath(dirname(__DIR__, 3), 'user-self-management') . '/api.php';
|
||||
|
||||
@@ -2,4 +2,8 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require dirname(__DIR__, 3) . '/modules/boersenchecker/pages/index.php';
|
||||
require_once dirname(__DIR__, 3) . '/src/App/bootstrap.php';
|
||||
|
||||
use App\AppPaths;
|
||||
|
||||
require AppPaths::customAppPath(dirname(__DIR__, 3), 'boersenchecker') . '/pages/index.php';
|
||||
|
||||
@@ -2,4 +2,8 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require dirname(__DIR__, 3) . '/modules/fx-rates/pages/index.php';
|
||||
require_once dirname(__DIR__, 3) . '/src/App/bootstrap.php';
|
||||
|
||||
use App\AppPaths;
|
||||
|
||||
require AppPaths::customAppPath(dirname(__DIR__, 3), 'fx-rates') . '/pages/index.php';
|
||||
|
||||
@@ -2,4 +2,8 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require dirname(__DIR__, 3) . '/modules/mining-checker/pages/index.php';
|
||||
require_once dirname(__DIR__, 3) . '/src/App/bootstrap.php';
|
||||
|
||||
use App\AppPaths;
|
||||
|
||||
require AppPaths::customAppPath(dirname(__DIR__, 3), 'mining-checker') . '/pages/index.php';
|
||||
|
||||
@@ -2,4 +2,8 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require dirname(__DIR__, 3) . '/modules/pihole/pages/index.php';
|
||||
require_once dirname(__DIR__, 3) . '/src/App/bootstrap.php';
|
||||
|
||||
use App\AppPaths;
|
||||
|
||||
require AppPaths::customAppPath(dirname(__DIR__, 3), 'pihole') . '/pages/index.php';
|
||||
|
||||
@@ -2,4 +2,8 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require dirname(__DIR__, 3) . '/modules/salesforce-translation-import/pages/index.php';
|
||||
require_once dirname(__DIR__, 3) . '/src/App/bootstrap.php';
|
||||
|
||||
use App\AppPaths;
|
||||
|
||||
require AppPaths::customAppPath(dirname(__DIR__, 3), 'salesforce-translation-import') . '/pages/index.php';
|
||||
|
||||
@@ -4,36 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__, 3) . '/src/App/bootstrap.php';
|
||||
|
||||
session_start();
|
||||
use App\AppPaths;
|
||||
|
||||
$assetVersion = static function (string $publicPath): string {
|
||||
$filesystemPath = dirname(__DIR__, 2) . $publicPath;
|
||||
|
||||
if (!is_file($filesystemPath)) {
|
||||
return $publicPath;
|
||||
}
|
||||
|
||||
$mtime = filemtime($filesystemPath);
|
||||
|
||||
return $mtime === false ? $publicPath : $publicPath . '?v=' . $mtime;
|
||||
};
|
||||
?><!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>User Self Management</title>
|
||||
<link rel="stylesheet" href="<?= htmlspecialchars($assetVersion('/assets/apps/user-self-management/app.css'), ENT_QUOTES) ?>">
|
||||
</head>
|
||||
<body style="margin:0;background:#e5e7eb;">
|
||||
<div id="user-self-management-app" style="min-height:100vh;"></div>
|
||||
<script src="<?= htmlspecialchars($assetVersion('/assets/apps/user-self-management/app.js'), ENT_QUOTES) ?>"></script>
|
||||
<script>
|
||||
if (typeof window.initUserSelfManagementApp === 'function') {
|
||||
window.initUserSelfManagementApp(document.getElementById('user-self-management-app'), {
|
||||
apiBase: '/api/user-self-management/index.php',
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
require AppPaths::systemAppPath(dirname(__DIR__, 3), 'user-self-management') . '/page.php';
|
||||
|
||||
@@ -1,255 +0,0 @@
|
||||
#cron-management-app {
|
||||
min-height: 100%;
|
||||
color: #0f172a;
|
||||
font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
|
||||
}
|
||||
|
||||
#cron-management-app,
|
||||
#cron-management-app * {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#cron-management-app.is-loading {
|
||||
opacity: 0.72;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-shell,
|
||||
#cron-management-app .cm-frame,
|
||||
#cron-management-app .cm-main,
|
||||
#cron-management-app .cm-panel {
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-brand,
|
||||
#cron-management-app .cm-copy {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-kicker {
|
||||
margin: 0 0 10px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
color: #2563eb;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-card,
|
||||
#cron-management-app .cm-job-card {
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-job-card {
|
||||
gap: 12px;
|
||||
padding: 18px 20px;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-side-title,
|
||||
#cron-management-app .cm-section-title {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-side-metric,
|
||||
#cron-management-app .cm-field,
|
||||
#cron-management-app .cm-token-box {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-side-metric span,
|
||||
#cron-management-app .cm-field span,
|
||||
#cron-management-app .cm-token-box p,
|
||||
#cron-management-app .cm-job-card p,
|
||||
#cron-management-app .cm-message,
|
||||
#cron-management-app .cm-empty {
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-form {
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-form--global {
|
||||
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
|
||||
align-items: end;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-field input,
|
||||
#cron-management-app .cm-token-box,
|
||||
#cron-management-app .cm-status-grid > div {
|
||||
width: 100%;
|
||||
min-height: 46px;
|
||||
padding: 12px 14px;
|
||||
border-radius: 14px;
|
||||
border: 1px solid rgba(148, 163, 184, 0.24);
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
color: #0f172a;
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-token-box code {
|
||||
display: block;
|
||||
overflow-wrap: anywhere;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-inline-form {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-primary {
|
||||
background: linear-gradient(135deg, #312e81, #4338ca);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-secondary {
|
||||
background: #eff6ff;
|
||||
color: #1d4ed8;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-job-list {
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-job-head,
|
||||
#cron-management-app .cm-section-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-job-meta {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-status-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-job-summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-job-summary-item,
|
||||
#cron-management-app .cm-job-inline-meta {
|
||||
font-size: 13px;
|
||||
line-height: 1.45;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-job-summary-item {
|
||||
padding: 10px 12px;
|
||||
border: 1px solid rgba(148, 163, 184, 0.22);
|
||||
border-radius: 12px;
|
||||
background: rgba(248, 250, 252, 0.82);
|
||||
}
|
||||
|
||||
#cron-management-app .cm-job-summary-item span {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-job-summary-item strong {
|
||||
display: block;
|
||||
margin-top: 4px;
|
||||
font-size: 14px;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-job-inline-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px 14px;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-job-inline-meta span {
|
||||
display: inline-flex;
|
||||
gap: 6px;
|
||||
align-items: baseline;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-job-toolbar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-form--job {
|
||||
padding: 14px;
|
||||
border: 1px solid rgba(148, 163, 184, 0.22);
|
||||
border-radius: 14px;
|
||||
background: rgba(248, 250, 252, 0.85);
|
||||
}
|
||||
|
||||
#cron-management-app .cm-form--job[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-form--job .cm-field input {
|
||||
min-height: 42px;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-status-grid strong {
|
||||
display: block;
|
||||
margin-top: 4px;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-check {
|
||||
display: inline-flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
font-size: 14px;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-message {
|
||||
padding: 14px 16px;
|
||||
border-radius: 14px;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-message.is-success {
|
||||
background: rgba(34, 197, 94, 0.12);
|
||||
color: #166534;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-message.is-error,
|
||||
#cron-management-app .cm-parse-error {
|
||||
background: rgba(239, 68, 68, 0.1);
|
||||
color: #991b1b;
|
||||
padding: 12px 14px;
|
||||
border-radius: 14px;
|
||||
}
|
||||
|
||||
#cron-management-app .cm-list {
|
||||
margin: 8px 0 0;
|
||||
padding-left: 18px;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
#cron-management-app .cm-form--global,
|
||||
#cron-management-app .cm-status-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
(() => {
|
||||
const normalizeUrl = (url) => {
|
||||
const next = new URL(url, window.location.origin);
|
||||
next.searchParams.set('partial', '1');
|
||||
return next.toString();
|
||||
};
|
||||
|
||||
const renderError = (host, message) => {
|
||||
host.innerHTML = `
|
||||
<div class="window-app-shell cm-shell">
|
||||
<div class="window-app-frame cm-frame">
|
||||
<main class="window-app-main cm-main">
|
||||
<div class="window-app-panel cm-panel">
|
||||
<section class="window-app-card cm-card">
|
||||
<p class="cm-message is-error">${String(message || 'Cron Tool konnte nicht geladen werden.')}</p>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
};
|
||||
|
||||
const bindInteractions = (host, loadRoute) => {
|
||||
host.querySelectorAll('[data-cm-edit-toggle]').forEach((button) => {
|
||||
if (button.dataset.cmBound === '1') {
|
||||
return;
|
||||
}
|
||||
|
||||
button.dataset.cmBound = '1';
|
||||
button.addEventListener('click', () => {
|
||||
const targetId = String(button.getAttribute('data-cm-edit-toggle') || '');
|
||||
const target = targetId !== '' ? host.querySelector(`[data-cm-edit-target="${CSS.escape(targetId)}"]`) : null;
|
||||
if (!(target instanceof HTMLElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
target.hidden = !target.hidden;
|
||||
});
|
||||
});
|
||||
|
||||
host.querySelectorAll('[data-cm-edit-close]').forEach((button) => {
|
||||
if (button.dataset.cmBound === '1') {
|
||||
return;
|
||||
}
|
||||
|
||||
button.dataset.cmBound = '1';
|
||||
button.addEventListener('click', () => {
|
||||
const targetId = String(button.getAttribute('data-cm-edit-close') || '');
|
||||
const target = targetId !== '' ? host.querySelector(`[data-cm-edit-target="${CSS.escape(targetId)}"]`) : null;
|
||||
if (target instanceof HTMLElement) {
|
||||
target.hidden = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
host.querySelectorAll('form[action]').forEach((form) => {
|
||||
if (form.dataset.cmBound === '1') {
|
||||
return;
|
||||
}
|
||||
|
||||
const action = String(form.getAttribute('action') || '');
|
||||
if (!action.startsWith('/admin/cron/')) {
|
||||
return;
|
||||
}
|
||||
|
||||
form.dataset.cmBound = '1';
|
||||
form.addEventListener('submit', async (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
try {
|
||||
host.classList.add('is-loading');
|
||||
const response = await fetch(normalizeUrl(action), {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
body: new FormData(form),
|
||||
});
|
||||
|
||||
const html = await response.text();
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}`);
|
||||
}
|
||||
|
||||
host.innerHTML = html;
|
||||
bindInteractions(host, loadRoute);
|
||||
} catch (error) {
|
||||
renderError(host, error?.message || 'Cron Tool konnte nicht geladen werden.');
|
||||
} finally {
|
||||
host.classList.remove('is-loading');
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
window.initCronManagementApp = function initCronManagementApp(host, options = {}) {
|
||||
if (!(host instanceof Element)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (host.dataset.cmAppBound === '1') {
|
||||
return;
|
||||
}
|
||||
|
||||
host.dataset.cmAppBound = '1';
|
||||
|
||||
const entryRoute = String(options.entryRoute || '/admin/cron/');
|
||||
const loadRoute = async (route) => {
|
||||
try {
|
||||
host.classList.add('is-loading');
|
||||
const response = await fetch(normalizeUrl(route), {
|
||||
credentials: 'same-origin',
|
||||
headers: { Accept: 'text/html' },
|
||||
});
|
||||
const html = await response.text();
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}`);
|
||||
}
|
||||
|
||||
host.innerHTML = html;
|
||||
bindInteractions(host, loadRoute);
|
||||
} catch (error) {
|
||||
renderError(host, error?.message || 'Cron Tool konnte nicht geladen werden.');
|
||||
} finally {
|
||||
host.classList.remove('is-loading');
|
||||
}
|
||||
};
|
||||
|
||||
if (options.standalone) {
|
||||
bindInteractions(host, loadRoute);
|
||||
return;
|
||||
}
|
||||
|
||||
loadRoute(entryRoute);
|
||||
};
|
||||
})();
|
||||
@@ -1,322 +0,0 @@
|
||||
#user-management-app {
|
||||
min-height: 100%;
|
||||
color: #0f172a;
|
||||
font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
|
||||
}
|
||||
|
||||
#user-management-app,
|
||||
#user-management-app * {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#user-management-app.is-loading {
|
||||
opacity: 0.7;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
#user-management-app .um-shell,
|
||||
#user-management-app .um-frame,
|
||||
#user-management-app .um-main,
|
||||
#user-management-app .um-panel {
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
#user-management-app .um-brand,
|
||||
#user-management-app .um-copy,
|
||||
#user-management-app .um-meta {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#user-management-app .um-kicker {
|
||||
margin: 0 0 10px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
color: #2563eb;
|
||||
}
|
||||
|
||||
#user-management-app .um-nav-button.is-active {
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
#user-management-app .um-side-card,
|
||||
#user-management-app .um-card {
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
#user-management-app .um-side-title,
|
||||
#user-management-app .um-section-title {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
#user-management-app .um-side-metric,
|
||||
#user-management-app .um-summary-item {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
#user-management-app .um-side-metric span,
|
||||
#user-management-app .um-summary-item span,
|
||||
#user-management-app .um-request-card span,
|
||||
#user-management-app .um-field span,
|
||||
#user-management-app .um-meta,
|
||||
#user-management-app .um-empty,
|
||||
#user-management-app .um-message,
|
||||
#user-management-app .um-checkbox-item p {
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
#user-management-app .um-grid {
|
||||
display: grid;
|
||||
gap: 18px;
|
||||
}
|
||||
|
||||
#user-management-app .um-grid--split {
|
||||
grid-template-columns: minmax(280px, 0.95fr) minmax(0, 1.35fr);
|
||||
}
|
||||
|
||||
#user-management-app .um-section-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
#user-management-app .um-request-list,
|
||||
#user-management-app .um-checkbox-grid {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
#user-management-app .um-request-card {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
padding: 14px 16px;
|
||||
border: 1px solid rgba(148, 163, 184, 0.24);
|
||||
border-radius: 16px;
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
|
||||
}
|
||||
|
||||
#user-management-app .um-request-card:hover,
|
||||
#user-management-app .um-request-card.is-active {
|
||||
border-color: rgba(37, 99, 235, 0.4);
|
||||
box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.35);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
#user-management-app .um-request-card strong,
|
||||
#user-management-app .um-checkbox-item strong {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
#user-management-app .um-request-status {
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: #1d4ed8;
|
||||
}
|
||||
|
||||
#user-management-app .um-summary-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
#user-management-app .um-summary-item {
|
||||
padding: 14px 16px;
|
||||
border-radius: 16px;
|
||||
background: rgba(248, 250, 252, 0.9);
|
||||
border: 1px solid rgba(148, 163, 184, 0.18);
|
||||
}
|
||||
|
||||
#user-management-app .um-summary-item strong {
|
||||
font-size: 15px;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
#user-management-app .um-form {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
#user-management-app .um-field {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
#user-management-app .um-field input,
|
||||
#user-management-app .um-field textarea {
|
||||
width: 100%;
|
||||
min-height: 46px;
|
||||
padding: 12px 14px;
|
||||
border-radius: 14px;
|
||||
border: 1px solid rgba(148, 163, 184, 0.24);
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
color: #0f172a;
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
#user-management-app .um-field textarea {
|
||||
min-height: 120px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
#user-management-app .um-user-picker {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#user-management-app .um-user-picker-list {
|
||||
position: absolute;
|
||||
top: calc(100% + 8px);
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 20;
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
max-height: 320px;
|
||||
overflow: auto;
|
||||
padding: 10px;
|
||||
border: 1px solid rgba(148, 163, 184, 0.24);
|
||||
border-radius: 16px;
|
||||
background: rgba(255, 255, 255, 0.98);
|
||||
box-shadow: 0 20px 44px rgba(15, 23, 42, 0.12);
|
||||
}
|
||||
|
||||
#user-management-app .um-user-picker-list[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
#user-management-app .um-user-picker-option {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
width: 100%;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid rgba(148, 163, 184, 0.18);
|
||||
border-radius: 14px;
|
||||
background: rgba(248, 250, 252, 0.95);
|
||||
color: #0f172a;
|
||||
text-align: left;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#user-management-app .um-user-picker-option:hover {
|
||||
border-color: rgba(37, 99, 235, 0.35);
|
||||
box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.3);
|
||||
background: #eff6ff;
|
||||
}
|
||||
|
||||
#user-management-app .um-user-picker-option strong {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
#user-management-app .um-user-picker-option span,
|
||||
#user-management-app .um-user-picker-empty {
|
||||
font-size: 13px;
|
||||
line-height: 1.45;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
#user-management-app .um-user-picker-empty {
|
||||
padding: 8px 4px;
|
||||
}
|
||||
|
||||
#user-management-app .um-fieldset {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
#user-management-app .um-fieldset legend {
|
||||
margin-bottom: 8px;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
#user-management-app .um-checkbox-item {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
#user-management-app .um-checkbox-item input {
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
#user-management-app .um-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#user-management-app .um-primary {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 44px;
|
||||
padding: 10px 16px;
|
||||
border: 0;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(135deg, #2563eb, #1d4ed8);
|
||||
color: #fff;
|
||||
font: inherit;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#user-management-app .um-secondary,
|
||||
#user-management-app .um-danger {
|
||||
min-height: 42px;
|
||||
}
|
||||
|
||||
#user-management-app .um-danger {
|
||||
border-color: rgba(239, 68, 68, 0.28);
|
||||
color: #b91c1c;
|
||||
}
|
||||
|
||||
#user-management-app .um-message {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
#user-management-app .um-message strong {
|
||||
font-size: 15px;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
#user-management-app .um-message.is-error {
|
||||
color: #b91c1c;
|
||||
}
|
||||
|
||||
#user-management-app .um-message.is-success {
|
||||
color: #047857;
|
||||
}
|
||||
|
||||
#user-management-app .um-list {
|
||||
margin: 0;
|
||||
padding-left: 18px;
|
||||
}
|
||||
|
||||
@media (max-width: 980px) {
|
||||
#user-management-app .um-grid--split {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
#user-management-app .um-section-head,
|
||||
#user-management-app .um-actions {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
}
|
||||
@@ -1,270 +0,0 @@
|
||||
(() => {
|
||||
const normalizeUrl = (url) => {
|
||||
const next = new URL(url, window.location.origin);
|
||||
next.searchParams.set('partial', '1');
|
||||
return next.toString();
|
||||
};
|
||||
|
||||
const renderError = (host, message) => {
|
||||
host.innerHTML = `
|
||||
<div class="window-app-shell um-shell">
|
||||
<div class="window-app-frame um-frame">
|
||||
<main class="window-app-main um-main">
|
||||
<div class="window-app-panel um-panel">
|
||||
<section class="window-app-card um-card">
|
||||
<p class="um-message is-error">${String(message || 'User Management konnte nicht geladen werden.')}</p>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
};
|
||||
|
||||
const escapeHtml = (value) => String(value ?? '')
|
||||
.replaceAll('&', '&')
|
||||
.replaceAll('<', '<')
|
||||
.replaceAll('>', '>')
|
||||
.replaceAll('"', '"')
|
||||
.replaceAll("'", ''');
|
||||
|
||||
const bindUserPickers = (host) => {
|
||||
const dataNode = host.querySelector('#um-existing-users-data');
|
||||
if (!(dataNode instanceof HTMLScriptElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let users = [];
|
||||
try {
|
||||
const decoded = JSON.parse(dataNode.textContent || '[]');
|
||||
if (Array.isArray(decoded)) {
|
||||
users = decoded;
|
||||
}
|
||||
} catch (_error) {
|
||||
users = [];
|
||||
}
|
||||
|
||||
const normalizedUsers = users.map((user) => ({
|
||||
username: String(user?.username || ''),
|
||||
display_name: String(user?.display_name || ''),
|
||||
email: String(user?.email || ''),
|
||||
group_dns: Array.isArray(user?.group_dns) ? user.group_dns.map((group) => String(group || '')) : [],
|
||||
search: [
|
||||
String(user?.username || ''),
|
||||
String(user?.display_name || ''),
|
||||
String(user?.email || ''),
|
||||
].join(' ').toLowerCase(),
|
||||
})).filter((user) => user.username !== '');
|
||||
|
||||
const closeAll = () => {
|
||||
host.querySelectorAll('[data-user-picker-list]').forEach((list) => {
|
||||
list.setAttribute('hidden', 'hidden');
|
||||
list.innerHTML = '';
|
||||
});
|
||||
};
|
||||
|
||||
host.querySelectorAll('[data-user-picker]').forEach((picker) => {
|
||||
const input = picker.querySelector('[data-user-picker-input]');
|
||||
const list = picker.querySelector('[data-user-picker-list]');
|
||||
if (!(input instanceof HTMLInputElement) || !(list instanceof HTMLElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (input.dataset.umPickerBound === '1') {
|
||||
return;
|
||||
}
|
||||
input.dataset.umPickerBound = '1';
|
||||
|
||||
const syncGroupSelection = (username) => {
|
||||
const normalizedUsername = String(username || '').trim().toLowerCase();
|
||||
host.querySelectorAll('input[name="manual_group_dns[]"]').forEach((checkbox) => {
|
||||
if (!(checkbox instanceof HTMLInputElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
checkbox.checked = false;
|
||||
});
|
||||
|
||||
if (normalizedUsername === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
const user = normalizedUsers.find((entry) => entry.username.toLowerCase() === normalizedUsername);
|
||||
if (!user) {
|
||||
return;
|
||||
}
|
||||
|
||||
const selectedGroups = new Set(user.group_dns);
|
||||
host.querySelectorAll('input[name="manual_group_dns[]"]').forEach((checkbox) => {
|
||||
if (!(checkbox instanceof HTMLInputElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
checkbox.checked = selectedGroups.has(checkbox.value);
|
||||
});
|
||||
};
|
||||
|
||||
const renderMatches = () => {
|
||||
const needle = input.value.trim().toLowerCase();
|
||||
const matches = normalizedUsers
|
||||
.filter((user) => needle === '' || user.search.includes(needle))
|
||||
.slice(0, needle === '' ? 80 : 25);
|
||||
|
||||
list.innerHTML = '';
|
||||
if (matches.length === 0) {
|
||||
list.innerHTML = '<div class="um-user-picker-empty">Keine passenden Benutzer gefunden.</div>';
|
||||
list.hidden = false;
|
||||
return;
|
||||
}
|
||||
|
||||
list.innerHTML = matches.map((user) => `
|
||||
<button class="um-user-picker-option" type="button" data-user-picker-value="${escapeHtml(user.username)}">
|
||||
<strong>${escapeHtml(user.username)}</strong>
|
||||
<span>${escapeHtml(user.display_name || 'Ohne Anzeigename')}</span>
|
||||
<span>${escapeHtml(user.email || 'Keine E-Mail')}</span>
|
||||
</button>
|
||||
`).join('');
|
||||
list.hidden = false;
|
||||
};
|
||||
|
||||
input.addEventListener('focus', renderMatches);
|
||||
input.addEventListener('input', renderMatches);
|
||||
|
||||
list.addEventListener('click', (event) => {
|
||||
const option = event.target.closest('[data-user-picker-value]');
|
||||
if (!(option instanceof HTMLElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
input.value = String(option.dataset.userPickerValue || '');
|
||||
list.hidden = true;
|
||||
list.innerHTML = '';
|
||||
syncGroupSelection(input.value);
|
||||
input.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
});
|
||||
|
||||
input.addEventListener('change', () => {
|
||||
syncGroupSelection(input.value);
|
||||
});
|
||||
|
||||
if (input.value.trim() !== '') {
|
||||
syncGroupSelection(input.value);
|
||||
}
|
||||
});
|
||||
|
||||
if (!host.dataset.umPickerOutsideBound) {
|
||||
host.dataset.umPickerOutsideBound = '1';
|
||||
document.addEventListener('click', (event) => {
|
||||
if (!(event.target instanceof Node) || !host.contains(event.target)) {
|
||||
closeAll();
|
||||
return;
|
||||
}
|
||||
|
||||
const insidePicker = event.target instanceof Element && event.target.closest('[data-user-picker]');
|
||||
if (!insidePicker) {
|
||||
closeAll();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const bindInteractions = (host, loadRoute) => {
|
||||
host.querySelectorAll('a[href]').forEach((link) => {
|
||||
if (link.dataset.umBound === '1') {
|
||||
return;
|
||||
}
|
||||
|
||||
const href = String(link.getAttribute('href') || '');
|
||||
if (!href.startsWith('/admin/users/')) {
|
||||
return;
|
||||
}
|
||||
|
||||
link.dataset.umBound = '1';
|
||||
link.addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
loadRoute(href);
|
||||
});
|
||||
});
|
||||
|
||||
host.querySelectorAll('form[action]').forEach((form) => {
|
||||
if (form.dataset.umBound === '1') {
|
||||
return;
|
||||
}
|
||||
|
||||
const action = String(form.getAttribute('action') || '');
|
||||
if (!action.startsWith('/admin/users/')) {
|
||||
return;
|
||||
}
|
||||
|
||||
form.dataset.umBound = '1';
|
||||
form.addEventListener('submit', async (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
try {
|
||||
host.classList.add('is-loading');
|
||||
const response = await fetch(normalizeUrl(action), {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
body: new FormData(form),
|
||||
});
|
||||
|
||||
const html = await response.text();
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}`);
|
||||
}
|
||||
|
||||
host.innerHTML = html;
|
||||
bindInteractions(host, loadRoute);
|
||||
bindUserPickers(host);
|
||||
} catch (error) {
|
||||
renderError(host, error?.message || 'Formular konnte nicht verarbeitet werden.');
|
||||
} finally {
|
||||
host.classList.remove('is-loading');
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
window.initUserManagementApp = function initUserManagementApp(host, options = {}) {
|
||||
if (!(host instanceof Element)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (host.dataset.umAppBound === '1') {
|
||||
return;
|
||||
}
|
||||
|
||||
host.dataset.umAppBound = '1';
|
||||
|
||||
const entryRoute = String(options.entryRoute || '/admin/users/');
|
||||
const loadRoute = async (route) => {
|
||||
try {
|
||||
host.classList.add('is-loading');
|
||||
const response = await fetch(normalizeUrl(route), {
|
||||
credentials: 'same-origin',
|
||||
headers: { Accept: 'text/html' },
|
||||
});
|
||||
const html = await response.text();
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}`);
|
||||
}
|
||||
|
||||
host.innerHTML = html;
|
||||
bindInteractions(host, loadRoute);
|
||||
bindUserPickers(host);
|
||||
} catch (error) {
|
||||
renderError(host, error?.message || 'User Management konnte nicht geladen werden.');
|
||||
} finally {
|
||||
host.classList.remove('is-loading');
|
||||
}
|
||||
};
|
||||
|
||||
if (options.standalone) {
|
||||
bindInteractions(host, loadRoute);
|
||||
bindUserPickers(host);
|
||||
return;
|
||||
}
|
||||
|
||||
loadRoute(entryRoute);
|
||||
};
|
||||
})();
|
||||
@@ -1,98 +0,0 @@
|
||||
#user-self-management-app {
|
||||
min-height: 100%;
|
||||
color: #0f172a;
|
||||
font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
|
||||
}
|
||||
|
||||
#user-self-management-app,
|
||||
#user-self-management-app * {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#user-self-management-app .usm-brand {
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
#user-self-management-app .usm-brand h1 {
|
||||
margin: 0 0 8px;
|
||||
font-size: 24px;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
#user-self-management-app .usm-brand p,
|
||||
#user-self-management-app .usm-copy,
|
||||
#user-self-management-app .usm-meta,
|
||||
#user-self-management-app .usm-note,
|
||||
#user-self-management-app .usm-status {
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
#user-self-management-app .usm-nav-button.is-active {
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
#user-self-management-app .usm-kicker {
|
||||
margin: 0 0 10px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
color: #2563eb;
|
||||
}
|
||||
|
||||
#user-self-management-app .usm-title {
|
||||
margin: 0 0 8px;
|
||||
font-size: 32px;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
#user-self-management-app .usm-choice.is-active {
|
||||
border-color: #2563eb;
|
||||
box-shadow: inset 0 0 0 1px #2563eb;
|
||||
background: #eff6ff;
|
||||
}
|
||||
|
||||
#user-self-management-app .usm-choice strong,
|
||||
#user-self-management-app .usm-item-main strong {
|
||||
display: block;
|
||||
margin: 0 0 4px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
#user-self-management-app .usm-choice p,
|
||||
#user-self-management-app .usm-item-main p {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
#user-self-management-app .usm-item input {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
#user-self-management-app .usm-item-main {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
#user-self-management-app .usm-item-meta {
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: #1d4ed8;
|
||||
}
|
||||
|
||||
#user-self-management-app .usm-message {
|
||||
font-size: 13px;
|
||||
color: #334155;
|
||||
}
|
||||
|
||||
#user-self-management-app .usm-message.is-error {
|
||||
color: #b91c1c;
|
||||
}
|
||||
|
||||
#user-self-management-app .usm-message.is-success {
|
||||
color: #047857;
|
||||
}
|
||||
@@ -1,474 +0,0 @@
|
||||
(() => {
|
||||
const SECTIONS = [
|
||||
{ id: 'desktop', label: 'Desktop Type' },
|
||||
{ id: 'profile', label: 'Benutzerdaten' },
|
||||
{ id: 'apps', label: 'App-Installation' },
|
||||
{ id: 'widgets', label: 'Infobereich' },
|
||||
];
|
||||
|
||||
const escapeHtml = (value) => String(value)
|
||||
.replaceAll('&', '&')
|
||||
.replaceAll('<', '<')
|
||||
.replaceAll('>', '>')
|
||||
.replaceAll('"', '"')
|
||||
.replaceAll("'", ''');
|
||||
|
||||
const clone = (value) => JSON.parse(JSON.stringify(value));
|
||||
|
||||
const sameSelection = (left, right) => {
|
||||
const nextLeft = [...left].sort();
|
||||
const nextRight = [...right].sort();
|
||||
|
||||
return JSON.stringify(nextLeft) === JSON.stringify(nextRight);
|
||||
};
|
||||
|
||||
const summarizeSection = (sectionId) => {
|
||||
if (sectionId === 'desktop') {
|
||||
return 'Windows-aehnlicher Standard fuer Desktop-Typ und Skin-Auswahl.';
|
||||
}
|
||||
|
||||
if (sectionId === 'profile') {
|
||||
return 'Lokales Profil fuer Name, E-Mail, Telefon und spaetere LDAP-/Keycloak-Synchronisierung.';
|
||||
}
|
||||
|
||||
if (sectionId === 'apps') {
|
||||
return 'Bestimmt, welche Desktop-Apps fuer diesen Benutzer sichtbar bleiben.';
|
||||
}
|
||||
|
||||
return 'Steuert, welche Elemente im rechten Infobereich des Desktops aktiv sind.';
|
||||
};
|
||||
|
||||
const renderSkinChoices = (state) => state.bootstrap.options.skins.map((skin) => {
|
||||
const isActive = state.draft.desktop.active_skin === skin.skin_id;
|
||||
|
||||
return `
|
||||
<button
|
||||
class="window-app-choice usm-choice${isActive ? ' is-active' : ''}"
|
||||
type="button"
|
||||
data-action="select-skin"
|
||||
data-skin-id="${escapeHtml(skin.skin_id)}"
|
||||
>
|
||||
<strong>${escapeHtml(skin.label)}</strong>
|
||||
<p>${escapeHtml(summarizeSkin(skin.skin_id))}</p>
|
||||
</button>
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
const summarizeSkin = (skinId) => {
|
||||
if (skinId === 'apple') {
|
||||
return 'Top-Bar, rechte Icon-Anordnung und Finder-nahe Fensterelemente.';
|
||||
}
|
||||
|
||||
if (skinId === 'linux') {
|
||||
return 'Klassische Arbeitsflaeche mit neutralem Fensterstil und Linux-Taskbar.';
|
||||
}
|
||||
|
||||
return 'Standardisiertes Control-Panel-Muster mit Windows-naher Einstellungslogik.';
|
||||
};
|
||||
|
||||
const renderAppItems = (state) => state.bootstrap.options.apps.map((app) => {
|
||||
const checked = state.draft.apps.enabled_ids.includes(app.app_id);
|
||||
|
||||
return `
|
||||
<label class="window-app-item usm-item">
|
||||
<input
|
||||
type="checkbox"
|
||||
data-action="toggle-app"
|
||||
data-app-id="${escapeHtml(app.app_id)}"
|
||||
${checked ? 'checked' : ''}
|
||||
${app.required ? 'disabled' : ''}
|
||||
>
|
||||
<span class="window-app-item-main usm-item-main">
|
||||
<strong>${escapeHtml(app.title)}</strong>
|
||||
<p>${escapeHtml(app.summary || '')}</p>
|
||||
<span class="usm-item-meta">${app.required ? 'Pflicht-App' : 'Optional sichtbar'}</span>
|
||||
</span>
|
||||
</label>
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
const renderWidgetItems = (state) => state.bootstrap.options.widgets.map((widget) => {
|
||||
const checked = state.draft.widgets.active_ids.includes(widget.widget_id);
|
||||
|
||||
return `
|
||||
<label class="window-app-item usm-item">
|
||||
<input
|
||||
type="checkbox"
|
||||
data-action="toggle-widget"
|
||||
data-widget-id="${escapeHtml(widget.widget_id)}"
|
||||
${checked ? 'checked' : ''}
|
||||
>
|
||||
<span class="window-app-item-main usm-item-main">
|
||||
<strong>${escapeHtml(widget.title)}</strong>
|
||||
<p>${escapeHtml(widget.summary || '')}</p>
|
||||
<span class="usm-item-meta">${widget.default_enabled ? 'Standardbereich' : 'Optionaler Bereich'}</span>
|
||||
</span>
|
||||
</label>
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
const renderProfileFields = (state) => `
|
||||
<div class="window-app-grid usm-grid">
|
||||
${renderField('name', 'Name', state.draft.profile.name)}
|
||||
${renderField('email', 'E-Mail', state.draft.profile.email, 'email')}
|
||||
${renderField('phone', 'Telefon', state.draft.profile.phone, 'tel')}
|
||||
${renderField('birthdate', 'Geburtsdatum', state.draft.profile.birthdate, 'date')}
|
||||
${renderField('title', 'Titel', state.draft.profile.title)}
|
||||
${renderField('department', 'Abteilung', state.draft.profile.department)}
|
||||
${renderField('city', 'Ort', state.draft.profile.city)}
|
||||
${renderField('website', 'Website', state.draft.profile.website, 'url')}
|
||||
</div>
|
||||
<div class="window-app-field usm-field">
|
||||
<label class="window-app-label usm-label" for="usm-notes">Notizen</label>
|
||||
<textarea id="usm-notes" class="window-app-textarea usm-textarea" data-field="profile.notes">${escapeHtml(state.draft.profile.notes || '')}</textarea>
|
||||
</div>
|
||||
`;
|
||||
|
||||
const renderField = (fieldId, label, value, type = 'text') => `
|
||||
<div class="window-app-field usm-field">
|
||||
<label class="window-app-label usm-label" for="usm-${escapeHtml(fieldId)}">${escapeHtml(label)}</label>
|
||||
<input
|
||||
id="usm-${escapeHtml(fieldId)}"
|
||||
class="window-app-input usm-input"
|
||||
type="${escapeHtml(type)}"
|
||||
data-field="profile.${escapeHtml(fieldId)}"
|
||||
value="${escapeHtml(value || '')}"
|
||||
>
|
||||
</div>
|
||||
`;
|
||||
|
||||
const sectionContent = (state) => {
|
||||
if (state.activeSection === 'desktop') {
|
||||
return `
|
||||
<section class="window-app-card usm-card">
|
||||
<p class="window-app-kicker usm-kicker">Desktop Type</p>
|
||||
<h2>Skin-Auswahl</h2>
|
||||
<p class="window-app-copy usm-copy">Die direkte Skin-Umschaltung liegt jetzt im Setup. Die Auswahl wird pro Benutzer gespeichert.</p>
|
||||
<div class="window-app-choice-grid usm-choice-grid">
|
||||
${renderSkinChoices(state)}
|
||||
</div>
|
||||
</section>
|
||||
`;
|
||||
}
|
||||
|
||||
if (state.activeSection === 'profile') {
|
||||
return `
|
||||
<section class="window-app-card usm-card">
|
||||
<p class="window-app-kicker usm-kicker">Benutzerdaten</p>
|
||||
<h2>Persoenliches Profil</h2>
|
||||
<p class="window-app-copy usm-copy">Diese Daten werden zunaechst lokal gespeichert und spaeter an LDAP oder Keycloak angebunden.</p>
|
||||
${renderProfileFields(state)}
|
||||
</section>
|
||||
`;
|
||||
}
|
||||
|
||||
if (state.activeSection === 'apps') {
|
||||
return `
|
||||
<section class="window-app-card usm-card">
|
||||
<p class="window-app-kicker usm-kicker">App-Auswahl</p>
|
||||
<h2>Sichtbare Desktop-Apps</h2>
|
||||
<p class="window-app-copy usm-copy">Aenderungen an der App-Auswahl werden nach dem Speichern mit einem Desktop-Reload sauber uebernommen.</p>
|
||||
<div class="window-app-list usm-list">
|
||||
${renderAppItems(state)}
|
||||
</div>
|
||||
</section>
|
||||
`;
|
||||
}
|
||||
|
||||
return `
|
||||
<section class="window-app-card usm-card">
|
||||
<p class="window-app-kicker usm-kicker">Infobereich</p>
|
||||
<h2>Rechter Desktopbereich</h2>
|
||||
<p class="window-app-copy usm-copy">Diese Inhalte liegen aktuell im rechten Infobereich des Desktops und werden hier benutzerbezogen ein- oder ausgeblendet.</p>
|
||||
<div class="window-app-list usm-list">
|
||||
${renderWidgetItems(state)}
|
||||
</div>
|
||||
</section>
|
||||
`;
|
||||
};
|
||||
|
||||
const renderApp = (root, state) => {
|
||||
if (state.loading) {
|
||||
root.innerHTML = '<div class="window-app-loading usm-loading"><p class="window-app-copy usm-copy">Einstellungen werden geladen.</p></div>';
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.error && !state.bootstrap) {
|
||||
root.innerHTML = `<div class="window-app-error-state usm-error-state"><p class="window-app-message usm-message is-error">${escapeHtml(state.error)}</p></div>`;
|
||||
return;
|
||||
}
|
||||
|
||||
root.innerHTML = `
|
||||
<div class="window-app-shell usm-shell">
|
||||
<div class="window-app-frame usm-frame">
|
||||
<aside class="window-app-sidebar usm-nav">
|
||||
<div class="window-app-brand usm-brand">
|
||||
<p class="window-app-kicker usm-kicker">Setup</p>
|
||||
<h1>User Self Management</h1>
|
||||
<p class="window-app-copy">Ein gemeinsamer Setup-Bereich fuer Desktop-Typ, Benutzerdaten, Apps und den rechten Infobereich.</p>
|
||||
</div>
|
||||
<div class="window-app-nav-list usm-nav-list">
|
||||
${SECTIONS.map((section) => `
|
||||
<button
|
||||
class="window-app-nav-button usm-nav-button${state.activeSection === section.id ? ' is-active' : ''}"
|
||||
type="button"
|
||||
data-action="open-section"
|
||||
data-section-id="${escapeHtml(section.id)}"
|
||||
>
|
||||
<strong>${escapeHtml(section.label)}</strong>
|
||||
<span class="window-app-meta usm-meta">${escapeHtml(summarizeSection(section.id))}</span>
|
||||
</button>
|
||||
`).join('')}
|
||||
</div>
|
||||
</aside>
|
||||
<main class="window-app-main usm-main">
|
||||
<div class="window-app-panel usm-panel">
|
||||
<section class="window-app-hero usm-hero">
|
||||
<div>
|
||||
<p class="window-app-kicker usm-kicker">Desktop Setup</p>
|
||||
<h2 class="window-app-title usm-title">${escapeHtml(sectionTitle(state.activeSection))}</h2>
|
||||
<p class="window-app-copy usm-copy">${escapeHtml(summarizeSection(state.activeSection))}</p>
|
||||
</div>
|
||||
<div class="window-app-pill-row usm-pill-row">
|
||||
<span class="window-app-pill usm-pill">LDAP: geplant</span>
|
||||
<span class="window-app-pill usm-pill">Keycloak: geplant</span>
|
||||
<span class="window-app-pill usm-pill">Scope: ${escapeHtml(state.bootstrap.meta.storage_scope || 'guest')}</span>
|
||||
</div>
|
||||
</section>
|
||||
${sectionContent(state)}
|
||||
<section class="window-app-actions usm-actions">
|
||||
<div>
|
||||
<p class="window-app-note usm-note">Skin- und App-Aenderungen koennen einen Reload ausloesen, damit Fenster, Icons und Menue sauber synchron bleiben.</p>
|
||||
<p class="window-app-message usm-message${state.error ? ' is-error' : state.success ? ' is-success' : ''}">${escapeHtml(state.error || state.success || '')}</p>
|
||||
</div>
|
||||
<button class="window-app-button usm-button" type="button" data-action="save-settings" ${state.saving ? 'disabled' : ''}>
|
||||
${state.saving ? 'Speichert ...' : 'Aenderungen speichern'}
|
||||
</button>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
};
|
||||
|
||||
const sectionTitle = (sectionId) => {
|
||||
const current = SECTIONS.find((section) => section.id === sectionId);
|
||||
return current ? current.label : 'Setup';
|
||||
};
|
||||
|
||||
const setDraftValue = (draft, path, value) => {
|
||||
const segments = path.split('.');
|
||||
let cursor = draft;
|
||||
|
||||
segments.slice(0, -1).forEach((segment) => {
|
||||
cursor = cursor[segment];
|
||||
});
|
||||
|
||||
cursor[segments[segments.length - 1]] = value;
|
||||
};
|
||||
|
||||
const toggleSelection = (collection, value) => {
|
||||
const next = new Set(collection);
|
||||
|
||||
if (next.has(value)) {
|
||||
next.delete(value);
|
||||
} else {
|
||||
next.add(value);
|
||||
}
|
||||
|
||||
return Array.from(next);
|
||||
};
|
||||
|
||||
const syncSelectionWithCheckedState = (collection, value, isChecked) => {
|
||||
const next = new Set(collection);
|
||||
|
||||
if (isChecked) {
|
||||
next.add(value);
|
||||
} else {
|
||||
next.delete(value);
|
||||
}
|
||||
|
||||
return Array.from(next);
|
||||
};
|
||||
|
||||
const buildPatch = (state) => ({
|
||||
profile: state.draft.profile,
|
||||
desktop: {
|
||||
active_skin: state.draft.desktop.active_skin,
|
||||
},
|
||||
apps: {
|
||||
enabled_ids: state.draft.apps.enabled_ids,
|
||||
},
|
||||
widgets: {
|
||||
active_ids: state.draft.widgets.active_ids,
|
||||
},
|
||||
});
|
||||
|
||||
const requiresReload = (before, after) => before.desktop.active_skin !== after.desktop.active_skin
|
||||
|| !sameSelection(before.apps.enabled_ids, after.apps.enabled_ids);
|
||||
|
||||
const attachInteractions = (root, state, options) => {
|
||||
root.addEventListener('click', async (event) => {
|
||||
const button = event.target instanceof Element ? event.target.closest('[data-action]') : null;
|
||||
|
||||
if (!button) {
|
||||
return;
|
||||
}
|
||||
|
||||
const action = button.dataset.action;
|
||||
|
||||
if (action === 'open-section') {
|
||||
state.activeSection = button.dataset.sectionId || 'desktop';
|
||||
renderApp(root, state);
|
||||
return;
|
||||
}
|
||||
|
||||
if (action === 'select-skin') {
|
||||
state.draft.desktop.active_skin = button.dataset.skinId || state.draft.desktop.active_skin;
|
||||
renderApp(root, state);
|
||||
return;
|
||||
}
|
||||
|
||||
if (action === 'save-settings') {
|
||||
if (!options.apiBase || state.saving) {
|
||||
return;
|
||||
}
|
||||
|
||||
state.saving = true;
|
||||
state.error = '';
|
||||
state.success = '';
|
||||
renderApp(root, state);
|
||||
|
||||
try {
|
||||
const before = clone(state.bootstrap.preferences);
|
||||
const response = await window.fetch(options.apiBase, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Accept: 'application/json',
|
||||
},
|
||||
body: JSON.stringify(buildPatch(state)),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`save-failed:${response.status}`);
|
||||
}
|
||||
|
||||
const payload = await response.json();
|
||||
const after = payload.preferences;
|
||||
const ldapSync = payload.meta?.ldap_profile_sync || null;
|
||||
state.bootstrap = payload;
|
||||
state.draft = clone(after);
|
||||
const baseMessage = payload.meta?.requires_reload
|
||||
? 'Gespeichert. Desktop wird fuer Skin- oder App-Aenderungen neu geladen.'
|
||||
: 'Einstellungen wurden gespeichert.';
|
||||
const ldapMessage = ldapSync && ldapSync.attempted
|
||||
? ` LDAP: ${ldapSync.message || (ldapSync.success ? 'Synchronisiert.' : 'Nicht synchronisiert.')}`
|
||||
: '';
|
||||
state.success = `${baseMessage}${ldapMessage}`;
|
||||
state.saving = false;
|
||||
renderApp(root, state);
|
||||
|
||||
if (window.desktopShell?.dispatchUserSettingsUpdate) {
|
||||
window.desktopShell.dispatchUserSettingsUpdate({
|
||||
preferences: after,
|
||||
requiresReload: payload.meta?.requires_reload || requiresReload(before, after),
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
} catch (error) {
|
||||
state.saving = false;
|
||||
state.error = 'Speichern fehlgeschlagen. Die lokalen Einstellungen bleiben unveraendert.';
|
||||
renderApp(root, state);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
root.addEventListener('change', (event) => {
|
||||
const target = event.target;
|
||||
|
||||
if (!(target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.dataset.field) {
|
||||
setDraftValue(state.draft, target.dataset.field, target.value);
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.dataset.appId) {
|
||||
state.draft.apps.enabled_ids = syncSelectionWithCheckedState(
|
||||
state.draft.apps.enabled_ids,
|
||||
target.dataset.appId,
|
||||
target.checked
|
||||
);
|
||||
renderApp(root, state);
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.dataset.widgetId) {
|
||||
state.draft.widgets.active_ids = syncSelectionWithCheckedState(
|
||||
state.draft.widgets.active_ids,
|
||||
target.dataset.widgetId,
|
||||
target.checked
|
||||
);
|
||||
renderApp(root, state);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
window.initUserSelfManagementApp = (root, options = {}) => {
|
||||
if (!(root instanceof HTMLElement) || root.dataset.usmInitialized === 'true') {
|
||||
return;
|
||||
}
|
||||
|
||||
root.dataset.usmInitialized = 'true';
|
||||
|
||||
const state = {
|
||||
loading: true,
|
||||
saving: false,
|
||||
error: '',
|
||||
success: '',
|
||||
activeSection: 'desktop',
|
||||
bootstrap: null,
|
||||
draft: null,
|
||||
};
|
||||
|
||||
attachInteractions(root, state, options);
|
||||
renderApp(root, state);
|
||||
|
||||
if (!options.apiBase) {
|
||||
state.loading = false;
|
||||
state.error = 'Die Setup-API ist nicht konfiguriert.';
|
||||
renderApp(root, state);
|
||||
return;
|
||||
}
|
||||
|
||||
window.fetch(options.apiBase, {
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
},
|
||||
})
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`load-failed:${response.status}`);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
})
|
||||
.then((payload) => {
|
||||
state.loading = false;
|
||||
state.bootstrap = payload;
|
||||
state.draft = clone(payload.preferences);
|
||||
renderApp(root, state);
|
||||
})
|
||||
.catch(() => {
|
||||
state.loading = false;
|
||||
state.error = 'Die Einstellungen konnten nicht geladen werden.';
|
||||
renderApp(root, state);
|
||||
});
|
||||
};
|
||||
})();
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/src/App/bootstrap.php';
|
||||
|
||||
use App\AppPaths;
|
||||
use ModulesCore\ModuleRegistry;
|
||||
|
||||
$projectRoot = dirname(__DIR__, 2);
|
||||
@@ -15,7 +16,7 @@ if ($module === '' || $path === '' || str_contains($path, '..')) {
|
||||
exit('Invalid module asset request.');
|
||||
}
|
||||
|
||||
$registry = new ModuleRegistry($projectRoot . '/modules');
|
||||
$registry = new ModuleRegistry(AppPaths::customAppsRoot($projectRoot));
|
||||
$modulePath = $registry->modulePath($module);
|
||||
|
||||
if ($modulePath === null) {
|
||||
|
||||
51
public/system-app-assets/index.php
Normal file
51
public/system-app-assets/index.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/src/App/bootstrap.php';
|
||||
|
||||
use App\AppPaths;
|
||||
|
||||
$projectRoot = dirname(__DIR__, 2);
|
||||
$app = trim((string) ($_GET['app'] ?? ''));
|
||||
$path = trim((string) ($_GET['path'] ?? ''));
|
||||
|
||||
if ($app === '' || $path === '' || str_contains($path, '..')) {
|
||||
http_response_code(400);
|
||||
exit('Invalid system app asset request.');
|
||||
}
|
||||
|
||||
$appPath = AppPaths::systemAppPath($projectRoot, $app);
|
||||
if (!is_dir($appPath)) {
|
||||
http_response_code(404);
|
||||
exit('System app not found.');
|
||||
}
|
||||
|
||||
$assetPath = realpath($appPath . '/' . ltrim($path, '/'));
|
||||
$allowedRoot = realpath($appPath);
|
||||
|
||||
if ($assetPath === false || $allowedRoot === false || !str_starts_with($assetPath, $allowedRoot . DIRECTORY_SEPARATOR) || !is_file($assetPath)) {
|
||||
http_response_code(404);
|
||||
exit('Asset not found.');
|
||||
}
|
||||
|
||||
$extension = strtolower(pathinfo($assetPath, PATHINFO_EXTENSION));
|
||||
$contentType = match ($extension) {
|
||||
'css' => 'text/css; charset=utf-8',
|
||||
'js' => 'application/javascript; charset=utf-8',
|
||||
'json' => 'application/json; charset=utf-8',
|
||||
'svg' => 'image/svg+xml',
|
||||
'png' => 'image/png',
|
||||
'jpg', 'jpeg' => 'image/jpeg',
|
||||
'gif' => 'image/gif',
|
||||
'webp' => 'image/webp',
|
||||
default => 'application/octet-stream',
|
||||
};
|
||||
|
||||
$mtime = filemtime($assetPath);
|
||||
if ($mtime !== false) {
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $mtime) . ' GMT');
|
||||
}
|
||||
header('Content-Type: ' . $contentType);
|
||||
header('Cache-Control: public, max-age=300');
|
||||
readfile($assetPath);
|
||||
Reference in New Issue
Block a user