safe upload and get update progress
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Has been cancelled
This commit is contained in:
1 parent
dcc4f59552
commit
1601be1060
7 files changed
+66
-41
No files matched your search
+12
-17
@@ -28,8 +28,6 @@ checker.addEventListener("click", () => {
|
||||
|
||||
upload_image_button.addEventListener("click", () => {
|
||||
upload_image_input.click();
|
||||
update_block.classList.remove("hidden");
|
||||
uploadprogress.classList.remove("hidden");
|
||||
});
|
||||
|
||||
update_image_button.addEventListener("click", () => {
|
||||
@@ -40,9 +38,10 @@ const upload_firmware_image = async () => {
|
||||
upload_percents.innerHTML = "Upload progress 0 %";
|
||||
upload_progress_bar.style.width = "0%";
|
||||
uploadprogress_block.classList.remove("hidden");
|
||||
let image = update_firmware_input.files[0];
|
||||
let image = upload_image_input.files[0];
|
||||
let formData = new FormData();
|
||||
formData.append(image.name, image);
|
||||
formData.append("image", image);
|
||||
formData.append("token", localStorage.getItem('token'))
|
||||
var request = new XMLHttpRequest();
|
||||
request.upload.addEventListener("progress", (e) => {
|
||||
var file1Size = image.size;
|
||||
@@ -59,25 +58,21 @@ const upload_firmware_image = async () => {
|
||||
});
|
||||
request.onreadystatechange = () => {
|
||||
if (request.readyState === 4) {
|
||||
let jsondata = JSON.parse(request.responseText);
|
||||
if (jsondata.success) {
|
||||
image_table_body.innerHTML = `
|
||||
<td><b>${jsondata.response.file.name}<b/></td>
|
||||
<td>${(jsondata.response.file.size / 1024 / 1024).toFixed(2)}MB</td>
|
||||
<td>${jsondata.response.cpu}</td>
|
||||
<td>${jsondata.response.deviceName}</td>
|
||||
<td>${jsondata.response.version}</td>
|
||||
`;
|
||||
image_table.classList.remove("hidden-table");
|
||||
start_update_button.classList.remove("hidden-button");
|
||||
console.log(request.responseText)
|
||||
const jsondata = JSON.parse(request.responseText)
|
||||
if (jsondata.status === true) {
|
||||
update_image_button.classList.remove('hidden')
|
||||
update_block.classList.remove("hidden");
|
||||
} else {
|
||||
notification('Upload error', 'error')
|
||||
}
|
||||
}
|
||||
};
|
||||
request.open(
|
||||
"post",
|
||||
window.location.origin + "/wimic/updatefirmware/upload",
|
||||
routes.upload_image(),
|
||||
);
|
||||
request.timeout = 45000;
|
||||
request.timeout = 450000;
|
||||
request.send(formData);
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user