Ver código fonte

www: update.html: go to the status page after successful update

After a successful firmware update, redirect to the new status page.
H. Peter Anvin 2 anos atrás
pai
commit
1f866a4c56

BIN
esp32/output/max80.ino.bin


+ 6 - 4
esp32/www/max80.js

@@ -146,10 +146,12 @@ function upload(form,data) {
 
 	classmod(form, [['ok',ok],['err',!ok],['running',0],['done',1]]);
 
-	// Automatically reload the page after successful upload
-	const rf = parseInt(xhr.getResponseHeader('Refresh'));
-	if (rf && ok)
-	    setTimeout(() => window.location.reload(), rf * 1000);
+	// Optionally redirect elsewhere after success
+	const reft = parseFloat(form.dataset.ref) * 1000;
+	if (ok && reft >= 0.0) {
+	    const refh = form.dataset.refUrl || window.location.href;
+	    setTimeout(() => { window.location.href = refh; }, reft);
+	}
     }, PassiveListener);
 
     xhr.open(form.method, form.action);

+ 3 - 2
esp32/www/update.html

@@ -8,8 +8,9 @@
   <body>
     <script>inc("head.html")</script>
     <h1 class="update">Update</h1>
-    <form id="upload" class="idle" action="sys/fwupdate"
-	  method="post" onsubmit="uploadfile()">
+    <form id="upload" class="idle"
+	  action="sys/fwupdate" method="post" onsubmit="uploadfile()"
+	  data-ref="10" data-ref-url="status.html">
       <fieldset class="firmware">
 	<legend>Firmware</legend>
 	<input type="file" name="file" hidden accept=".fw" onchange="uploadfile()" />

BIN
fpga/output/v1.fw


BIN
fpga/output/v2.fw