Skip to content

Commit

Permalink
Merge pull request #75 from floatplane/firmware_name
Browse files Browse the repository at this point in the history
Display old and new firmware names when upgrading
  • Loading branch information
floatplane authored Jul 16, 2024
2 parents a4abc79 + 4ebbfc8 commit 6de6433
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
4 changes: 3 additions & 1 deletion scripts/webserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ def render(path, context = {})
mode_selection_all: false,
login_password: "abc123",
})
when "/upgrade" then res.body = render("upgrade")
when "/upgrade" then res.body = render("upgrade", {
firmware: 'mitsuqtt-WEMOS_D1_Mini-SPIFFS-2024.07.10-2bc2afc'
})
when "/upload" then res.body = render("upload")
when "/wifi" then res.body = render("wifi", {access_point: "the_ssid", hostname: "the_hostname", password: "abc123"})

Expand Down
2 changes: 1 addition & 1 deletion src/frontend/en-us/views/status.mst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</tr>
<tr>
<td class="bold">Firmware</td>
<td class="left wrap-text"><code>{{progname}}</code></td>
<td class="left wrap-text"><code>{{progname}}.bin</code></td>
</tr>
<tr>
<td class="bold">Build date</td>
Expand Down
34 changes: 31 additions & 3 deletions src/frontend/en-us/views/upgrade.mst
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,45 @@
function eb(s) {
return document.getElementById(s);
}
function ready(fn) {
if (document.readyState !== 'loading') {
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
}
ready(function() {
eb('firmware').addEventListener('change', function() {
const fileName = eb('firmware').files[0].name;
if (fileName.length > 0) {
eb('selectedFileName').innerText = fileName;
eb('selectedFile').style.display = 'block';
eb('selectFile').style.display = 'none';
eb('upgrade').disabled = false;
}
});
});
</script>
<main>
<h2>Upgrade</h2>
<div id='f1' style='display:block;'>
<form method='post' action='upload' enctype='multipart/form-data'>
<label for='upload'>Select a BIN file containing new firmware</label>
<input type='file' accept='.bin' name='upload'>
<div style="min-height: 120px">
<div id="selectFile">
<label for='upload'>Select a BIN file containing new firmware</label>
<input type='file' accept='.bin' name='upload' id="firmware" >
</div>
<div id="selectedFile" style="display:none">
<div><b>Current firmware:</b></div>
<div style="margin-bottom: 8px;"><code>{{firmware}}.bin</code></div>
<div><b>New firmware:</b></div>
<div><code id="selectedFileName">No file selected</code></div>
</div>
</div>
<br>
<div class="buttons">
<button id="upgrade" disabled type='submit' onclick="eb('f1').style.display='none';eb('f2').style.display='block';this.form.submit();" class='button bgrn'>Start upgrade</button>
<a class="buttonLink" href='/setup'>&lt; Back</a>
<button type='submit' onclick="eb('f1').style.display='none';eb('f2').style.display='block';this.form.submit();" class='button bgrn'>Start upgrade</button>
</div>
</form>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,7 @@ void handleUpgrade() {

uploaderror = UploadError::noError;
JsonDocument data;
data[F("firmware")] = F(MITSUQTT_PROGNAME);
renderView(views::upgrade, data, {{"header", partials::header}, {"footer", partials::footer}});
}

Expand Down

0 comments on commit 6de6433

Please sign in to comment.