feat: update version to 1.2.2; change OTA upgrade link in HTML files; enhance OTA upload handling with progress updates and JSON responses
This commit is contained in:
		| @@ -21,7 +21,7 @@ | ||||
|             <a href="/waage">Scale</a> | ||||
|             <a href="/spoolman">Spoolman/Bambu</a> | ||||
|             <a href="/about">About</a> | ||||
|             <a href="/ota">Upgrade</a> | ||||
|             <a href="/upgrade">Upgrade</a> | ||||
|         </nav> | ||||
|         <div class="status-container"> | ||||
|             <div class="status-item"> | ||||
|   | ||||
| @@ -21,7 +21,7 @@ | ||||
|             <a href="/waage">Scale</a> | ||||
|             <a href="/spoolman">Spoolman/Bambu</a> | ||||
|             <a href="/about">About</a> | ||||
|             <a href="/ota">Upgrade</a> | ||||
|             <a href="/upgrade">Upgrade</a> | ||||
|         </nav> | ||||
|         <div class="status-container"> | ||||
|             <div class="status-item"> | ||||
|   | ||||
| @@ -21,7 +21,7 @@ | ||||
|             <a href="/waage">Scale</a> | ||||
|             <a href="/spoolman">Spoolman/Bambu</a> | ||||
|             <a href="/about">About</a> | ||||
|             <a href="/ota">Upgrade</a> | ||||
|             <a href="/upgrade">Upgrade</a> | ||||
|         </nav> | ||||
|         <div class="status-container"> | ||||
|             <div class="status-item"> | ||||
|   | ||||
| @@ -21,7 +21,7 @@ | ||||
|             <a href="/waage">Scale</a> | ||||
|             <a href="/spoolman">Spoolman/Bambu</a> | ||||
|             <a href="/about">About</a> | ||||
|             <a href="/ota">Upgrade</a> | ||||
|             <a href="/upgrade">Upgrade</a> | ||||
|         </nav> | ||||
|         <div class="status-container"> | ||||
|             <div class="status-item"> | ||||
|   | ||||
| @@ -1013,4 +1013,78 @@ input[type="submit"]:disabled, | ||||
|     color: #000; | ||||
|     vertical-align: middle; | ||||
|     margin-left: 0.5rem; | ||||
| } | ||||
|  | ||||
| .progress-container { | ||||
|     width: 100%; | ||||
|     margin: 20px 0; | ||||
|     display: none; | ||||
|     background: #f0f0f0; | ||||
|     border-radius: 4px; | ||||
|     overflow: hidden; | ||||
| } | ||||
| .progress-bar { | ||||
|     width: 0%; | ||||
|     height: 24px; | ||||
|     background-color: #4CAF50; | ||||
|     text-align: center; | ||||
|     line-height: 24px; | ||||
|     color: white; | ||||
|     transition: width 0.3s ease-in-out; | ||||
|     font-weight: bold; | ||||
| } | ||||
| .status { | ||||
|     margin: 10px 0; | ||||
|     padding: 15px; | ||||
|     border-radius: 4px; | ||||
|     display: none; | ||||
| } | ||||
| .error {  | ||||
|     background-color: #ffebee;  | ||||
|     color: #c62828;  | ||||
|     border: 1px solid #ef9a9a; | ||||
| } | ||||
| .success {  | ||||
|     background-color: #e8f5e9;  | ||||
|     color: #2e7d32;  | ||||
|     border: 1px solid #a5d6a7; | ||||
| } | ||||
| .update-form { | ||||
|     background: var(--primary-color); | ||||
|     padding: 20px; | ||||
|     border-radius: 8px; | ||||
|     box-shadow: 0 2px 4px rgba(0,0,0,0.1); | ||||
|     margin: 0 auto; | ||||
|     width: 400px; | ||||
| } | ||||
| .update-form input[type="file"] { | ||||
|     margin-bottom: 15px; | ||||
|     width: 80%; | ||||
|     padding: 8px; | ||||
|     border: 1px solid #ddd; | ||||
|     border-radius: 4px; | ||||
| } | ||||
| .update-form input[type="submit"] { | ||||
|     background-color: #4CAF50; | ||||
|     color: white; | ||||
|     padding: 10px 20px; | ||||
|     border: none; | ||||
|     border-radius: 4px; | ||||
|     cursor: pointer; | ||||
|     font-size: 16px; | ||||
| } | ||||
| .update-form input[type="submit"]:hover { | ||||
|     background-color: #45a049; | ||||
| } | ||||
| .update-form input[type="submit"]:disabled { | ||||
|     background-color: #cccccc; | ||||
|     cursor: not-allowed; | ||||
| } | ||||
| .warning { | ||||
|     background-color: var(--primary-color); | ||||
|     border: 1px solid #ffe0b2; | ||||
|     color: #e65100; | ||||
|     padding: 15px; | ||||
|     margin: 20px 0; | ||||
|     border-radius: 4px; | ||||
| } | ||||
							
								
								
									
										142
									
								
								html/upgrade.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										142
									
								
								html/upgrade.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,142 @@ | ||||
