Files
desktop/public/apps/mining-checker/index.php
Lars Gebhardt-Kusche 823c5d197d
All checks were successful
Deploy / deploy-staging (push) Successful in 47s
Deploy / deploy-production (push) Has been skipped
update
2026-06-15 02:38:41 +02:00

114 lines
3.5 KiB
PHP

<?php
declare(strict_types=1);
require_once dirname(__DIR__, 3) . '/src/App/bootstrap.php';
use App\ConfigLoader;
use App\KeycloakAuth;
session_start();
$projectRoot = dirname(__DIR__, 3);
$auth = new KeycloakAuth(ConfigLoader::load($projectRoot, 'keycloak'));
if (!$auth->shouldShowDesktop()) {
header('Location: /auth/keycloak', true, 302);
exit;
}
$assetVersion = static function (string $publicPath) use ($projectRoot): string {
$filesystemPath = $projectRoot . '/public' . $publicPath;
if (!is_file($filesystemPath)) {
return $publicPath;
}
$mtime = filemtime($filesystemPath);
return $mtime === false ? $publicPath : $publicPath . '?v=' . $mtime;
};
$sections = [
['key' => 'overview', 'label' => 'Übersicht'],
['key' => 'upload', 'label' => 'Upload'],
['key' => 'measurements', 'label' => 'Mining-History'],
['key' => 'wallet', 'label' => 'Wallet'],
['key' => 'mining', 'label' => 'Miner-Daten'],
['key' => 'dashboards', 'label' => 'Dashboards'],
];
$defaultProjectKey = getenv('MINING_CHECKER_DEFAULT_PROJECT_KEY') ?: 'doge-main';
$activeView = trim((string) ($_GET['view'] ?? 'overview'));
$sectionKeys = array_values(array_filter(array_map(
static fn (mixed $section): string => is_array($section) ? trim((string) ($section['key'] ?? '')) : '',
$sections
)));
if ($sectionKeys === []) {
$sectionKeys = ['overview'];
}
if (!in_array($activeView, $sectionKeys, true)) {
$activeView = $sectionKeys[0];
}
$sectionsJson = json_encode($sections, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
?><!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Mining-Checker</title>
<style>
:root {
color-scheme: light;
--surface: rgba(255, 255, 255, 0.92);
--line: rgba(148, 163, 184, 0.24);
--text: #0f172a;
--muted: #475569;
--brand-accent: #14b8a6;
--brand-accent-3: #0f766e;
font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}
* {
box-sizing: border-box;
}
html,
body {
min-height: 100%;
}
body {
margin: 0;
background:
radial-gradient(circle at top left, rgba(45, 212, 191, 0.12), transparent 24%),
linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
color: var(--text);
}
.mining-module-shell {
min-height: 100vh;
padding: 18px;
}
</style>
<link rel="stylesheet" href="<?= htmlspecialchars($assetVersion('/assets/apps/mining-checker/app.css'), ENT_QUOTES) ?>">
</head>
<body data-module-debug-enabled="0">
<div class="mining-module-shell">
<div
id="mining-checker-app"
data-default-project-key="<?= htmlspecialchars($defaultProjectKey, ENT_QUOTES) ?>"
data-api-base="/api/mining-checker/index.php/v1"
data-active-view="<?= htmlspecialchars($activeView, ENT_QUOTES) ?>"
data-sections-json="<?= htmlspecialchars(is_string($sectionsJson) ? $sectionsJson : '[]', ENT_QUOTES) ?>"
></div>
</div>
<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 src="<?= htmlspecialchars($assetVersion('/assets/apps/mining-checker/app.js'), ENT_QUOTES) ?>"></script>
</body>
</html>