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

This commit is contained in:
2026-05-06 00:00:37 +02:00
parent 48b7583f19
commit 47757675c2
5 changed files with 33 additions and 47 deletions

View File

@@ -26,7 +26,7 @@
return [];
}
})();
const initialDebugMode = document.body && document.body.dataset.nexusDebugEnabled === '1';
const initialDebugMode = document.body && document.body.dataset.moduleDebugEnabled === '1';
function getCookie(name) {
const pattern = `; ${document.cookie}`;
const parts = pattern.split(`; ${name}=`);

View File

@@ -44,7 +44,7 @@ final class Router
$this->config = ModuleConfig::load($this->moduleBasePath);
$requestUri = (string) ($_SERVER['REQUEST_URI'] ?? '');
$requestPath = (string) (parse_url($requestUri, PHP_URL_PATH) ?: '');
$debugEnabled = function_exists('nexus_debug_enabled') ? nexus_debug_enabled() : false;
$debugEnabled = function_exists('module_debug_enabled') ? module_debug_enabled('mining-checker') : false;
$latestDebugFilePath = rtrim($this->config->debugDir(), '/') . '/latest-server.json';
$isLatestDebugRequest = str_ends_with($requestPath, '/api/mining-checker/v1/debug/latest')
|| $requestPath === 'api/mining-checker/v1/debug/latest'

View File

@@ -5,8 +5,6 @@ $error = null;
$notice = null;
$testGroup = null;
$dbTestMessages = [];
$nexusDebugSettings = modules()->settings(nexus_debug_settings_key());
$nexusDebugEnabled = !empty($nexusDebugSettings['enabled']);
require_admin();
@@ -17,6 +15,21 @@ 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 dieses Modul Debug-Daten in den globalen Nexus-Debugstream schreiben.',
];
}
$fieldTypes = [];
$fieldMeta = [];
foreach ($fields as $field) {
@@ -403,7 +416,6 @@ 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 !== []) {
@@ -564,14 +576,13 @@ 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 (!$nexusDebugEnabled) {
nexus_debug_clear();
if (empty($payload['debug_enabled'])) {
module_debug_clear($moduleName);
}
$notice = 'Setup gespeichert.';
$module = modules()->get($moduleName) ?: $module;
@@ -605,22 +616,6 @@ $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'] : [];

View File

@@ -30,6 +30,7 @@ $auth = app()->auth();
$authUser = $auth->user();
$isDebugAdmin = auth_is_admin();
$isNexusDebugEnabled = $isDebugAdmin && nexus_debug_enabled();
$isCurrentModuleDebugEnabled = $isDebugAdmin && $currentModuleName !== null && module_debug_enabled($currentModuleName);
?>
<!doctype html>
<html lang="de">
@@ -56,7 +57,7 @@ $isNexusDebugEnabled = $isDebugAdmin && nexus_debug_enabled();
<?php asset_styles(); ?>
<?php asset_scripts('header'); ?>
</head>
<body data-nexus-debug-admin="<?= $isDebugAdmin ? '1' : '0' ?>" data-nexus-debug-enabled="<?= $isNexusDebugEnabled ? '1' : '0' ?>">
<body data-nexus-debug-admin="<?= $isDebugAdmin ? '1' : '0' ?>" data-nexus-debug-enabled="<?= $isNexusDebugEnabled ? '1' : '0' ?>" data-module-debug-enabled="<?= $isCurrentModuleDebugEnabled ? '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">

View File

@@ -276,29 +276,8 @@ function module_design(string $module): array
return $cache[$module];
}
function nexus_debug_settings_key(): string
{
return '__nexus_debug__';
}
function nexus_debug_configured(): bool
{
try {
$settings = modules()->settings(nexus_debug_settings_key());
} catch (\Throwable $e) {
return false;
}
$value = $settings['enabled'] ?? '0';
return $value === true || $value === 1 || $value === '1' || $value === 'true';
}
function nexus_debug_enabled(): bool
{
if (!nexus_debug_configured()) {
return false;
}
if (function_exists('auth_enabled') && auth_enabled()) {
return auth_is_admin();
}
@@ -363,7 +342,18 @@ function module_debug_enabled(string $module): bool
return false;
}
return nexus_debug_enabled();
if (!nexus_debug_enabled()) {
return false;
}
try {
$settings = modules()->settings($module);
} catch (\Throwable $e) {
return false;
}
$value = $settings['debug_enabled'] ?? '0';
return $value === true || $value === 1 || $value === '1' || $value === 'true';
}
function module_debug_entries(string $module): array