Spaces:
Sleeping
Sleeping
Aryanshh commited on
Commit ยท
495eca8
1
Parent(s): ab38db6
feat: Add interactive controls to Eco-HUD
Browse files- dashboard/app.js +38 -0
- dashboard/index.html +5 -1
- dashboard/style.css +35 -0
dashboard/app.js
CHANGED
|
@@ -37,6 +37,44 @@ async function updateState() {
|
|
| 37 |
}
|
| 38 |
}
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
// Poll every 2 seconds
|
| 41 |
setInterval(updateState, 2000);
|
| 42 |
updateState();
|
|
|
|
| 37 |
}
|
| 38 |
}
|
| 39 |
|
| 40 |
+
// Actions
|
| 41 |
+
async function manualStep() {
|
| 42 |
+
try {
|
| 43 |
+
const btn = document.getElementById('step-btn');
|
| 44 |
+
btn.disabled = true;
|
| 45 |
+
btn.textContent = 'Wait...';
|
| 46 |
+
|
| 47 |
+
// Send a default SKIP action for testing
|
| 48 |
+
const response = await fetch(`${API_BASE}/step`, {
|
| 49 |
+
method: 'POST',
|
| 50 |
+
headers: { 'Content-Type': 'application/json' },
|
| 51 |
+
body: JSON.stringify({ action_type: 'skip' })
|
| 52 |
+
});
|
| 53 |
+
|
| 54 |
+
await updateState();
|
| 55 |
+
btn.disabled = false;
|
| 56 |
+
btn.textContent = 'Next Day (Step)';
|
| 57 |
+
} catch (error) {
|
| 58 |
+
console.error('Step failed:', error);
|
| 59 |
+
}
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
async function manualReset() {
|
| 63 |
+
try {
|
| 64 |
+
await fetch(`${API_BASE}/reset`, {
|
| 65 |
+
method: 'POST',
|
| 66 |
+
headers: { 'Content-Type': 'application/json' },
|
| 67 |
+
body: JSON.stringify({ task: 'easy' })
|
| 68 |
+
});
|
| 69 |
+
await updateState();
|
| 70 |
+
} catch (error) {
|
| 71 |
+
console.error('Reset failed:', error);
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
document.getElementById('step-btn').addEventListener('click', manualStep);
|
| 76 |
+
document.getElementById('reset-btn').addEventListener('click', manualReset);
|
| 77 |
+
|
| 78 |
// Poll every 2 seconds
|
| 79 |
setInterval(updateState, 2000);
|
| 80 |
updateState();
|
dashboard/index.html
CHANGED
|
@@ -14,7 +14,11 @@
|
|
| 14 |
<span class="icon">๐</span>
|
| 15 |
<h1>NETZERO-NAV</h1>
|
| 16 |
</div>
|
| 17 |
-
<div
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
</header>
|
| 19 |
|
| 20 |
<main>
|
|
|
|
| 14 |
<span class="icon">๐</span>
|
| 15 |
<h1>NETZERO-NAV</h1>
|
| 16 |
</div>
|
| 17 |
+
<div class="controls">
|
| 18 |
+
<button id="reset-btn" class="btn btn-outline">Reset</button>
|
| 19 |
+
<button id="step-btn" class="btn btn-primary">Next Day (Step)</button>
|
| 20 |
+
<div id="connection-status" class="status-badge">Connecting...</div>
|
| 21 |
+
</div>
|
| 22 |
</header>
|
| 23 |
|
| 24 |
<main>
|
dashboard/style.css
CHANGED
|
@@ -51,6 +51,41 @@ header {
|
|
| 51 |
color: var(--deep-forest);
|
| 52 |
}
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
.status-badge {
|
| 55 |
background: var(--border-tan);
|
| 56 |
padding: 0.5rem 1rem;
|
|
|
|
| 51 |
color: var(--deep-forest);
|
| 52 |
}
|
| 53 |
|
| 54 |
+
.controls {
|
| 55 |
+
display: flex;
|
| 56 |
+
align-items: center;
|
| 57 |
+
gap: 1rem;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
.btn {
|
| 61 |
+
padding: 0.6rem 1.2rem;
|
| 62 |
+
border-radius: 8px;
|
| 63 |
+
font-size: 0.85rem;
|
| 64 |
+
font-weight: 600;
|
| 65 |
+
cursor: pointer;
|
| 66 |
+
transition: all 0.2s ease;
|
| 67 |
+
border: none;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
.btn-primary {
|
| 71 |
+
background-color: var(--primary-green);
|
| 72 |
+
color: white;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
.btn-primary:hover {
|
| 76 |
+
background-color: var(--deep-forest);
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
.btn-outline {
|
| 80 |
+
background-color: transparent;
|
| 81 |
+
border: 1.5px solid var(--primary-green);
|
| 82 |
+
color: var(--primary-green);
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
.btn-outline:hover {
|
| 86 |
+
background-color: #E1F5E1;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
.status-badge {
|
| 90 |
background: var(--border-tan);
|
| 91 |
padding: 0.5rem 1rem;
|