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