Feature: Automatic page reload after firmware upgrade
This will work after the current upgrade if this code was loaded.
This commit is contained in:
parent
f7119bc3c7
commit
0584eadcf2
@ -549,7 +549,7 @@
|
|||||||
"Back": "Zurück",
|
"Back": "Zurück",
|
||||||
"Retry": "Wiederholen",
|
"Retry": "Wiederholen",
|
||||||
"OtaStatus": "OTA-Status",
|
"OtaStatus": "OTA-Status",
|
||||||
"OtaSuccess": "OTA erfolgreich. Das Gerät wurde automatisch neu gestartet und wird in wenigen Augenblicken wieder zur Verfügung stehen. Bitte nicht vergessen, die Weboberfläche neu zu laden!",
|
"OtaSuccess": "Das Hochladen der Firmware war erfolgreich. Das Gerät wurde automatisch neu gestartet. Wenn das Gerät wieder erreichbar ist wird die automatisch Oberfläche neu geladen.",
|
||||||
"FirmwareUpload": "Firmware hochladen",
|
"FirmwareUpload": "Firmware hochladen",
|
||||||
"UploadProgress": "Hochlade-Fortschritt"
|
"UploadProgress": "Hochlade-Fortschritt"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -549,7 +549,7 @@
|
|||||||
"Back": "Back",
|
"Back": "Back",
|
||||||
"Retry": "Retry",
|
"Retry": "Retry",
|
||||||
"OtaStatus": "OTA Status",
|
"OtaStatus": "OTA Status",
|
||||||
"OtaSuccess": "OTA Success. The unit has been automatically restarted and will be available again in a few moments. Please do not forget to reload the web interface!",
|
"OtaSuccess": "The firmware upload was successful. The device was restarted automatically. When the device is accessible again, the interface is automatically reloaded.",
|
||||||
"FirmwareUpload": "Firmware Upload",
|
"FirmwareUpload": "Firmware Upload",
|
||||||
"UploadProgress": "Upload Progress"
|
"UploadProgress": "Upload Progress"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -549,7 +549,7 @@
|
|||||||
"Back": "Retour",
|
"Back": "Retour",
|
||||||
"Retry": "Réessayer",
|
"Retry": "Réessayer",
|
||||||
"OtaStatus": "Statut OTA",
|
"OtaStatus": "Statut OTA",
|
||||||
"OtaSuccess": "Succès de l'OTA. L'unité a été automatiquement redémarrée et sera à nouveau disponible dans quelques instants. N'oubliez pas de recharger l'interface web !",
|
"OtaSuccess": "Le téléchargement du firmware a réussi. L'appareil a été redémarré automatiquement. Lorsque l'appareil est à nouveau accessible, l'interface est automatiquement rechargée.",
|
||||||
"FirmwareUpload": "Téléversement du firmware",
|
"FirmwareUpload": "Téléversement du firmware",
|
||||||
"UploadProgress": "Progression du téléversement"
|
"UploadProgress": "Progression du téléversement"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -37,9 +37,11 @@
|
|||||||
<span> {{ $t('firmwareupgrade.OtaSuccess') }} </span>
|
<span> {{ $t('firmwareupgrade.OtaSuccess') }} </span>
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<button class="btn btn-primary" @click="clear">
|
<div class="text-center">
|
||||||
<BIconArrowLeft /> {{ $t('firmwareupgrade.Back') }}
|
<div class="spinner-border" role="status">
|
||||||
</button>
|
<span class="visually-hidden"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</CardElement>
|
</CardElement>
|
||||||
|
|
||||||
<CardElement :text="$t('firmwareupgrade.FirmwareUpload')" textVariant="text-bg-primary" center-content
|
<CardElement :text="$t('firmwareupgrade.FirmwareUpload')" textVariant="text-bg-primary" center-content
|
||||||
@ -95,6 +97,7 @@ export default defineComponent({
|
|||||||
OTASuccess: false,
|
OTASuccess: false,
|
||||||
type: "firmware",
|
type: "firmware",
|
||||||
file: {} as Blob,
|
file: {} as Blob,
|
||||||
|
hostCheckInterval: 0
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -142,6 +145,7 @@ export default defineComponent({
|
|||||||
// request.response will hold the response from the server
|
// request.response will hold the response from the server
|
||||||
if (request.status === 200) {
|
if (request.status === 200) {
|
||||||
this.OTASuccess = true;
|
this.OTASuccess = true;
|
||||||
|
this.hostCheckInterval = setInterval(this.checkRemoteHostAndReload, 1000);
|
||||||
} else if (request.status !== 500) {
|
} else if (request.status !== 500) {
|
||||||
this.OTAError = `[HTTP ERROR] ${request.statusText}`;
|
this.OTAError = `[HTTP ERROR] ${request.statusText}`;
|
||||||
} else {
|
} else {
|
||||||
@ -181,6 +185,32 @@ export default defineComponent({
|
|||||||
this.OTAError = "";
|
this.OTAError = "";
|
||||||
this.OTASuccess = false;
|
this.OTASuccess = false;
|
||||||
},
|
},
|
||||||
|
checkRemoteHostAndReload(): void {
|
||||||
|
// Check if the browser is online
|
||||||
|
if (navigator.onLine) {
|
||||||
|
const remoteHostUrl = "/api/system/status";
|
||||||
|
|
||||||
|
// Use a simple fetch request to check if the remote host is reachable
|
||||||
|
fetch(remoteHostUrl, { method: 'HEAD' })
|
||||||
|
.then(response => {
|
||||||
|
// Check if the response status is OK (200-299 range)
|
||||||
|
if (response.ok) {
|
||||||
|
console.log('Remote host is available. Reloading page...');
|
||||||
|
clearInterval(this.hostCheckInterval);
|
||||||
|
this.hostCheckInterval = 0;
|
||||||
|
// Perform a page reload
|
||||||
|
window.location.replace("/");
|
||||||
|
} else {
|
||||||
|
console.log('Remote host is not reachable. Do something else if needed.');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error checking remote host:', error);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log('Browser is offline. Cannot check remote host.');
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
if (!isLoggedIn()) {
|
if (!isLoggedIn()) {
|
||||||
@ -188,5 +218,8 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
},
|
},
|
||||||
|
unmounted() {
|
||||||
|
clearInterval(this.hostCheckInterval);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user