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

This commit is contained in:
2026-06-09 02:24:17 +02:00
parent e68bab8a0f
commit afbb0a13f0
5 changed files with 137 additions and 27 deletions

View File

@@ -74,12 +74,24 @@ return [
'icon' => 'MC', 'icon' => 'MC',
'entry_route' => '/apps/mining-checker', 'entry_route' => '/apps/mining-checker',
'window_mode' => 'window', 'window_mode' => 'window',
'content_mode' => 'iframe', 'content_mode' => 'native-module',
'default_width' => 1180, 'default_width' => 1180,
'default_height' => 760, 'default_height' => 760,
'supports_widget' => false, 'supports_widget' => false,
'supports_tray' => true, 'supports_tray' => true,
'module_name' => 'finance', 'module_name' => 'finance',
'summary' => 'Vollstaendiger Rechner fuer Mining-Profitabilitaet, Stromkosten, ROI und Snapshot-Historie.', 'summary' => 'Vollstaendiger Rechner fuer Mining-Profitabilitaet, Stromkosten, ROI und Snapshot-Historie.',
'module_options' => [
'default_project_key' => 'doge-main',
'active_view' => 'overview',
'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'],
],
],
], ],
]; ];

View File

@@ -20,6 +20,14 @@ $assetVersion = static function (string $publicPath): string {
return $mtime === false ? $publicPath : $publicPath . '?v=' . $mtime; return $mtime === false ? $publicPath : $publicPath . '?v=' . $mtime;
}; };
$hasMiningChecker = false;
foreach ($desktopPayload['apps'] as $desktopApp) {
if (($desktopApp['app_id'] ?? null) === 'mining-checker') {
$hasMiningChecker = true;
break;
}
}
$renderStartIcon = static function (array $profile): string { $renderStartIcon = static function (array $profile): string {
$style = (string) ($profile['taskbar_icon_style'] ?? 'label'); $style = (string) ($profile['taskbar_icon_style'] ?? 'label');
@@ -142,5 +150,11 @@ $renderStartIcon = static function (array $profile): string {
<?php if (!empty($skinProfile['js_path']) && $skinProfile['js_path'] !== $baseSkinProfile['js_path']): ?> <?php if (!empty($skinProfile['js_path']) && $skinProfile['js_path'] !== $baseSkinProfile['js_path']): ?>
<script src="<?= htmlspecialchars($assetVersion((string) $skinProfile['js_path']), ENT_QUOTES) ?>"></script> <script src="<?= htmlspecialchars($assetVersion((string) $skinProfile['js_path']), ENT_QUOTES) ?>"></script>
<?php endif; ?> <?php endif; ?>
<?php if ($hasMiningChecker): ?>
<link rel="stylesheet" href="<?= htmlspecialchars($assetVersion('/assets/apps/mining-checker/app.css'), ENT_QUOTES) ?>">
<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>
<?php endif; ?>
</body> </body>
</html> </html>

View File

@@ -1,32 +1,33 @@
(function () { (function () {
const root = document.getElementById('mining-checker-app'); function boot(root) {
if (!root || !window.React || !window.ReactDOM) { if (!root || !window.React || !window.ReactDOM) {
return; return false;
} }
const h = React.createElement; const h = React.createElement;
const { useEffect, useMemo, useRef, useState } = React; const { useEffect, useMemo, useRef, useState } = React;
const apiBase = root.dataset.apiBase || '/api/mining-checker/v1'; const apiBase = root.dataset.apiBase || '/api/mining-checker/v1';
const initialProjectKey = root.dataset.defaultProjectKey || 'doge-main'; const initialProjectKey = root.dataset.defaultProjectKey || 'doge-main';
const initialActiveTab = String(root.dataset.activeView || 'overview').trim() || 'overview'; const initialActiveTab = String(root.dataset.activeView || 'overview').trim() || 'overview';
const configuredSections = (() => { const configuredSections = (() => {
try { try {
const parsed = JSON.parse(root.dataset.sectionsJson || '[]'); const parsed = JSON.parse(root.dataset.sectionsJson || '[]');
if (!Array.isArray(parsed)) { if (!Array.isArray(parsed)) {
return [];
}
return parsed
.map((section) => {
const key = section && typeof section.key === 'string' ? section.key.trim() : '';
const label = section && typeof section.label === 'string' ? section.label.trim() : '';
return key && label ? [key, label] : null;
})
.filter(Boolean);
} catch (error) {
return []; return [];
} }
return parsed })();
.map((section) => { const initialDebugMode = root.dataset.moduleDebugEnabled === '1'
const key = section && typeof section.key === 'string' ? section.key.trim() : ''; || (document.body && document.body.dataset.moduleDebugEnabled === '1');
const label = section && typeof section.label === 'string' ? section.label.trim() : '';
return key && label ? [key, label] : null;
})
.filter(Boolean);
} catch (error) {
return [];
}
})();
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}=`);
@@ -3184,5 +3185,47 @@
} }
} }
ReactDOM.createRoot(root).render(h(App)); ReactDOM.createRoot(root).render(h(App));
return true;
}
window.initMiningCheckerApp = function initMiningCheckerApp(root, options) {
if (!(root instanceof HTMLElement)) {
return false;
}
const config = options && typeof options === 'object' ? options : {};
if (config.apiBase) {
root.dataset.apiBase = String(config.apiBase);
}
if (config.defaultProjectKey) {
root.dataset.defaultProjectKey = String(config.defaultProjectKey);
}
if (config.activeView) {
root.dataset.activeView = String(config.activeView);
}
if (config.sections) {
root.dataset.sectionsJson = JSON.stringify(config.sections);
}
if (config.moduleDebugEnabled !== undefined) {
root.dataset.moduleDebugEnabled = config.moduleDebugEnabled ? '1' : '0';
}
if (root.dataset.miningCheckerMounted === '1') {
return true;
}
const mounted = boot(root);
if (mounted) {
root.dataset.miningCheckerMounted = '1';
}
return mounted;
};
const root = document.getElementById('mining-checker-app');
if (root) {
window.initMiningCheckerApp(root);
}
})(); })();

View File

@@ -410,6 +410,22 @@ h1 {
background: #ffffff; background: #ffffff;
} }
.window-content--module {
position: relative;
background: #f8fafc;
}
.window-module-host {
position: absolute;
inset: 0;
overflow: auto;
}
.window-module-error {
padding: 18px;
color: #991b1b;
}
.window-embed-fallback { .window-embed-fallback {
position: absolute; position: absolute;
inset: auto 16px 16px 16px; inset: auto 16px 16px 16px;

View File

@@ -108,6 +108,14 @@ if (payloadNode) {
}; };
const buildWindowBody = (definition) => { const buildWindowBody = (definition) => {
if (definition.content_mode === 'native-module' && definition.app_id === 'mining-checker') {
return `
<div class="window-content window-content--embedded window-content--module">
<div class="window-module-host" data-module-app="mining-checker"></div>
</div>
`;
}
if (definition.content_mode === 'iframe' && typeof definition.entry_route === 'string' && definition.entry_route !== '') { if (definition.content_mode === 'iframe' && typeof definition.entry_route === 'string' && definition.entry_route !== '') {
const title = escapeHtml(definition.title); const title = escapeHtml(definition.title);
const src = escapeHtml(definition.entry_route); const src = escapeHtml(definition.entry_route);
@@ -544,6 +552,22 @@ if (payloadNode) {
}, { once: true }); }, { once: true });
} }
const moduleHost = node.querySelector('.window-module-host');
if (moduleHost && definition.content_mode === 'native-module' && definition.app_id === 'mining-checker') {
const moduleOptions = definition.module_options || {};
if (typeof window.initMiningCheckerApp === 'function') {
window.initMiningCheckerApp(moduleHost, {
apiBase: '/api/mining-checker/index.php/v1',
defaultProjectKey: moduleOptions.default_project_key || 'doge-main',
activeView: moduleOptions.active_view || 'overview',
sections: Array.isArray(moduleOptions.sections) ? moduleOptions.sections : [],
moduleDebugEnabled: false,
});
} else {
moduleHost.innerHTML = '<div class="window-module-error">Mining-Checker Assets konnten nicht initialisiert werden.</div>';
}
}
node.querySelectorAll('.window-action').forEach((action) => { node.querySelectorAll('.window-action').forEach((action) => {
action.addEventListener('click', (event) => { action.addEventListener('click', (event) => {
event.stopPropagation(); event.stopPropagation();
@@ -595,6 +619,7 @@ if (payloadNode) {
content: app.summary || '', content: app.summary || '',
entry_route: app.entry_route || '', entry_route: app.entry_route || '',
content_mode: app.content_mode || 'summary', content_mode: app.content_mode || 'summary',
module_options: app.module_options || null,
}); });
}; };