Skip to content

Commit

Permalink
fix view reset when upload is complete
Browse files Browse the repository at this point in the history
  • Loading branch information
stv0g committed Apr 3, 2022
1 parent d3f31a6 commit a152d55
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions frontend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,23 @@ var upload: Upload | null;
let points: Array<number[]> = []

function reset() {
if (upload) {
if (upload && upload.inProgress) {
upload.abort();
}
else {
resetView();
}
}

function resetView() {
let divStats = document.getElementById("statistics");
divStats.classList.add("d-none");

let btnReset = document.getElementById("reset");
btnReset.classList.add("d-none");

let divResult = document.getElementById("result");
divResult.classList.add("d-none");
}

function alert(cls: string, msg: string, url?: string, icon?: string) {
Expand Down Expand Up @@ -178,14 +192,7 @@ async function startUpload(files: FileList) {
}
catch (e) {
if (e === "Aborted") {
let divStats = document.getElementById("statistics");
divStats.classList.add("d-none");

let btnReset = document.getElementById("reset");
btnReset.classList.add("d-none");

let divResult = document.getElementById("result");
divResult.classList.add("d-none");
resetView();
} else {
alert("danger", `Upload failed: ${e}`, null, "triangle-exclamation");

Expand Down

0 comments on commit a152d55

Please sign in to comment.