Skip to content

Commit b3733aa

Browse files
committed
Use js to POST manual update, or it will refresh the page and break my tests
1 parent 347b1c4 commit b3733aa

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

web_app/static/settings.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,22 @@ $(document).ready(function () {
537537
const queryString = window.location.search;
538538
const urlParams = new URLSearchParams(queryString);
539539
if (urlParams.get('update') === 'manual' ) {
540-
$("#updateModal .modal-body").append('<h3>Manual Update: </h3><form method="POST" action="" enctype="multipart/form-data"> <p><input type="file" name="file"></p><p><input onclick="this.form.submit()" id="submit-button" type="submit" value="Submit"></p></form>');
540+
$("#updateModal .modal-body").append('<h3>Manual Update: </h3><form method="POST" action="" enctype="multipart/form-data"> <p><input type="file" name="file"></p><p><input id="submit-button" type="submit" value="Submit"></p></form>');
541+
const upd_formElt = document.querySelector('#updateModal div.modal-body form');
542+
upd_formElt.addEventListener('submit', handleFileSubmit);
543+
function handleFileSubmit(event) {
544+
console.log('inside function handlefilesubmit');
545+
event.preventDefault;
546+
fetch(upd_formElt.action, {
547+
method: "post",
548+
// body: new URLSearchParams(new FormData(form)) // for application/x-www-form-urlencoded
549+
body: new FormData(upd_formElt) // for multipart/form-data
550+
});
551+
$("#updateModal .modal-body").html('<span class="spinner-border spinner-border-sm"></span> Updating...');
552+
};
541553
}
542-
})
543-
554+
});
555+
544556
$("#start-update-button").on("click", function () {
545557
//$("#updateModal .modal-title").text(("Installing update"));
546558
socket.emit("update rtkbase");

0 commit comments

Comments
 (0)