Add auto-update functionality
This commit is contained in:
parent
1c2d8dcdd0
commit
6c40b54273
7 changed files with 45 additions and 8 deletions
|
@ -81,7 +81,8 @@
|
|||
"swUpdateAvailable": "Eine neuere Version ist verfügbar!",
|
||||
"latestVersion": "Letzte Version",
|
||||
"releaseDate": "Veröffentlichungsdatum",
|
||||
"viewRelease": "Veröffentlichung anzeigen"
|
||||
"viewRelease": "Veröffentlichung anzeigen",
|
||||
"autoUpdate": "Update installieren (experimentell)"
|
||||
}
|
||||
},
|
||||
"colors": {
|
||||
|
|
|
@ -94,7 +94,8 @@
|
|||
"swUpToDate": "You are up to date.",
|
||||
"latestVersion": "Latest Version",
|
||||
"releaseDate": "Release Date",
|
||||
"viewRelease": "View Release"
|
||||
"viewRelease": "View Release",
|
||||
"autoUpdate": "Install update (experimental)"
|
||||
}
|
||||
},
|
||||
"colors": {
|
||||
|
|
|
@ -80,7 +80,8 @@
|
|||
"swUpdateAvailable": "¡Una nueva versión está disponible!",
|
||||
"latestVersion": "Ultima versión",
|
||||
"releaseDate": "Fecha de lanzamiento",
|
||||
"viewRelease": "Ver lanzamiento"
|
||||
"viewRelease": "Ver lanzamiento",
|
||||
"autoUpdate": "Instalar actualización (experimental)"
|
||||
}
|
||||
},
|
||||
"button": {
|
||||
|
|
|
@ -80,7 +80,8 @@
|
|||
"swUpdateAvailable": "Een nieuwere versie is beschikbaar!",
|
||||
"latestVersion": "Laatste versie",
|
||||
"releaseDate": "Datum van publicatie",
|
||||
"viewRelease": "Bekijk publicatie"
|
||||
"viewRelease": "Bekijk publicatie",
|
||||
"autoUpdate": "Update installeren (experimenteel)"
|
||||
}
|
||||
},
|
||||
"colors": {
|
||||
|
|
|
@ -124,7 +124,7 @@
|
|||
|
||||
<Container fluid>
|
||||
<Row>
|
||||
<Control bind:settings bind:status lg="3" xxl="4"></Control>
|
||||
<Control bind:settings on:showToast={showToast} bind:status lg="3" xxl="4"></Control>
|
||||
<Status bind:settings bind:status lg="6" xxl="4"></Status>
|
||||
<Settings bind:settings on:showToast={showToast} on:formReset={fetchSettingsData} lg="3" xxl="4"
|
||||
></Settings>
|
||||
|
|
|
@ -239,7 +239,7 @@
|
|||
{#if $settings.otaEnabled}
|
||||
<hr />
|
||||
<h3>{$_('section.control.firmwareUpdate')}</h3>
|
||||
<FirmwareUpdater bind:settings />
|
||||
<FirmwareUpdater on:showToast bind:settings />
|
||||
{/if}
|
||||
</CardBody>
|
||||
</Card>
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<script lang="ts">
|
||||
import { PUBLIC_BASE_URL } from '$lib/config';
|
||||
import { onMount } from 'svelte';
|
||||
import { createEventDispatcher, onMount } from 'svelte';
|
||||
import { _ } from 'svelte-i18n';
|
||||
import { writable } from 'svelte/store';
|
||||
import { Progress, Alert, Button } from '@sveltestrap/sveltestrap';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
export let settings = { hwRev: '' };
|
||||
|
||||
let currentVersion: string = $settings.gitTag; // Replace with your current version
|
||||
|
@ -107,6 +109,36 @@
|
|||
return binaryFilename;
|
||||
};
|
||||
|
||||
const onAutoUpdate = async (e: Event) => {
|
||||
e.preventDefault();
|
||||
|
||||
try {
|
||||
const response = await fetch(`${PUBLIC_BASE_URL}/api/firmware/auto_update`);
|
||||
|
||||
if (!response.ok) {
|
||||
let msg = (await response.json()).msg;
|
||||
|
||||
dispatch('showToast', {
|
||||
color: 'danger',
|
||||
text: msg
|
||||
});
|
||||
} else {
|
||||
let msg = (await response.json()).msg;
|
||||
|
||||
dispatch('showToast', {
|
||||
color: 'info',
|
||||
text: msg
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
dispatch('showToast', {
|
||||
color: 'danger',
|
||||
text: error
|
||||
});
|
||||
console.error('Error fetching latest version:', error);
|
||||
}
|
||||
};
|
||||
|
||||
onMount(async () => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
|
@ -153,7 +185,8 @@
|
|||
)}: {releaseDate} -
|
||||
<a href={releaseUrl} target="_blank">{$_('section.firmwareUpdater.viewRelease')}</a><br />
|
||||
{#if isNewerVersionAvailable}
|
||||
{$_('section.firmwareUpdater.swUpdateAvailable')}
|
||||
{$_('section.firmwareUpdater.swUpdateAvailable')} -
|
||||
<a href="/" on:click={onAutoUpdate}>{$_('section.firmwareUpdater.autoUpdate')}</a>.
|
||||
{:else}
|
||||
{$_('section.firmwareUpdater.swUpToDate')}
|
||||
{/if}
|
||||
|
|
Loading…
Reference in a new issue