Refactor upgrade, scale, and WiFi pages for improved UI and functionality

- Updated page titles and structure for clarity.
- Enhanced sidebar navigation and status indicators.
- Improved form styling and user feedback during updates.
- Added WebSocket handling for real-time status updates.
- Streamlined version fetching logic across pages.
This commit is contained in:
Manuel Weiser committed 2026-02-21 10:49:59 +01:00
1 parent 4a7d3318a2
commit 526b25ba1e
7 files changed
+595 -1432

No files matched your search

+2 -1
View File
@@ -30,4 +30,5 @@ html/spoolman_url.json
_local/*
website/*
release.sh
wiki
wiki
_layout
+73 -59
View File
@@ -3,81 +3,95 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FilaMan - Filament Management Tool</title>
<title>FilaMan - Filament Management</title>
<link rel="icon" type="image/png" href="/favicon.ico">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="fm-page">
<aside class="fm-sidebar">
<div class="sidebar-brand">
<img src="/logo.png" alt="Logo" class="sidebar-logo">
<div class="brand-text">
<h1>FilaMan <span class="version"></span></h1>
</div>
</div>
<nav class="fm-nav">
<a href="/" class="active">Start</a>
<a href="/waage">Scale</a>
<a href="/setup">Setup</a>
<a href="/upgrade">Upgrade</a>
</nav>
<div class="sidebar-status">
<div class="status-item">
<span class="status-dot" id="filamanDot"></span>
<span>System Sync</span>
</div>
<div class="status-item">
<span id="ramStatus"></span>
</div>
</div>
</aside>
<main class="fm-main">
<header>
<h1>Welcome to FilaMan</h1>
<p>Your smart solution for <strong>Filament Management</strong> in 3D printing.</p>
</header>
<div class="fm-card" style="border-color: var(--accent-3); background: rgba(247, 200, 106, 0.05);">
<h3 style="color: var(--accent-3);">System Compatibility</h3>
<p>
Starting with <strong>Version 3.0.0</strong>, this scale is exclusively designed for use with the
<a href="https://github.com/Fire-Devils/filaman-system" target="_blank" style="color: var(--accent-2); text-decoration: underline;">FilaMan-System</a>.
</p>
</div>
<div class="fm-card">
<h2>About FilaMan</h2>
<p>
FilaMan is designed to simplify filament spool management. Identify and weigh your spools
automatically and keep your inventory synced with the FilaMan-System.
</p>
<a href="https://www.filaman.app" target="_blank" class="fm-btn fm-btn-outline">Visit Website</a>
</div>
<div class="features-grid">
<div class="fm-card fm-card-hover">
<h3>Spool Identification</h3>
<p>Easily identify filament spools using NFC tags for instant tracking.</p>
</div>
<div class="fm-card fm-card-hover">
<h3>Automatic Sync</h3>
<p>Seamlessly update spool data with the FilaMan API for accurate tracking.</p>
</div>
<div class="fm-card fm-card-hover">
<h3>Scale Integration</h3>
<p>Built-in scale support for precise remaining weight calculation.</p>
</div>
</div>
</main>
</div>
<script>
// Fetch Version
fetch('/api/version')
.then(response => response.json())
.then(data => {
const versionSpan = document.querySelector('.version');
if (versionSpan) {
versionSpan.textContent = 'v' + data.version;
}
if (versionSpan) versionSpan.textContent = 'v' + data.version;
})
.catch(error => console.error('Error fetching version:', error));
</script>
</head>
<body>
<div class="navbar">
<div style="display: flex; align-items: center; gap: 2rem;">
<img src="/logo.png" alt="FilaMan Logo" class="logo">
<div class="logo-text">
<h1>FilaMan<span class="version"></span></h1>
<h4>Filament Management Tool</h4>
</div>
</div>
<nav style="display: flex; gap: 1rem;">
<a href="/">Start</a>
<a href="/waage">Scale</a>
<a href="/setup">Setup</a>
<a href="/upgrade">Upgrade</a>
</nav>
<div class="status-container">
<div class="status-item">
<span class="status-dot" id="filamanDot"></span>F
</div>
<div class="ram-status" id="ramStatus"></div>
</div>
</div>
<div class="content">
<h1>FilaMan</h1>
<p>Filament Management Tool</p>
<p>Your smart solution for <strong>Filament Management</strong> in 3D printing.</p>
<h2>About FilaMan</h2>
<p>
FilaMan is a tool designed to simplify filament spool management. It allows you to identify and weigh filament spools,
automatically syncing data with the FilaMan-System.
</p>
<p>Get more information at <a href="https://www.filaman.app" target="_blank">https://www.filaman.app</a>.</p>
<div class="features">
<div class="feature">
<h3>Spool Identification</h3>
<p>Easily identify filament spools using NFC tags.</p>
</div>
<div class="feature">
<h3>Automatic Syncing</h3>
<p>Seamlessly update spool data with the FilaMan API for accurate tracking.</p>
</div>
<div class="feature">
<h3>Scale Integration</h3>
<p>Built-in scale support for precise remaining weight calculation.</p>
</div>
</div>
</div>
<script>
// WebSocket handling
let ws = null;
function connectWebSocket() {
ws = new WebSocket(`ws://${window.location.hostname}/ws`);
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
if (data.type === 'heartbeat') {
document.getElementById('filamanDot').style.backgroundColor = data.filaman_connected ? '#4caf50' : '#f44336';
const dot = document.getElementById('filamanDot');
dot.className = data.filaman_connected ? 'status-dot online' : 'status-dot offline';
document.getElementById('ramStatus').textContent = data.freeHeap + ' KB free';
}
};
+84 -60
View File
@@ -3,79 +3,86 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FilaMan - Setup</title>
<title>FilaMan - Device Setup</title>
<link rel="icon" type="image/png" href="/favicon.ico">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="fm-page">
<aside class="fm-sidebar">
<div class="sidebar-brand">
<img src="/logo.png" alt="Logo" class="sidebar-logo">
<div class="brand-text">
<h1>FilaMan <span class="version"></span></h1>
</div>
</div>
<nav class="fm-nav">
<a href="/">Start</a>
<a href="/waage">Scale</a>
<a href="/setup" class="active">Setup</a>
<a href="/upgrade">Upgrade</a>
</nav>
<div class="sidebar-status">
<div class="status-item">
<span class="status-dot" id="filamanDot"></span>
<span>System Sync</span>
</div>
<div class="status-item">
<span id="ramStatus"></span>
</div>
</div>
</aside>
<main class="fm-main">
<header>
<h1>Device Setup</h1>
<p>Register your device to connect it with your FilaMan-System account.</p>
</header>
<div class="fm-card">
<h2>System Registration</h2>
<p>Current Status: <strong style="color: var(--accent);">{{registered}}</strong></p>
<div class="fm-form-group" style="margin-top: 2rem;">
<label class="fm-label" for="filamanUrl">FilaMan API URL</label>
<input type="text" id="filamanUrl" class="fm-input" value="{{filamanUrl}}" placeholder="e.g. http://192.168.1.10:8000">
</div>
<div class="fm-form-group">
<label class="fm-label" for="deviceCode">Registration Code</label>
<input type="text" id="deviceCode" class="fm-input" maxlength="6" placeholder="6-digit code">
<p style="font-size: 0.8rem; margin-top: 0.5rem;">Enter the 6-digit code shown in your FilaMan Dashboard.</p>
</div>
<button id="registerBtn" class="fm-btn fm-btn-primary">Register Device</button>
<div id="statusMessage" style="margin-top: 1.5rem;"></div>
</div>
</main>
</div>
<script>
// Fetch Version
fetch('/api/version')
.then(response => response.json())
.then(data => {
const versionSpan = document.querySelector('.version');
if (versionSpan) {
versionSpan.textContent = 'v' + data.version;
}
if (versionSpan) versionSpan.textContent = 'v' + data.version;
})
.catch(error => console.error('Error fetching version:', error));
</script>
</head>
<body>
<div class="navbar">
<div style="display: flex; align-items: center; gap: 2rem;">
<img src="/logo.png" alt="FilaMan Logo" class="logo">
<div class="logo-text">
<h1>FilaMan<span class="version"></span></h1>
<h4>Filament Management Tool</h4>
</div>
</div>
<nav style="display: flex; gap: 1rem;">
<a href="/">Start</a>
<a href="/waage">Scale</a>
<a href="/setup">Setup</a>
<a href="/upgrade">Upgrade</a>
</nav>
<div class="status-container">
<div class="status-item">
<span class="status-dot" id="filamanDot"></span>F
</div>
<div class="ram-status" id="ramStatus"></div>
</div>
</div>
<div class="content">
<h1>Device Setup</h1>
<div class="card">
<div class="card-body">
<h5 class="card-title">Registration</h5>
<p>Status: <strong>{{registered}}</strong></p>
<div class="form-group">
<label for="filamanUrl">FilaMan API URL:</label>
<input type="text" id="filamanUrl" class="form-control" value="{{filamanUrl}}" placeholder="http://192.168.1.10:8000">
</div>
<div class="form-group mt-2">
<label for="deviceCode">Registration Code (6 digits):</label>
<input type="text" id="deviceCode" class="form-control" maxlength="6" placeholder="123456">
</div>
<button id="registerBtn" class="btn btn-primary mt-3">Register Device</button>
<div id="statusMessage" class="mt-3"></div>
</div>
</div>
</div>
<script>
document.getElementById('registerBtn').addEventListener('click', () => {
const url = document.getElementById('filamanUrl').value;
const code = document.getElementById('deviceCode').value;
const statusMessage = document.getElementById('statusMessage');
if (!url || !code) {
statusMessage.innerHTML = 'Please provide both URL and Code';
statusMessage.className = 'alert alert-danger';
statusMessage.textContent = 'Please provide both URL and Code';
statusMessage.style.color = 'var(--error-text)';
return;
}
statusMessage.innerHTML = 'Registering...';
statusMessage.className = 'alert alert-info';
statusMessage.textContent = 'Registering device...';
statusMessage.style.color = 'var(--text-muted)';
fetch('/api/register', {
method: 'POST',
@@ -85,20 +92,37 @@
.then(response => response.json())
.then(data => {
if (data.success) {
statusMessage.innerHTML = 'Registration successful! Rebooting...';
statusMessage.className = 'alert alert-success';
statusMessage.textContent = 'Registration successful! Rebooting...';
statusMessage.style.color = 'var(--success-text)';
setTimeout(() => fetch('/reboot'), 2000);
} else {
statusMessage.innerHTML = 'Registration failed. Check code and URL.';
statusMessage.className = 'alert alert-danger';
statusMessage.textContent = 'Registration failed. Please check your code and URL.';
statusMessage.style.color = 'var(--error-text)';
}
})
.catch(error => {
console.error('Error:', error);
statusMessage.innerHTML = 'Network error.';
statusMessage.className = 'alert alert-danger';
statusMessage.textContent = 'Network error. Please check connection.';
statusMessage.style.color = 'var(--error-text)';
});
});
// WebSocket handling
let ws = null;
function connectWebSocket() {
ws = new WebSocket(`ws://${window.location.hostname}/ws`);
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
if (data.type === 'heartbeat') {
const dot = document.getElementById('filamanDot');
dot.className = data.filaman_connected ? 'status-dot online' : 'status-dot offline';
document.getElementById('ramStatus').textContent = data.freeHeap + ' KB free';
}
};
ws.onclose = () => setTimeout(connectWebSocket, 2000);
}
connectWebSocket();
setInterval(() => { if(ws && ws.readyState === WebSocket.OPEN) ws.send(JSON.stringify({type:'heartbeat'})); }, 5000);
</script>
</body>
</html>
+223 -1135
View File
File diff suppressed because it is too large. Load diff
+83 -77
View File
@@ -3,85 +3,94 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FilaMan - Filament Management Tool</title>
<title>FilaMan - Firmware Upgrade</title>
<link rel="icon" type="image/png" href="/favicon.ico">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="fm-page">
<aside class="fm-sidebar">
<div class="sidebar-brand">
<img src="/logo.png" alt="Logo" class="sidebar-logo">
<div class="brand-text">
<h1>FilaMan <span class="version"></span></h1>
</div>
</div>
<nav class="fm-nav">
<a href="/">Start</a>
<a href="/waage">Scale</a>
<a href="/setup">Setup</a>
<a href="/upgrade" class="active">Upgrade</a>
</nav>
<div class="sidebar-status">
<div class="status-item">
<span class="status-dot" id="filamanDot"></span>
<span>System Sync</span>
</div>
<div class="status-item">
<span id="ramStatus"></span>
</div>
</div>
</aside>
<main class="fm-main">
<header>
<h1>Firmware Upgrade</h1>
<p>Keep your device up to date with the latest features and security improvements.</p>
</header>
<div class="fm-card" style="border-color: var(--accent-3);">
<h3 style="color: var(--accent-3);">Important Warning</h3>
<p>Do <strong>not</strong> power off the device during the update process. A failed update may require manual recovery.</p>
</div>
<div class="features-grid">
<div class="fm-card">
<h2>Firmware Update</h2>
<p>Upload a new binary firmware file.</p>
<form id="firmwareForm" enctype='multipart/form-data' data-type="firmware">
<div class="fm-form-group">
<input type='file' name='update' accept='.bin' required class="fm-input">
</div>
<input type='submit' value='Start Update' class="fm-btn fm-btn-primary" style="width: 100%;">
</form>
</div>
<div class="fm-card">
<h2>Webpage Update</h2>
<p>Update the internal web interface assets.</p>
<form id="webpageForm" enctype='multipart/form-data' data-type="webpage">
<div class="fm-form-group">
<input type='file' name='update' accept='.bin' required class="fm-input">
</div>
<input type='submit' value='Start Update' class="fm-btn fm-btn-outline" style="width: 100%;">
</form>
</div>
</div>
<div id="progressContainer" class="fm-card" style="display: none; margin-top: 2rem;">
<h3 id="updateStatus">Update in progress...</h3>
<div style="width: 100%; background: var(--bg); height: 24px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); margin: 1rem 0;">
<div id="progressBar" style="width: 0%; height: 100%; background: var(--accent); transition: width 0.3s ease;"></div>
</div>
<p id="detailedStatus" style="font-size: 0.85rem;"></p>
</div>
</main>
</div>
<script>
// Fetch Version
fetch('/api/version')
.then(response => response.json())
.then(data => {
const versionSpan = document.querySelector('.version');
if (versionSpan) {
versionSpan.textContent = 'v' + data.version;
}
if (versionSpan) versionSpan.textContent = 'v' + data.version;
})
.catch(error => console.error('Error fetching version:', error));
</script>
</head>
<body>
<div class="navbar">
<div style="display: flex; align-items: center; gap: 2rem;">
<img src="/logo.png" alt="FilaMan Logo" class="logo">
<div class="logo-text">
<h1>FilaMan<span class="version"></span></h1>
<h4>Filament Management Tool</h4>
</div>
</div>
<nav style="display: flex; gap: 1rem;">
<a href="/">Start</a>
<a href="/waage">Scale</a>
<a href="/setup">Setup</a>
<a href="/upgrade">Upgrade</a>
</nav>
<div class="status-container">
<div class="status-item">
<span class="status-dot" id="filamanDot"></span>F
</div>
<div class="ram-status" id="ramStatus"></div>
</div>
</div>
<div class="content">
<h1>Firmware Upgrade</h1>
<div class="warning">
<strong>Warning:</strong> Do not power off the device during update.
</div>
<div class="update-options">
<div class="update-section">
<h2>1) Firmware Update</h2>
<p>Upload a new firmware file (upgrade_filaman_firmware_*.bin)</p>
<div class="update-form">
<form id="firmwareForm" enctype='multipart/form-data' data-type="firmware">
<input type='file' name='update' accept='.bin' required>
<input type='submit' value='Start Firmware Update' class="btn btn-primary">
</form>
</div>
</div>
<div class="update-section">
<h2>2) Webpage Update</h2>
<p>Upload a new webpage file (upgrade_filaman_website_*.bin)</p>
<div class="update-form">
<form id="webpageForm" enctype='multipart/form-data' data-type="webpage">
<input type='file' name='update' accept='.bin' required>
<input type='submit' value='Start Webpage Update' class="btn btn-primary">
</form>
</div>
</div>
</div>
<div class="progress-container" style="display: none;">
<div class="progress-bar">0%</div>
</div>
<div class="status"></div>
</div>
<script>
const progress = document.querySelector('.progress-bar');
const progressContainer = document.querySelector('.progress-container');
const status = document.querySelector('.status');
const progress = document.getElementById('progressBar');
const progressContainer = document.getElementById('progressContainer');
const status = document.getElementById('detailedStatus');
let updateInProgress = false;
let lastReceivedProgress = 0;
@@ -92,7 +101,8 @@
ws.onmessage = function(event) {
const data = JSON.parse(event.data);
if (data.type === "heartbeat") {
document.getElementById('filamanDot').style.backgroundColor = data.filaman_connected ? '#4caf50' : '#f44336';
const dot = document.getElementById('filamanDot');
dot.className = data.filaman_connected ? 'status-dot online' : 'status-dot offline';
document.getElementById('ramStatus').textContent = data.freeHeap + ' KB free';
}
if (data.type === "updateProgress" && updateInProgress) {
@@ -100,12 +110,10 @@
const newProgress = parseInt(data.progress);
if (!isNaN(newProgress) && newProgress >= lastReceivedProgress) {
progress.style.width = newProgress + '%';
progress.textContent = newProgress + '%';
lastReceivedProgress = newProgress;
}
if (data.message) {
status.textContent = data.message;
status.style.display = 'block';
}
}
};
@@ -117,25 +125,23 @@
e.preventDefault();
const form = e.target;
const file = form.update.files[0];
const updateType = form.dataset.type;
if (!file) return;
updateInProgress = true;
progressContainer.style.display = 'block';
status.style.display = 'none';
progress.style.width = '0%';
document.querySelectorAll('form input[type=submit]').forEach(btn => btn.disabled = true);
document.querySelectorAll('input[type=submit]').forEach(btn => btn.disabled = true);
const xhr = new XMLHttpRequest();
xhr.open('POST', '/update', true);
xhr.onload = function() {
if (xhr.status !== 200) {
status.textContent = "Update failed: " + xhr.responseText;
status.style.display = 'block';
status.style.color = 'var(--error-text)';
updateInProgress = false;
document.querySelectorAll('form input[type=submit]').forEach(btn => btn.disabled = false);
document.querySelectorAll('input[type=submit]').forEach(btn => btn.disabled = false);
}
};
+77 -64
View File
@@ -6,72 +6,79 @@
<title>FilaMan - Scale Configuration</title>
<link rel="icon" type="image/png" href="/favicon.ico">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="fm-page">
<aside class="fm-sidebar">
<div class="sidebar-brand">
<img src="/logo.png" alt="Logo" class="sidebar-logo">
<div class="brand-text">
<h1>FilaMan <span class="version"></span></h1>
</div>
</div>
<nav class="fm-nav">
<a href="/">Start</a>
<a href="/waage" class="active">Scale</a>
<a href="/setup">Setup</a>
<a href="/upgrade">Upgrade</a>
</nav>
<div class="sidebar-status">
<div class="status-item">
<span class="status-dot" id="filamanDot"></span>
<span>System Sync</span>
</div>
<div class="status-item">
<span id="ramStatus"></span>
</div>
</div>
</aside>
<main class="fm-main">
<header>
<h1>Scale Configuration</h1>
<p>Manage and calibrate your built-in scale for precise filament weighing.</p>
</header>
<div class="fm-card">
<h2>Scale Actions</h2>
<div style="display: flex; gap: 1rem; align-items: center; flex-wrap: wrap;">
<button id="calibrateBtn" class="fm-btn fm-btn-primary">Calibrate Scale</button>
<button id="tareBtn" class="fm-btn fm-btn-outline">Tare Scale</button>
<label class="status-pill" style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;">
<input type="checkbox" id="autoTareCheckbox" onchange="setAutoTare(this.checked);" {{autoTare}}>
<span>Enable Auto-TARE</span>
</label>
</div>
<div id="statusMessage" style="margin-top: 1.5rem; color: var(--accent);"></div>
</div>
<div id="calibrationCard" class="fm-card" style="display: none; border-color: var(--error-text);">
<h2>Calibration Procedure</h2>
<p>Follow these steps carefully to ensure accuracy:</p>
<ol style="margin-left: 1.5rem; margin-bottom: 1.5rem; color: var(--text-muted);">
<li>Ensure the scale is completely empty.</li>
<li>Prepare a 500g calibration weight.</li>
<li>Click "Start Calibration" below.</li>
<li>Step 1: Wait for zero-point reading.</li>
<li>Step 2: Place the 500g weight on the scale when prompted.</li>
<li>Step 3: Remove the weight.</li>
</ol>
<button id="startCalibrationBtn" class="fm-btn fm-btn-danger">Start Calibration</button>
</div>
</main>
</div>
<script>
// Fetch Version
fetch('/api/version')
.then(response => response.json())
.then(data => {
const versionSpan = document.querySelector('.version');
if (versionSpan) {
versionSpan.textContent = 'v' + data.version;
}
if (versionSpan) versionSpan.textContent = 'v' + data.version;
})
.catch(error => console.error('Error fetching version:', error));
</script>
</head>
<body>
<div class="navbar">
<div style="display: flex; align-items: center; gap: 2rem;">
<img src="/logo.png" alt="FilaMan Logo" class="logo">
<div class="logo-text">
<h1>FilaMan<span class="version"></span></h1>
<h4>Filament Management Tool</h4>
</div>
</div>
<nav style="display: flex; gap: 1rem;">
<a href="/">Start</a>
<a href="/waage">Scale</a>
<a href="/setup">Setup</a>
<a href="/upgrade">Upgrade</a>
</nav>
<div class="status-container">
<div class="status-item">
<span class="status-dot" id="filamanDot"></span>F
</div>
<div class="ram-status" id="ramStatus"></div>
</div>
</div>
<div class="content">
<h1>Scale Configuration</h1>
<div class="card">
<div class="card-body">
<h5 class="card-title">Scale Actions</h5>
<button id="calibrateBtn" class="btn btn-primary">Calibrate Scale</button>
<button id="tareBtn" class="btn btn-secondary">Tare Scale</button>
&nbsp;&nbsp;&nbsp;Enable Auto-TARE <input type="checkbox" id="autoTareCheckbox" onchange="setAutoTare(this.checked);" {{autoTare}}>
<div id="statusMessage" class="mt-3"></div>
</div>
</div>
<div id="calibrationCard" class="card mt-3" style="display: none;">
<div class="card-body">
<h5 class="card-title">Calibration Procedure</h5>
<p>Please follow these steps:</p>
<ol>
<li>Make sure the scale is empty</li>
<li>Have a 500g calibration weight ready</li>
<li>Click on "Start Calibration"</li>
<li>Step 1: Empty the scale</li>
<li>Step 2: Place the 500g weight on the scale</li>
<li>Step 3: Remove weight from Scale</li>
</ol>
<button id="startCalibrationBtn" class="btn btn-danger">Start Calibration</button>
</div>
</div>
</div>
<script>
let ws = null;
const statusMessage = document.getElementById('statusMessage');
@@ -79,25 +86,30 @@
ws = new WebSocket(`ws://${window.location.hostname}/ws`);
ws.onopen = () => {
statusMessage.innerHTML = 'Scale connected';
statusMessage.textContent = 'Scale connected via WebSocket';
enableButtons(true);
};
ws.onclose = () => {
statusMessage.innerHTML = 'Scale connection lost';
statusMessage.textContent = 'Scale connection lost. Reconnecting...';
enableButtons(false);
setTimeout(connectWebSocket, 2000);
};
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
if (data.type === 'heartbeat') {
const dot = document.getElementById('filamanDot');
dot.className = data.filaman_connected ? 'status-dot online' : 'status-dot offline';
document.getElementById('ramStatus').textContent = data.freeHeap + ' KB free';
}
if (data.type === 'scale') {
if (data.payload === 'success') {
statusMessage.innerHTML = 'Action successful';
statusMessage.className = 'alert alert-success';
statusMessage.textContent = 'Action successful';
statusMessage.style.color = 'var(--success-text)';
} else if (data.payload === 'error') {
statusMessage.innerHTML = 'Error while performing action';
statusMessage.className = 'alert alert-danger';
statusMessage.textContent = 'Error while performing action';
statusMessage.style.color = 'var(--error-text)';
}
}
};
@@ -136,6 +148,7 @@
}
connectWebSocket();
setInterval(() => { if(ws && ws.readyState === WebSocket.OPEN) ws.send(JSON.stringify({type:'heartbeat'})); }, 5000);
</script>
</body>
</html>
+53 -36
View File
@@ -3,58 +3,75 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FilaMan - Filament Management Tool</title>
<title>FilaMan - WiFi Info</title>
<link rel="icon" type="image/png" href="/favicon.ico">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="fm-page">
<aside class="fm-sidebar">
<div class="sidebar-brand">
<img src="/logo.png" alt="Logo" class="sidebar-logo">
<div class="brand-text">
<h1>FilaMan <span class="version"></span></h1>
</div>
</div>
<nav class="fm-nav">
<a href="/">Start</a>
<a href="/waage">Scale</a>
<a href="/setup">Setup</a>
<a href="/upgrade">Upgrade</a>
</nav>
<div class="sidebar-status">
<div class="status-item">
<span class="status-dot" id="filamanDot"></span>
<span>System Sync</span>
</div>
<div class="status-item">
<span id="ramStatus"></span>
</div>
</div>
</aside>
<main class="fm-main">
<header>
<h1>WiFi Configuration</h1>
<p>Connection status and network management.</p>
</header>
<div class="fm-card">
<h2>Connected</h2>
<p>Your device is currently connected to WiFi and operating normally.</p>
<p>
To change network settings or connect to a different access point,
please use the hardware reset button (if available) or the WiFi manager portal.
</p>
<div style="margin-top: 1.5rem;">
<span class="status-pill">Connected via Station Mode</span>
</div>
</div>
</main>
</div>
<script>
// Fetch Version
fetch('/api/version')
.then(response => response.json())
.then(data => {
const versionSpan = document.querySelector('.version');
if (versionSpan) {
versionSpan.textContent = 'v' + data.version;
}
if (versionSpan) versionSpan.textContent = 'v' + data.version;
})
.catch(error => console.error('Error fetching version:', error));
</script>
</head>
<body>
<div class="navbar">
<div style="display: flex; align-items: center; gap: 2rem;">
<img src="/logo.png" alt="FilaMan Logo" class="logo">
<div class="logo-text">
<h1>FilaMan<span class="version"></span></h1>
<h4>Filament Management Tool</h4>
</div>
</div>
<nav style="display: flex; gap: 1rem;">
<a href="/">Start</a>
<a href="/waage">Scale</a>
<a href="/setup">Setup</a>
<a href="/upgrade">Upgrade</a>
</nav>
<div class="status-container">
<div class="status-item">
<span class="status-dot" id="filamanDot"></span>F
</div>
<div class="ram-status" id="ramStatus"></div>
</div>
</div>
<div class="content">
<h1>WiFi Configuration</h1>
<p>Your device is connected to WiFi.</p>
<p>To change WiFi settings, you can reset the WiFi configuration by holding the hardware button (if available) or using the WiFi manager portal.</p>
</div>
<script>
// WebSocket handling
let ws = null;
function connectWebSocket() {
ws = new WebSocket(`ws://${window.location.hostname}/ws`);
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
if (data.type === 'heartbeat') {
document.getElementById('filamanDot').style.backgroundColor = data.filaman_connected ? '#4caf50' : '#f44336';
const dot = document.getElementById('filamanDot');
dot.className = data.filaman_connected ? 'status-dot online' : 'status-dot offline';
document.getElementById('ramStatus').textContent = data.freeHeap + ' KB free';
}
};