Skip to content

Commit 2a4cc19

Browse files
committed
download button
1 parent 1d082de commit 2a4cc19

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

assets/css/main.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,11 @@ header {
318318
flex-wrap: wrap;
319319
}
320320

321+
.card__actions--center {
322+
justify-content: center;
323+
align-items: center;
324+
}
325+
321326
.tile {
322327
padding: 20px;
323328
border-radius: var(--radius-md);

assets/js/webflasher.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,6 @@ const injectDialogSurfaceStyles = (dialog) => {
571571
box-shadow: 0 34px 120px rgba(0, 221, 0, 0.25);
572572
backdrop-filter: blur(24px);
573573
color: var(--text);
574-
// padding: 24px 28px 28px;
575574
}
576575
.container::before {
577576
background: rgba(12, 18, 21, 0.96);
@@ -782,11 +781,13 @@ document.addEventListener("DOMContentLoaded", () => {
782781
const deviceSection = document.querySelector("[data-device-section]");
783782
const installSection = document.querySelector("[data-install-section]");
784783
const installButton = document.querySelector("esp-web-install-button");
784+
const downloadButton = document.querySelector("[data-download-button]");
785785
const manifestSummary = document.querySelector("[data-manifest-summary]");
786786
if (!releaseContainer ||
787787
!vendorContainer ||
788788
!deviceContainer ||
789789
!installButton ||
790+
!downloadButton ||
790791
!manifestSummary) {
791792
return;
792793
}
@@ -847,10 +848,16 @@ document.addEventListener("DOMContentLoaded", () => {
847848
}
848849
manifestSummary.textContent = parts.length > 0 ? parts.join(" -> ") : summaryFallback;
849850
};
851+
const hideDownloadButton = () => {
852+
downloadButton.setAttribute("hidden", "");
853+
downloadButton.removeAttribute("href");
854+
downloadButton.removeAttribute("download");
855+
};
850856
const hideInstallButton = () => {
851857
revokeManifestUrl();
852858
installButton.setAttribute("hidden", "");
853859
installButton.removeAttribute("manifest");
860+
hideDownloadButton();
854861
};
855862
const resetDeviceDetails = (message) => {
856863
if (descriptionTarget) {
@@ -913,6 +920,7 @@ document.addEventListener("DOMContentLoaded", () => {
913920
}
914921
const binRelativePath = `bins${state.releaseValue}/Launcher-${device.id}.bin`;
915922
let binAbsolutePath = binRelativePath;
923+
const downloadFileName = `Launcher-${device.id}.bin`;
916924
if (manifestBaseUrl) {
917925
try {
918926
binAbsolutePath = new URL(binRelativePath, manifestBaseUrl).toString();
@@ -921,6 +929,9 @@ document.addEventListener("DOMContentLoaded", () => {
921929
console.warn("Unable to resolve firmware from manifest base path.", error);
922930
}
923931
}
932+
downloadButton.href = binAbsolutePath;
933+
downloadButton.download = downloadFileName;
934+
downloadButton.removeAttribute("hidden");
924935
const manifest = {
925936
name: device.name,
926937
new_install_prompt_erase: true,

src/pages/webflasher.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ <h2 class="section__heading">Flash your board</h2>
9393
</div>
9494
</div>
9595
<div class="card card--compact" style="align-items: center;">
96-
<esp-web-install-button></esp-web-install-button>
96+
<div class="card__actions card__actions--center">
97+
<esp-web-install-button></esp-web-install-button>
98+
<a class="button button--ghost" data-download-button hidden download>Download</a>
99+
</div>
97100
<p class="card__description" style="text-align: center; max-width: 520px;">
98101
Having trouble? Make sure you are using Chrome, Edge, or another browser with WebUSB support and that this page is served over HTTPS.
99102
</p>

src/webflasher.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,13 +910,15 @@ document.addEventListener("DOMContentLoaded", () => {
910910
const deviceSection = document.querySelector<HTMLElement>("[data-device-section]");
911911
const installSection = document.querySelector<HTMLElement>("[data-install-section]");
912912
const installButton = document.querySelector<WebInstallButtonElement>("esp-web-install-button");
913+
const downloadButton = document.querySelector<HTMLAnchorElement>("[data-download-button]");
913914
const manifestSummary = document.querySelector<HTMLElement>("[data-manifest-summary]");
914915

915916
if (
916917
!releaseContainer ||
917918
!vendorContainer ||
918919
!deviceContainer ||
919920
!installButton ||
921+
!downloadButton ||
920922
!manifestSummary
921923
) {
922924
return;
@@ -982,10 +984,17 @@ document.addEventListener("DOMContentLoaded", () => {
982984
manifestSummary.textContent = parts.length > 0 ? parts.join(" -> ") : summaryFallback;
983985
};
984986

987+
const hideDownloadButton = () => {
988+
downloadButton.setAttribute("hidden", "");
989+
downloadButton.removeAttribute("href");
990+
downloadButton.removeAttribute("download");
991+
};
992+
985993
const hideInstallButton = () => {
986994
revokeManifestUrl();
987995
installButton.setAttribute("hidden", "");
988996
installButton.removeAttribute("manifest");
997+
hideDownloadButton();
989998
};
990999

9911000
const resetDeviceDetails = (message?: string) => {
@@ -1053,6 +1062,7 @@ document.addEventListener("DOMContentLoaded", () => {
10531062

10541063
const binRelativePath = `bins${state.releaseValue}/Launcher-${device.id}.bin`;
10551064
let binAbsolutePath = binRelativePath;
1065+
const downloadFileName = `Launcher-${device.id}.bin`;
10561066

10571067
if (manifestBaseUrl) {
10581068
try {
@@ -1062,6 +1072,10 @@ document.addEventListener("DOMContentLoaded", () => {
10621072
}
10631073
}
10641074

1075+
downloadButton.href = binAbsolutePath;
1076+
downloadButton.download = downloadFileName;
1077+
downloadButton.removeAttribute("hidden");
1078+
10651079
const manifest = {
10661080
name: device.name,
10671081
new_install_prompt_erase: true,

0 commit comments

Comments
 (0)