Files
nexus/modules/mining-checker/pages/index.php
Lars Gebhardt-Kusche e335a8d5bf
All checks were successful
Deploy / deploy-staging (push) Successful in 7s
Deploy / deploy-production (push) Has been skipped
xycyxc
2026-05-05 23:20:29 +02:00

60 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
require_once dirname(__DIR__) . '/bootstrap.php';
$moduleConfig = require dirname(__DIR__) . '/config/module.php';
$design = module_design('mining-checker');
$defaultProjectKey = (string) ($moduleConfig['default_project_key'] ?? 'doge-main');
$sections = is_array($design['sections'] ?? null) ? $design['sections'] : [];
$activeView = trim((string) ($_GET['view'] ?? 'overview'));
$allowedViews = [];
$tabs = [];
foreach ($sections as $section) {
if (!is_array($section)) {
continue;
}
$key = trim((string) ($section['key'] ?? ''));
$label = trim((string) ($section['label'] ?? ''));
if ($key === '' || $label === '') {
continue;
}
$allowedViews[] = $key;
$tabs[] = [
'label' => $label,
'href' => '/module/mining-checker?view=' . rawurlencode($key),
'active' => $activeView === $key,
];
}
if ($allowedViews === []) {
$allowedViews = ['overview'];
}
if (!in_array($activeView, $allowedViews, true)) {
$activeView = $allowedViews[0];
foreach ($tabs as &$tab) {
$tab['active'] = str_ends_with((string) ($tab['href'] ?? ''), 'view=' . $activeView);
}
unset($tab);
}
$sectionsJson = json_encode($sections, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$moduleCss = file_get_contents(dirname(__DIR__) . '/assets/css/app.css') ?: '';
$moduleJs = file_get_contents(dirname(__DIR__) . '/assets/js/app.js') ?: '';
$moduleJs = str_replace('</script>', '<\/script>', $moduleJs);
?>
<?= module_shell_header('mining-checker', [
'title' => 'DOGE Mining-Checker',
'tabs' => $tabs,
]) ?>
<div class="module-flow">
<div id="mining-checker-app"
data-default-project-key="<?= e($defaultProjectKey) ?>"
data-api-base="/api/mining-checker/v1"
data-active-view="<?= e($activeView) ?>"
data-sections-json="<?= e(is_string($sectionsJson) ? $sectionsJson : '[]') ?>"></div>
</div>
<style><?= $moduleCss ?></style>
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<script><?= $moduleJs ?></script>
<?= module_shell_footer() ?>