сделал загрузку обновленной прошивки и само обновление раздельными
This commit is contained in:
@@ -629,7 +629,8 @@
|
||||
<input type="file" accept="application/zip" @change="(e) => { this.uploadFw.filename = e.target.files[0] }">
|
||||
<span v-if="uploadFw.sha256 !== null">SHA256: {{ uploadFw.sha256 }}</span>
|
||||
</label>
|
||||
<button class="dangerous-button" @click="settingsUploadUpdate()">Обновить встроенное ПО <span class="submit-spinner" v-show="submitStatus.firmwareUpload"></span></button>
|
||||
<button class="action-button" @click="settingsUploadUpdate()">Загрузить<span class="submit-spinner" v-show="submitStatus.firmwareUpload"></span></button>
|
||||
<button class="dangerous-button" v-show="uploadFw.sha256 !== null" @click="settingsPerformFirmwareUpgrade()">Обновить встроенное ПО <span class="submit-spinner" v-show="submitStatus.firmwareUpgrade"></span></button>
|
||||
</div>
|
||||
|
||||
<div hidden>
|
||||
@@ -808,6 +809,7 @@
|
||||
debugSend: false,
|
||||
tcpAccel: false,
|
||||
firmwareUpload: false,
|
||||
firmwareUpgrade: false
|
||||
},
|
||||
|
||||
stat_rx: {
|
||||
@@ -1312,14 +1314,14 @@
|
||||
|
||||
try {
|
||||
this.submitStatus.firmwareUpload = true
|
||||
this.uploadFw.progress = 0
|
||||
const blob = await readFileAsArrayBuffer(this.uploadFw.filename)
|
||||
|
||||
const xhr = new XMLHttpRequest();
|
||||
const success = await new Promise((resolve) => {
|
||||
await new Promise((resolve) => {
|
||||
xhr.upload.addEventListener("progress", (event) => {
|
||||
if (event.lengthComputable) {
|
||||
this.uploadFw.progress = Math.round((event.loaded / event.total) * 1000) / 10;
|
||||
console.log("upload progress:", this.uploadFw.progress);
|
||||
}
|
||||
});
|
||||
xhr.addEventListener("loadend", () => {
|
||||
@@ -1332,23 +1334,23 @@
|
||||
xhr.setRequestHeader("Content-Type", "application/octet-stream");
|
||||
xhr.send(blob);
|
||||
});
|
||||
console.log("success:", success);
|
||||
// const result = await fetch('', {
|
||||
// method: 'POST',
|
||||
// body: await readFileAsArrayBuffer(this.uploadFw.filename),
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/zip',
|
||||
// },
|
||||
// onuploadprogress: (progressEvent) => {
|
||||
// this.uploadFw.progress = Math.round((progressEvent.loaded / progressEvent.total) * 100);
|
||||
// },
|
||||
// })
|
||||
} catch (e) {
|
||||
alert(`Ошибка загрузки файла: ${e}`);
|
||||
}
|
||||
this.submitStatus.firmwareUpload = false
|
||||
},
|
||||
|
||||
async settingsPerformFirmwareUpgrade() {
|
||||
if (this.submitStatus.firmwareUpgrade) { return }
|
||||
this.submitStatus.firmwareUpgrade = true
|
||||
try {
|
||||
await fetch('/api/doFirmwareUpgrade', { method: 'POST' })
|
||||
} catch (e) {
|
||||
console.log("failed to perform upgrade firmware: ", e)
|
||||
}
|
||||
this.submitStatus.firmwareUpgrade = false
|
||||
},
|
||||
|
||||
performUpdateSettings(reloadParts) {
|
||||
const doFetchSettings = async () => {
|
||||
let d = await fetch("/api/get/settings")
|
||||
|
Reference in New Issue
Block a user