ydcfydf
This commit is contained in:
@@ -26,7 +26,7 @@
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
const initialDebugMode = document.body && document.body.dataset.nexusDebugEnabled === '1';
|
const initialDebugMode = document.body && document.body.dataset.moduleDebugEnabled === '1';
|
||||||
function getCookie(name) {
|
function getCookie(name) {
|
||||||
const pattern = `; ${document.cookie}`;
|
const pattern = `; ${document.cookie}`;
|
||||||
const parts = pattern.split(`; ${name}=`);
|
const parts = pattern.split(`; ${name}=`);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ final class Router
|
|||||||
$this->config = ModuleConfig::load($this->moduleBasePath);
|
$this->config = ModuleConfig::load($this->moduleBasePath);
|
||||||
$requestUri = (string) ($_SERVER['REQUEST_URI'] ?? '');
|
$requestUri = (string) ($_SERVER['REQUEST_URI'] ?? '');
|
||||||
$requestPath = (string) (parse_url($requestUri, PHP_URL_PATH) ?: '');
|
$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';
|
$latestDebugFilePath = rtrim($this->config->debugDir(), '/') . '/latest-server.json';
|
||||||
$isLatestDebugRequest = str_ends_with($requestPath, '/api/mining-checker/v1/debug/latest')
|
$isLatestDebugRequest = str_ends_with($requestPath, '/api/mining-checker/v1/debug/latest')
|
||||||
|| $requestPath === 'api/mining-checker/v1/debug/latest'
|
|| $requestPath === 'api/mining-checker/v1/debug/latest'
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ $error = null;
|
|||||||
$notice = null;
|
$notice = null;
|
||||||
$testGroup = null;
|
$testGroup = null;
|
||||||
$dbTestMessages = [];
|
$dbTestMessages = [];
|
||||||
$nexusDebugSettings = modules()->settings(nexus_debug_settings_key());
|
|
||||||
$nexusDebugEnabled = !empty($nexusDebugSettings['enabled']);
|
|
||||||
|
|
||||||
require_admin();
|
require_admin();
|
||||||
|
|
||||||
@@ -17,6 +15,21 @@ if (!$module) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$fields = (array)($module['setup']['fields'] ?? []);
|
$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 = [];
|
$fieldTypes = [];
|
||||||
$fieldMeta = [];
|
$fieldMeta = [];
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
@@ -403,7 +416,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
$isSchedulerAutosave = isset($_POST['scheduler_autosave']) && (string) $_POST['scheduler_autosave'] === '1';
|
$isSchedulerAutosave = isset($_POST['scheduler_autosave']) && (string) $_POST['scheduler_autosave'] === '1';
|
||||||
$isSchedulerTest = isset($_POST['scheduler_test']) && (string) $_POST['scheduler_test'] === '1';
|
$isSchedulerTest = isset($_POST['scheduler_test']) && (string) $_POST['scheduler_test'] === '1';
|
||||||
$payload = [];
|
$payload = [];
|
||||||
$nexusDebugEnabled = isset($_POST['nexus_debug_enabled']);
|
|
||||||
|
|
||||||
if ($isSchedulerAutosave || $isSchedulerTest) {
|
if ($isSchedulerAutosave || $isSchedulerTest) {
|
||||||
if ($cronTaskDefinitions !== []) {
|
if ($cronTaskDefinitions !== []) {
|
||||||
@@ -564,14 +576,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
modules()->saveSettings($moduleName, $current);
|
modules()->saveSettings($moduleName, $current);
|
||||||
modules()->saveSettings(nexus_debug_settings_key(), ['enabled' => $nexusDebugEnabled]);
|
|
||||||
if ($isFxRatesSetup && modules()->hasFunction($moduleName, 'save_runtime_settings')) {
|
if ($isFxRatesSetup && modules()->hasFunction($moduleName, 'save_runtime_settings')) {
|
||||||
module_fn($moduleName, 'save_runtime_settings', $payload);
|
module_fn($moduleName, 'save_runtime_settings', $payload);
|
||||||
$current = modules()->settings($moduleName);
|
$current = modules()->settings($moduleName);
|
||||||
}
|
}
|
||||||
$refreshSchedulerState();
|
$refreshSchedulerState();
|
||||||
if (!$nexusDebugEnabled) {
|
if (empty($payload['debug_enabled'])) {
|
||||||
nexus_debug_clear();
|
module_debug_clear($moduleName);
|
||||||
}
|
}
|
||||||
$notice = 'Setup gespeichert.';
|
$notice = 'Setup gespeichert.';
|
||||||
$module = modules()->get($moduleName) ?: $module;
|
$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>
|
<option value="<?= e((string) $timezoneOption['value']) ?>"><?= e((string) $timezoneOption['label']) ?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</datalist>
|
</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 if ($isFxRatesSetup): ?>
|
||||||
<?php
|
<?php
|
||||||
$fxCatalog = is_array($current['currency_catalog'] ?? null) ? $current['currency_catalog'] : [];
|
$fxCatalog = is_array($current['currency_catalog'] ?? null) ? $current['currency_catalog'] : [];
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ $auth = app()->auth();
|
|||||||
$authUser = $auth->user();
|
$authUser = $auth->user();
|
||||||
$isDebugAdmin = auth_is_admin();
|
$isDebugAdmin = auth_is_admin();
|
||||||
$isNexusDebugEnabled = $isDebugAdmin && nexus_debug_enabled();
|
$isNexusDebugEnabled = $isDebugAdmin && nexus_debug_enabled();
|
||||||
|
$isCurrentModuleDebugEnabled = $isDebugAdmin && $currentModuleName !== null && module_debug_enabled($currentModuleName);
|
||||||
?>
|
?>
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
@@ -56,7 +57,7 @@ $isNexusDebugEnabled = $isDebugAdmin && nexus_debug_enabled();
|
|||||||
<?php asset_styles(); ?>
|
<?php asset_styles(); ?>
|
||||||
<?php asset_scripts('header'); ?>
|
<?php asset_scripts('header'); ?>
|
||||||
</head>
|
</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">
|
<main class="main-shell">
|
||||||
<section class="home-hero app-header main-header-box" data-module-name="<?= e((string)($currentModuleName ?? '')) ?>">
|
<section class="home-hero app-header main-header-box" data-module-name="<?= e((string)($currentModuleName ?? '')) ?>">
|
||||||
<a class="brand-mark" href="/" aria-label="Nexus">
|
<a class="brand-mark" href="/" aria-label="Nexus">
|
||||||
|
|||||||
@@ -276,29 +276,8 @@ function module_design(string $module): array
|
|||||||
return $cache[$module];
|
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
|
function nexus_debug_enabled(): bool
|
||||||
{
|
{
|
||||||
if (!nexus_debug_configured()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (function_exists('auth_enabled') && auth_enabled()) {
|
if (function_exists('auth_enabled') && auth_enabled()) {
|
||||||
return auth_is_admin();
|
return auth_is_admin();
|
||||||
}
|
}
|
||||||
@@ -363,7 +342,18 @@ function module_debug_enabled(string $module): bool
|
|||||||
return false;
|
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
|
function module_debug_entries(string $module): array
|
||||||
|
|||||||
Reference in New Issue
Block a user