2025-02-21 10:35:52 +01:00
|
|
|
<!DOCTYPE html>
|
2025-02-18 12:28:47 +01:00
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
2025-02-21 10:35:52 +01:00
|
|
|
<title>FilaMan - Firmware Update</title>
|
2025-02-18 12:28:47 +01:00
|
|
|
<link rel="stylesheet" href="style.css">
|
2025-02-21 10:35:52 +01:00
|
|
|
<style>
|
|
|
|
.debug-log {
|
|
|
|
background: #f5f5f5;
|
|
|
|
border: 1px solid #ddd;
|
|
|
|
padding: 10px;
|
|
|
|
margin: 10px 0;
|
|
|
|
font-family: monospace;
|
|
|
|
max-height: 200px;
|
|
|
|
overflow-y: auto;
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
</style>
|
2025-02-18 12:28:47 +01:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="content">
|
2025-02-21 10:35:52 +01:00
|
|
|
<h1>Firmware Update</h1>
|
|
|
|
|
2025-02-18 12:28:47 +01:00
|
|
|
<div class="warning">
|
2025-02-21 10:35:52 +01:00
|
|
|
<strong>Warning:</strong> Do not power off the device during update.
|
2025-02-18 12:28:47 +01:00
|
|
|
</div>
|
|
|
|
|
2025-02-21 10:35:52 +01:00
|
|
|
<form id="updateForm">
|
|
|
|
<input type="file" name="update" accept=".bin">
|
|
|
|
<button type="submit">Update Firmware</button>
|
|
|
|
</form>
|
2025-02-18 12:28:47 +01:00
|
|
|
|
2025-02-21 10:35:52 +01:00
|
|
|
<div class="progress" style="display: none;">
|
|
|
|
<div class="progress-bar"></div>
|
|
|
|
<div class="status"></div>
|
2025-02-18 12:28:47 +01:00
|
|
|
</div>
|
2025-02-21 10:35:52 +01:00
|
|
|
|
|
|
|
<div class="debug-log"></div>
|
2025-02-18 12:28:47 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
2025-02-21 10:35:52 +01:00
|
|
|
const form = document.getElementById('updateForm');
|
|
|
|
const progress = document.querySelector('.progress');
|
|
|
|
const progressBar = document.querySelector('.progress-bar');
|
|
|
|
const status = document.querySelector('.status');
|
|
|
|
const debugLog = document.querySelector('.debug-log');
|
|
|
|
|
|
|
|
function log(message) {
|
|
|
|
debugLog.style.display = 'block';
|
|
|
|
const time = new Date().toLocaleTimeString();
|
|
|
|
debugLog.innerHTML += `[${time}] ${message}<br>`;
|
|
|
|
debugLog.scrollTop = debugLog.scrollHeight;
|
2025-02-21 09:24:54 +01:00
|
|
|
}
|
|
|
|
|
2025-02-21 10:35:52 +01:00
|
|
|
form.addEventListener('submit', async (e) => {
|
2025-02-18 12:28:47 +01:00
|
|
|
e.preventDefault();
|
|
|
|
const file = form.update.files[0];
|
2025-02-18 14:18:14 +01:00
|
|
|
if (!file) {
|
2025-02-21 10:35:52 +01:00
|
|
|
alert('Please select a file');
|
2025-02-21 09:24:54 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2025-02-21 10:35:52 +01:00
|
|
|
log(`Selected file: ${file.name} (${file.size} bytes)`);
|
2025-02-18 12:28:47 +01:00
|
|
|
|
2025-02-21 10:35:52 +01:00
|
|
|
// Aktiviere Fortschrittsanzeige
|
|
|
|
progress.style.display = 'block';
|
|
|
|
form.style.display = 'none';
|
2025-02-18 12:28:47 +01:00
|
|
|
|
2025-02-21 10:35:52 +01:00
|
|
|
// Erstelle FormData für den Upload
|
|
|
|
const formData = new FormData();
|
|
|
|
formData.append('update', file);
|
2025-02-21 09:24:54 +01:00
|
|
|
|
|
|
|
try {
|
2025-02-21 10:35:52 +01:00
|
|
|
log('Starting upload...');
|
|
|
|
const response = await fetch('/update', {
|
|
|
|
method: 'POST',
|
|
|
|
body: formData
|
|
|
|
});
|
|
|
|
|
|
|
|
log(`Server responded with status: ${response.status}`);
|
|
|
|
|
|
|
|
let result;
|
|
|
|
const contentType = response.headers.get('content-type');
|
|
|
|
log(`Response content-type: ${contentType}`);
|
|
|
|
|
|
|
|
if (contentType && contentType.includes('application/json')) {
|
|
|
|
result = await response.json();
|
|
|
|
log('Received JSON response');
|
|
|
|
} else {
|
|
|
|
const text = await response.text();
|
|
|
|
log(`Received text response: ${text}`);
|
|
|
|
result = { success: response.ok, message: text };
|
2025-02-18 12:28:47 +01:00
|
|
|
}
|
2025-02-21 09:24:54 +01:00
|
|
|
|
2025-02-21 10:35:52 +01:00
|
|
|
log(`Update result: ${JSON.stringify(result)}`);
|
|
|
|
|
|
|
|
if (response.ok && result.success) {
|
|
|
|
status.textContent = 'Update successful! Restarting...';
|
|
|
|
status.className = 'success';
|
|
|
|
setTimeout(() => {
|
|
|
|
window.location.href = '/';
|
|
|
|
}, 5000);
|
|
|
|
} else {
|
|
|
|
throw new Error(result.message || 'Update failed');
|
|
|
|
}
|
2025-02-21 09:24:54 +01:00
|
|
|
} catch (error) {
|
2025-02-21 10:35:52 +01:00
|
|
|
log(`Error: ${error.message}`);
|
|
|
|
console.error('Update error:', error);
|
|
|
|
status.textContent = `Error: ${error.message}`;
|
|
|
|
status.className = 'error';
|
|
|
|
form.style.display = 'block';
|
|
|
|
progress.style.display = 'none';
|
2025-02-21 09:24:54 +01:00
|
|
|
}
|
2025-02-18 12:28:47 +01:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|