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

This commit is contained in:
2026-05-05 23:46:23 +02:00
parent e335a8d5bf
commit 48b7583f19
9 changed files with 528 additions and 277 deletions

View File

@@ -5,6 +5,8 @@ $error = null;
$notice = null;
$testGroup = null;
$dbTestMessages = [];
$nexusDebugSettings = modules()->settings(nexus_debug_settings_key());
$nexusDebugEnabled = !empty($nexusDebugSettings['enabled']);
require_admin();
@@ -15,21 +17,6 @@ if (!$module) {
}
$fields = (array)($module['setup']['fields'] ?? []);
$hasGlobalDebugField = false;
foreach ($fields as $field) {
if ((string)($field['name'] ?? '') === 'debug_enabled') {
$hasGlobalDebugField = true;
break;
}
}
if (!$hasGlobalDebugField) {
$fields[] = [
'name' => 'debug_enabled',
'label' => 'Modul-Debug aktivieren',
'type' => 'checkbox',
'help' => 'Wenn aktiv, darf das Modul Debug-Daten sammeln und den Debug-Bereich anzeigen.',
];
}
$fieldTypes = [];
$fieldMeta = [];
foreach ($fields as $field) {
@@ -416,6 +403,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$isSchedulerAutosave = isset($_POST['scheduler_autosave']) && (string) $_POST['scheduler_autosave'] === '1';
$isSchedulerTest = isset($_POST['scheduler_test']) && (string) $_POST['scheduler_test'] === '1';
$payload = [];
$nexusDebugEnabled = isset($_POST['nexus_debug_enabled']);
if ($isSchedulerAutosave || $isSchedulerTest) {
if ($cronTaskDefinitions !== []) {
@@ -576,13 +564,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
}
} else {
modules()->saveSettings($moduleName, $current);
modules()->saveSettings(nexus_debug_settings_key(), ['enabled' => $nexusDebugEnabled]);
if ($isFxRatesSetup && modules()->hasFunction($moduleName, 'save_runtime_settings')) {
module_fn($moduleName, 'save_runtime_settings', $payload);
$current = modules()->settings($moduleName);
}
$refreshSchedulerState();
if (empty($payload['debug_enabled'])) {
module_debug_clear($moduleName);
if (!$nexusDebugEnabled) {
nexus_debug_clear();
}
$notice = 'Setup gespeichert.';
$module = modules()->get($moduleName) ?: $module;
@@ -616,6 +605,22 @@ $activeDbGroup = $testGroup !== null && array_key_exists($testGroup, $dbGroups)
<option value="<?= e((string) $timezoneOption['value']) ?>"><?= e((string) $timezoneOption['label']) ?></option>
<?php endforeach; ?>
</datalist>
<section class="setup-panel">
<div class="setup-panel__head">
<div>
<span class="pill">Nexus</span>
<h2>Debug</h2>
<p class="muted">Aktiviert das projektweite Debug-Popup. Sichtbar und nutzbar nur fuer Benutzer aus der Admin-Gruppe `appadmin`.</p>
</div>
</div>
<div class="setup-grid">
<label class="setup-field muted">
<span>Globales Debug aktivieren</span>
<input type="checkbox" name="nexus_debug_enabled" value="1" <?= $nexusDebugEnabled ? 'checked' : '' ?>>
<small class="muted">Wenn aktiv, sammelt Nexus sitzungsbezogene Debug-Eintraege projektweit und zeigt sie ueber den Bug-Button als Popup an.</small>
</label>
</div>
</section>
<?php if ($isFxRatesSetup): ?>
<?php
$fxCatalog = is_array($current['currency_catalog'] ?? null) ? $current['currency_catalog'] : [];
@@ -776,11 +781,6 @@ $activeDbGroup = $testGroup !== null && array_key_exists($testGroup, $dbGroups)
<small class="muted">Letzter Sync: <?= e((string) $current['currency_catalog_synced_at']) ?></small>
<?php endif; ?>
</div>
<label class="setup-field muted">
<span>Modul-Debug aktivieren</span>
<input type="checkbox" name="debug_enabled" value="1" <?= !empty($current['debug_enabled']) ? 'checked' : '' ?>>
<small class="muted">Wenn aktiv, darf das Modul Debug-Daten sammeln und den Debug-Bereich anzeigen.</small>
</label>
</div>
</section>

View File

@@ -1,4 +1,17 @@
</main>
<?php if (auth_is_admin()): ?>
<?php
$nexusDebugPayload = json_encode([
'enabled' => nexus_debug_enabled(),
'entries' => nexus_debug_entries(),
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
if (!is_string($nexusDebugPayload)) {
$nexusDebugPayload = '{"enabled":false,"entries":[]}';
}
?>
<div id="nexus-debug-root"></div>
<script id="nexus-debug-data" type="application/json"><?= $nexusDebugPayload ?></script>
<?php endif; ?>
<script src="<?= e(app()->assets()->versioned('/assets/js/app.js')) ?>" defer></script>
<?php asset_scripts('footer'); ?>
</body>

View File

@@ -28,6 +28,8 @@ $headerActions = isset($GLOBALS['layout_header_actions']) && is_array($GLOBALS['
: [];
$auth = app()->auth();
$authUser = $auth->user();
$isDebugAdmin = auth_is_admin();
$isNexusDebugEnabled = $isDebugAdmin && nexus_debug_enabled();
?>
<!doctype html>
<html lang="de">
@@ -54,7 +56,7 @@ $authUser = $auth->user();
<?php asset_styles(); ?>
<?php asset_scripts('header'); ?>
</head>
<body>
<body data-nexus-debug-admin="<?= $isDebugAdmin ? '1' : '0' ?>" data-nexus-debug-enabled="<?= $isNexusDebugEnabled ? '1' : '0' ?>">
<main class="main-shell">
<section class="home-hero app-header main-header-box" data-module-name="<?= e((string)($currentModuleName ?? '')) ?>">
<a class="brand-mark" href="/" aria-label="Nexus">