Add PWA support and miner race
7
apps/web/public/icons/icon.svg
Normal file
@@ -0,0 +1,7 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" role="img" aria-label="gashboard">
|
||||
<rect width="512" height="512" fill="#07090f"/>
|
||||
<rect x="34" y="34" width="444" height="444" fill="#0c1120" stroke="#29ffe6" stroke-width="12"/>
|
||||
<path d="M98 314h68v74H98zm92-118h68v192h-68zm92 54h68v138h-68zm92-126h68v264h-68z" fill="#ff3df0"/>
|
||||
<path d="M80 256h64l34-82 62 178 58-132 44 70h90" fill="none" stroke="#29ffe6" stroke-width="18" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<text x="256" y="104" text-anchor="middle" fill="#ffd84a" font-family="monospace" font-size="54" font-weight="700">G</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 630 B |
7
apps/web/public/icons/maskable.svg
Normal file
@@ -0,0 +1,7 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" role="img" aria-label="gashboard">
|
||||
<rect width="512" height="512" fill="#07090f"/>
|
||||
<circle cx="256" cy="256" r="188" fill="#0c1120" stroke="#29ffe6" stroke-width="14"/>
|
||||
<path d="M126 316h62v72h-62zm84-118h62v190h-62zm84 52h62v138h-62zm84-126h62v264h-62z" fill="#ff3df0"/>
|
||||
<path d="M104 258h66l32-82 60 176 58-132 44 70h54" fill="none" stroke="#29ffe6" stroke-width="18" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<text x="256" y="112" text-anchor="middle" fill="#ffd84a" font-family="monospace" font-size="52" font-weight="700">G</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 622 B |
34
apps/web/public/manifest.webmanifest
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "gashboard",
|
||||
"short_name": "gashboard",
|
||||
"description": "Solo mining dashboard for Datum miners.",
|
||||
"start_url": "/",
|
||||
"scope": "/",
|
||||
"display": "standalone",
|
||||
"orientation": "portrait-primary",
|
||||
"background_color": "#07090f",
|
||||
"theme_color": "#0a0e1a",
|
||||
"categories": ["utilities", "finance"],
|
||||
"icons": [
|
||||
{
|
||||
"src": "/icons/icon.svg",
|
||||
"sizes": "any",
|
||||
"type": "image/svg+xml",
|
||||
"purpose": "any"
|
||||
},
|
||||
{
|
||||
"src": "/icons/maskable.svg",
|
||||
"sizes": "any",
|
||||
"type": "image/svg+xml",
|
||||
"purpose": "maskable"
|
||||
}
|
||||
],
|
||||
"shortcuts": [
|
||||
{
|
||||
"name": "Graphs",
|
||||
"short_name": "Graphs",
|
||||
"url": "/graphs",
|
||||
"description": "Open telemetry graphs"
|
||||
}
|
||||
]
|
||||
}
|
||||
14
apps/web/public/miners/avalon-mini-3.svg
Normal file
@@ -0,0 +1,14 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 420 220" role="img" aria-label="Avalon Mini 3 miner">
|
||||
<rect width="420" height="220" fill="none"/>
|
||||
<g filter="url(#g)">
|
||||
<rect x="44" y="56" width="332" height="110" rx="16" fill="#1f2937" stroke="#ff3df0" stroke-width="4"/>
|
||||
<rect x="70" y="78" width="210" height="66" rx="8" fill="#0b0f19" stroke="#29ffe6" stroke-width="3"/>
|
||||
<path d="M92 96h166M92 112h166M92 128h166" stroke="#475569" stroke-width="7" stroke-linecap="round"/>
|
||||
<circle cx="326" cy="111" r="34" fill="#07090f" stroke="#ffd84a" stroke-width="5"/>
|
||||
<path d="M326 78v66M293 111h66M303 88l46 46M349 88l-46 46" stroke="#6cff8c" stroke-width="4"/>
|
||||
<path d="M76 166h268M104 184h212" stroke="#475569" stroke-width="8" stroke-linecap="round"/>
|
||||
<circle cx="62" cy="74" r="6" fill="#29ffe6"/>
|
||||
<circle cx="360" cy="74" r="6" fill="#ff3df0"/>
|
||||
</g>
|
||||
<defs><filter id="g"><feDropShadow dx="0" dy="9" stdDeviation="9" flood-color="#000" flood-opacity=".55"/></filter></defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1023 B |
12
apps/web/public/miners/avalon-nano-3.svg
Normal file
@@ -0,0 +1,12 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 220" role="img" aria-label="Avalon Nano 3 miner">
|
||||
<rect width="320" height="220" fill="none"/>
|
||||
<g filter="url(#g)">
|
||||
<rect x="76" y="44" width="168" height="128" rx="20" fill="#e7edf5" stroke="#29ffe6" stroke-width="4"/>
|
||||
<rect x="96" y="64" width="128" height="88" rx="14" fill="#111827"/>
|
||||
<circle cx="160" cy="108" r="42" fill="#07090f" stroke="#ff3df0" stroke-width="6"/>
|
||||
<path d="M160 68c16 22 16 58 0 80M120 108c22-16 58-16 80 0M132 80c30 4 52 26 56 56M188 80c-4 30-26 52-56 56" stroke="#29ffe6" stroke-width="4" stroke-linecap="round"/>
|
||||
<rect x="112" y="166" width="96" height="12" rx="6" fill="#475569"/>
|
||||
<path d="M64 112h28M228 112h28" stroke="#ffd84a" stroke-width="8" stroke-linecap="round"/>
|
||||
</g>
|
||||
<defs><filter id="g"><feDropShadow dx="0" dy="8" stdDeviation="8" flood-color="#000" flood-opacity=".45"/></filter></defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 925 B |
15
apps/web/public/miners/bitaxe.svg
Normal file
@@ -0,0 +1,15 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 220" role="img" aria-label="Bitaxe miner">
|
||||
<rect width="320" height="220" fill="none"/>
|
||||
<g filter="url(#g)">
|
||||
<rect x="72" y="70" width="176" height="84" rx="12" fill="#152033" stroke="#6cff8c" stroke-width="4"/>
|
||||
<rect x="94" y="88" width="56" height="48" rx="6" fill="#0b0f19" stroke="#29ffe6" stroke-width="3"/>
|
||||
<circle cx="122" cy="112" r="18" fill="#07090f" stroke="#ff3df0" stroke-width="5"/>
|
||||
<path d="M122 94v36M104 112h36" stroke="#ffd84a" stroke-width="3"/>
|
||||
<rect x="166" y="90" width="54" height="18" rx="3" fill="#29ffe6" opacity=".85"/>
|
||||
<rect x="166" y="118" width="38" height="10" rx="3" fill="#ff3df0" opacity=".85"/>
|
||||
<path d="M86 154h148M104 170h112" stroke="#475569" stroke-width="7" stroke-linecap="round"/>
|
||||
<circle cx="80" cy="80" r="5" fill="#ffd84a"/>
|
||||
<circle cx="240" cy="80" r="5" fill="#ffd84a"/>
|
||||
</g>
|
||||
<defs><filter id="g"><feDropShadow dx="0" dy="8" stdDeviation="8" flood-color="#000" flood-opacity=".55"/></filter></defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
12
apps/web/public/miners/boomer-heater.svg
Normal file
@@ -0,0 +1,12 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 220" role="img" aria-label="Boomer Heater">
|
||||
<rect width="320" height="220" fill="none"/>
|
||||
<g filter="url(#g)">
|
||||
<rect x="72" y="48" width="176" height="132" rx="14" fill="#3b2f2f" stroke="#ff4f78" stroke-width="4"/>
|
||||
<rect x="92" y="70" width="136" height="84" rx="8" fill="#1f1717"/>
|
||||
<path d="M116 142c-18-28 18-36 0-64M160 142c-18-28 18-36 0-64M204 142c-18-28 18-36 0-64" fill="none" stroke="#ff8a4f" stroke-width="8" stroke-linecap="round"/>
|
||||
<path d="M90 180h140" stroke="#475569" stroke-width="10" stroke-linecap="round"/>
|
||||
<circle cx="224" cy="58" r="9" fill="#6a7aa0"/>
|
||||
<text x="160" y="205" text-anchor="middle" fill="#6a7aa0" font-family="monospace" font-size="15" font-weight="700">NO HASHES. JUST HEAT.</text>
|
||||
</g>
|
||||
<defs><filter id="g"><feDropShadow dx="0" dy="8" stdDeviation="8" flood-color="#000" flood-opacity=".55"/></filter></defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 940 B |
15
apps/web/public/miners/nerdqaxe.svg
Normal file
@@ -0,0 +1,15 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 220" role="img" aria-label="NerdQAxe miner">
|
||||
<rect width="320" height="220" fill="none"/>
|
||||
<g filter="url(#g)">
|
||||
<rect x="58" y="54" width="204" height="112" rx="10" fill="#111827" stroke="#29ffe6" stroke-width="4"/>
|
||||
<rect x="78" y="74" width="74" height="70" rx="6" fill="#2a102b" stroke="#ff3df0" stroke-width="3"/>
|
||||
<circle cx="115" cy="109" r="28" fill="#07090f" stroke="#29ffe6" stroke-width="5"/>
|
||||
<path d="M115 82v54M88 109h54M96 90l38 38M134 90l-38 38" stroke="#6cff8c" stroke-width="3"/>
|
||||
<rect x="170" y="76" width="70" height="28" rx="4" fill="#05070c" stroke="#ffd84a" stroke-width="3"/>
|
||||
<path d="M180 92h50" stroke="#ffd84a" stroke-width="4"/>
|
||||
<path d="M72 166h176M88 184h144" stroke="#475569" stroke-width="8" stroke-linecap="round"/>
|
||||
<circle cx="81" cy="58" r="8" fill="#ff3df0"/>
|
||||
<circle cx="239" cy="58" r="8" fill="#29ffe6"/>
|
||||
</g>
|
||||
<defs><filter id="g"><feDropShadow dx="0" dy="8" stdDeviation="8" flood-color="#000" flood-opacity=".55"/></filter></defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
74
apps/web/public/sw.js
Normal file
@@ -0,0 +1,74 @@
|
||||
const CACHE_VERSION = "gashboard-pwa-v1";
|
||||
const APP_SHELL = ["/", "/manifest.webmanifest", "/icons/icon.svg", "/icons/maskable.svg"];
|
||||
const MINER_ASSETS = [
|
||||
"/miners/nerdqaxe.svg",
|
||||
"/miners/bitaxe.svg",
|
||||
"/miners/avalon-nano-3.svg",
|
||||
"/miners/avalon-mini-3.svg",
|
||||
"/miners/boomer-heater.svg",
|
||||
];
|
||||
|
||||
self.addEventListener("install", (event) => {
|
||||
event.waitUntil(caches.open(CACHE_VERSION).then((cache) => cache.addAll([...APP_SHELL, ...MINER_ASSETS])));
|
||||
self.skipWaiting();
|
||||
});
|
||||
|
||||
self.addEventListener("activate", (event) => {
|
||||
event.waitUntil(
|
||||
caches
|
||||
.keys()
|
||||
.then((keys) => Promise.all(keys.filter((key) => key !== CACHE_VERSION).map((key) => caches.delete(key))))
|
||||
.then(() => self.clients.claim()),
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener("fetch", (event) => {
|
||||
const req = event.request;
|
||||
if (req.method !== "GET") return;
|
||||
|
||||
const url = new URL(req.url);
|
||||
if (url.origin !== self.location.origin) return;
|
||||
if (url.pathname.startsWith("/api/") || url.pathname === "/healthz") return;
|
||||
|
||||
if (req.mode === "navigate") {
|
||||
event.respondWith(networkFirst(req, "/"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (url.pathname.startsWith("/assets/") || url.pathname.startsWith("/icons/")) {
|
||||
event.respondWith(cacheFirst(req));
|
||||
return;
|
||||
}
|
||||
|
||||
event.respondWith(networkFirst(req));
|
||||
});
|
||||
|
||||
self.addEventListener("message", (event) => {
|
||||
if (event.data?.type === "SKIP_WAITING") self.skipWaiting();
|
||||
});
|
||||
|
||||
async function cacheFirst(req) {
|
||||
const cache = await caches.open(CACHE_VERSION);
|
||||
const cached = await cache.match(req);
|
||||
if (cached) return cached;
|
||||
const res = await fetch(req);
|
||||
if (res.ok) cache.put(req, res.clone());
|
||||
return res;
|
||||
}
|
||||
|
||||
async function networkFirst(req, fallbackPath) {
|
||||
const cache = await caches.open(CACHE_VERSION);
|
||||
try {
|
||||
const res = await fetch(req);
|
||||
if (res.ok) cache.put(req, res.clone());
|
||||
return res;
|
||||
} catch {
|
||||
const cached = await cache.match(req);
|
||||
if (cached) return cached;
|
||||
if (fallbackPath) {
|
||||
const fallback = await cache.match(fallbackPath);
|
||||
if (fallback) return fallback;
|
||||
}
|
||||
throw new Error("offline");
|
||||
}
|
||||
}
|
||||