|  | ||||
| <!-- head --><!DOCTYPE html> | ||||
| <html lang="en"> | ||||
| <head> | ||||
|     <meta charset="UTF-8"> | ||||
|     <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||||
|     <title>FilaMan - Filament Management Tool</title> | ||||
|     <link rel="icon" type="image/png" href="/favicon.ico"> | ||||
|     <link rel="stylesheet" href="style.css"> | ||||
| </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">v1.2.1</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="/spoolman">Spoolman/Bambu</a> | ||||
|             <a href="/about">About</a> | ||||
|             <a href="/upgrade">Upgrade</a> | ||||
|         </nav> | ||||
|         <div class="status-container"> | ||||
|             <div class="status-item"> | ||||
|                 <span class="status-dot" id="bambuDot"></span>B | ||||
|             </div> | ||||
|             <div class="status-item"> | ||||
|                 <span class="status-dot" id="spoolmanDot"></span>S | ||||
|             </div> | ||||
|             <div class="ram-status" id="ramStatus"></div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
| <!-- head --> | ||||
|      | ||||
|     <div class="content"> | ||||
|         <h1>Firmware Upgrade</h1> | ||||
|  | ||||
|         <div class="warning"> | ||||
|             <strong>Warning:</strong> Please do not turn off or restart the device during the update.  | ||||
|                         Configuration files will be automatically backed up and restored after the update. | ||||
|         </div> | ||||
|  | ||||
|          | ||||
|         <div class="update-form" style="align-items: center;"> | ||||
|             <form id="updateForm" enctype='multipart/form-data' style="text-align: center;"></form> | ||||
|                 <input type='file' name='update' accept='.bin' required> | ||||
|                 <input type='submit' value='Firmware Update starten'> | ||||
|             </form> | ||||
|         </div> | ||||
|  | ||||
|         <div class="progress-container"> | ||||
|             <div class="progress-bar">0%</div> | ||||
|         </div> | ||||
|         <div class="status"></div> | ||||
|     </div> | ||||
|  | ||||
|     <script> | ||||
|         document.getElementById('updateForm').addEventListener('submit', async (e) => { | ||||
|             e.preventDefault(); | ||||
|             const form = e.target; | ||||
|             const file = form.update.files[0]; | ||||
|             const formData = new FormData(); | ||||
|             formData.append('update', file); | ||||
|  | ||||
|             const progress = document.querySelector('.progress-bar'); | ||||
|             const progressContainer = document.querySelector('.progress-container'); | ||||
|             const status = document.querySelector('.status'); | ||||
|              | ||||
|             progressContainer.style.display = 'block'; | ||||
|             status.style.display = 'none'; | ||||
|             status.className = 'status'; | ||||
|             form.querySelector('input[type=submit]').disabled = true; | ||||
|  | ||||
|             const xhr = new XMLHttpRequest(); | ||||
|             xhr.open('POST', '/update', true); | ||||
|  | ||||
|             xhr.upload.onprogress = (e) => { | ||||
|                 if (e.lengthComputable) { | ||||
|                     const percentComplete = (e.loaded / e.total) * 100; | ||||
|                     progress.style.width = percentComplete + '%'; | ||||
|                     progress.textContent = Math.round(percentComplete) + '%'; | ||||
|                 } | ||||
|             }; | ||||
|  | ||||
|             xhr.onload = function() { | ||||
|                 try { | ||||
|                     let response = this.responseText; | ||||
|                     try { | ||||
|                         // Versuche als JSON zu parsen | ||||
|                         const jsonResponse = JSON.parse(response); | ||||
|                         response = jsonResponse.message; | ||||
|                          | ||||
|                         if (jsonResponse.restart) { | ||||
|                             // Wenn Gerät neustartet, warte und lade dann neu | ||||
|                             status.textContent = response + " Weiterleitung in 5 Sekunden..."; | ||||
|                             setTimeout(() => { | ||||
|                                 window.location.href = '/'; | ||||
|                             }, 5000); | ||||
|                         } | ||||
|                     } catch (e) { | ||||
|                         // Wenn kein JSON, nutze response als Text | ||||
|                         if (!isNaN(response)) { | ||||
|                             // Wenn es eine Zahl ist, update den Fortschritt | ||||
|                             const percent = parseInt(response); | ||||
|                             progress.style.width = percent + '%'; | ||||
|                             progress.textContent = percent + '%'; | ||||
|                             return; | ||||
|                         } | ||||
|                     } | ||||
|                      | ||||
|                     status.textContent = response; | ||||
|                     status.classList.add(xhr.status === 200 ? 'success' : 'error'); | ||||
|                     status.style.display = 'block'; | ||||
|                      | ||||
|                     if (xhr.status !== 200) { | ||||
|                         form.querySelector('input[type=submit]').disabled = false; | ||||
|                     } | ||||
|                 } catch (error) { | ||||
|                     status.textContent = 'Fehler: ' + error.message; | ||||
|                     status.classList.add('error'); | ||||
|                     status.style.display = 'block'; | ||||
|                     form.querySelector('input[type=submit]').disabled = false; | ||||
|                 } | ||||
|             }; | ||||
|  | ||||
|             xhr.onerror = function() { | ||||
|                 status.textContent = 'Update fehlgeschlagen: Netzwerkfehler'; | ||||
|                 status.classList.add('error'); | ||||
|                 status.style.display = 'block'; | ||||
|                 form.querySelector('input[type=submit]').disabled = false; | ||||
|             }; | ||||
|  | ||||
|             xhr.send(formData); | ||||
|         }); | ||||
|     </script> | ||||
| </body> | ||||
| </html> | ||||
| @@ -21,7 +21,7 @@ | ||||
|             <a href="/waage">Scale</a> | ||||
|             <a href="/spoolman">Spoolman/Bambu</a> | ||||
|             <a href="/about">About</a> | ||||
|             <a href="/ota">Upgrade</a> | ||||
|             <a href="/upgrade">Upgrade</a> | ||||
|         </nav> | ||||
|         <div class="status-container"> | ||||
|             <div class="status-item"> | ||||
|   | ||||
| @@ -21,7 +21,7 @@ | ||||
|             <a href="/waage">Scale</a> | ||||
|             <a href="/spoolman">Spoolman/Bambu</a> | ||||
|             <a href="/about">About</a> | ||||
|             <a href="/ota">Upgrade</a> | ||||
|             <a href="/upgrade">Upgrade</a> | ||||
|         </nav> | ||||
|         <div class="status-container"> | ||||
|             <div class="status-item"> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user