This commit is contained in:
MichaelDvP
2024-11-10 17:42:02 +01:00
31 changed files with 301 additions and 209 deletions

View File

@@ -57,7 +57,10 @@ export const alovaInstance = createAlova({
});
export const alovaInstanceGH = createAlova({
baseURL: 'https://api.github.com/repos/emsesp/EMS-ESP32/releases',
baseURL:
process.env.NODE_ENV === 'development'
? '/gh'
: 'https://api.github.com/repos/emsesp/EMS-ESP32/releases',
statesHook: ReactHook,
requestAdapter: xhrRequestAdapter()
});

View File

@@ -86,8 +86,8 @@ const Settings = () => {
<ListMenuItem
icon={BuildIcon}
bgcolor="#72caf9"
label={LL.EMS_ESP_VER()}
text={data.emsesp_version}
label="EMS-ESP Firmware"
text={'v' + data.emsesp_version}
to="version"
/>

View File

@@ -1,7 +1,9 @@
import { useState } from 'react';
import { useEffect, useState } from 'react';
import { toast } from 'react-toastify';
import CancelIcon from '@mui/icons-material/Cancel';
import CheckIcon from '@mui/icons-material/Done';
import DownloadIcon from '@mui/icons-material/GetApp';
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
import WarningIcon from '@mui/icons-material/Warning';
import {
@@ -11,7 +13,6 @@ import {
DialogActions,
DialogContent,
DialogTitle,
Divider,
Link,
Typography
} from '@mui/material';
@@ -36,15 +37,13 @@ const Version = () => {
const [upgradeAvailable, setUpgradeAvailable] = useState<boolean>(false);
const { send: sendCheckUpgrade } = useRequest(
(version: string) => callAction({ action: 'checkUpgrade', param: version }),
(versions: string) => callAction({ action: 'checkUpgrade', param: versions }),
{
immediate: false
}
).onSuccess((event) => {
const data = event.data as { emsesp_version: string; upgradeable: boolean };
if (data.upgradeable != undefined) {
setUpgradeAvailable(data.upgradeable);
}
setUpgradeAvailable(data.upgradeable);
});
const { data, send: loadData, error } = useRequest(SystemApi.readSystemStatus);
@@ -56,23 +55,20 @@ const Version = () => {
}
);
// called immediately to get the latest version, on page load
const { data: latestVersion } = useRequest(getStableVersion, {
// uncomment next 2 lines for testing, uses https://github.com/emsesp/EMS-ESP32/releases/download/v3.6.5/EMS-ESP-3_6_5-ESP32-16MB+.bin
// immediate: false,
// initialData: '3.6.5'
}).onSuccess((event) => {
void sendCheckUpgrade(event.data);
});
// called immediately to get the latest versions on page load
const { data: latestVersion } = useRequest(getStableVersion);
const { data: latestDevVersion } = useRequest(getDevVersion);
// called immediately to get the latest version, on page load, then check for upgrade (works for both dev and stable)
const { data: latestDevVersion } = useRequest(getDevVersion, {
// uncomment next 2 lines for testing, uses https://github.com/emsesp/EMS-ESP32/releases/download/latest/EMS-ESP-3_7_0-dev_31-ESP32-16MB+.bin
// immediate: false,
// initialData: '3.7.0-dev.32'
}).onSuccess((event) => {
void sendCheckUpgrade(event.data);
});
useEffect(() => {
if (latestVersion && latestDevVersion) {
// console.log("Latest versions, stable: " + latestVersion + " dev: " + latestDevVersion);
sendCheckUpgrade(latestDevVersion + ',' + latestVersion).catch(
(error: Error) => {
toast.error('Failed to check upgrade: ' + error.message);
}
);
}
}, [latestVersion, latestDevVersion]);
const STABLE_URL = 'https://github.com/emsesp/EMS-ESP32/releases/download/';
const STABLE_RELNOTES_URL =
@@ -111,11 +107,15 @@ const Version = () => {
setRestarting(true);
};
useLayoutTitle(LL.EMS_ESP_VER());
useLayoutTitle('EMS-ESP Firmware');
// see if we have internet access
const internet_live =
latestDevVersion !== undefined && latestVersion !== undefined;
// check for older boards where auto-upgrade is not supported
const download_only = data && !data.psram;
const renderUploadDialog = () => {
if (!internet_live) {
return null;
@@ -128,26 +128,15 @@ const Version = () => {
onClose={() => setOpenDialog(false)}
>
<DialogTitle>
{LL.INSTALL('') +
' ' +
(useDev ? LL.DEVELOPMENT() : LL.STABLE()) +
' Firmware'}
{(download_only ? LL.DOWNLOAD(0) : LL.INSTALL('')) + ' ' + ' Firmware'}
</DialogTitle>
<DialogContent dividers>
<Typography mb={2}>
{LL.INSTALL_VERSION(useDev ? latestDevVersion : latestVersion)}
{LL.INSTALL_VERSION(
download_only ? LL.DOWNLOAD(1) : LL.INSTALL(''),
useDev ? latestDevVersion : latestVersion
)}
</Typography>
<Link
target="_blank"
href={useDev ? DEV_RELNOTES_URL : STABLE_RELNOTES_URL}
color="primary"
>
changelog
</Link>
&nbsp;|&nbsp;
<Link target="_blank" href={getBinURL(useDev)} color="primary">
{LL.DOWNLOAD(1)}
</Link>
</DialogContent>
<DialogActions>
<Button
@@ -159,19 +148,30 @@ const Version = () => {
{LL.CANCEL()}
</Button>
<Button
startIcon={<WarningIcon color="warning" />}
startIcon={<DownloadIcon />}
variant="outlined"
onClick={() => installFirmwareURL(getBinURL(useDev))}
onClick={() => setOpenDialog(false)}
color="primary"
>
{LL.INSTALL('')}
<Link target="_blank" href={getBinURL(useDev)} color="primary">
{LL.DOWNLOAD(1)}
</Link>
</Button>
{!download_only && (
<Button
startIcon={<WarningIcon color="warning" />}
variant="outlined"
onClick={() => installFirmwareURL(getBinURL(useDev))}
color="primary"
>
{LL.INSTALL('')}
</Button>
)}
</DialogActions>
</Dialog>
);
};
// useDevVersion = true to force using the dev version
const showFirmwareDialog = (useDevVersion: boolean) => {
if (useDevVersion || data.emsesp_version.includes('dev')) {
setUseDev(true);
@@ -189,19 +189,23 @@ const Version = () => {
return (
<>
<Box p={2} border="1px solid grey" borderRadius={2}>
<Grid container spacing={3}>
<Typography sx={{ pb: 2 }} variant="h6" color="primary">
Firmware Version
</Typography>
<Grid container spacing={11}>
<Grid mb={1}>
<Typography mb={1} fontWeight={'fontWeightBold'}>
<Typography mb={1} color="secondary">
{LL.VERSION()}
</Typography>
<Typography mb={1} fontWeight={'fontWeightBold'}>
<Typography mb={1} color="secondary">
Platform
</Typography>
<Typography mb={1} fontWeight={'fontWeightBold'}>
Release
<Typography mb={1} color="secondary">
Release Type
</Typography>
</Grid>
<Grid>
<Grid mb={1}>
<Typography mb={1}>
{data.emsesp_version}
{data.build_flags && (
@@ -211,62 +215,101 @@ const Version = () => {
)}
</Typography>
<Typography mb={1}>{getPlatform()}</Typography>
<Typography>
{isDev ? LL.DEVELOPMENT() : LL.STABLE()}&nbsp;
<Link
target="_blank"
href={isDev ? DEV_RELNOTES_URL : STABLE_RELNOTES_URL}
color="primary"
>
(changelog)
</Link>
<Typography mb={1}>
{isDev ? LL.DEVELOPMENT() : LL.STABLE()}
{!isDev && internet_live && (
<Typography variant="caption">
<Button
sx={{ ml: 2 }}
variant="outlined"
color="primary"
size="small"
onClick={() => showFirmwareDialog(true)}
>
{LL.SWITCH_DEV()}
</Button>
</Typography>
)}
</Typography>
</Grid>
</Grid>
<Divider />
{!isDev && (
<Button
sx={{ mt: 2 }}
variant="outlined"
color="primary"
size="small"
onClick={() => showFirmwareDialog(true)}
>
{LL.SWITCH_DEV()}
</Button>
)}
<Typography mt={2} color="warning">
<InfoOutlinedIcon color="warning" sx={{ verticalAlign: 'middle' }} />
&nbsp;&nbsp;
{upgradeAvailable ? LL.UPGRADE_AVAILABLE() : LL.LATEST_VERSION()}
{upgradeAvailable &&
internet_live &&
(data.psram ? (
<Button
sx={{ ml: 2, textTransform: 'none' }}
variant="outlined"
color="primary"
size="small"
onClick={() => showFirmwareDialog(false)}
>
{isDev
? LL.INSTALL('v' + latestDevVersion)
: LL.INSTALL('v' + latestVersion)}
</Button>
) : (
<>
&nbsp;&nbsp;
<Link target="_blank" href={getBinURL(isDev)} color="primary">
{LL.DOWNLOAD(1)}&nbsp;v
{isDev ? latestDevVersion : latestVersion}
</Link>
</>
))}
<Typography sx={{ pb: 2 }} variant="h6" color="primary">
Latest Available Versions
</Typography>
{internet_live ? (
<>
<Grid container spacing={4}>
<Grid mb={1}>
<Typography mb={1} color="secondary">
Stable Release
</Typography>
<Typography mb={1} color="secondary">
Development Release
</Typography>
</Grid>
<Grid mb={1}>
<Typography mb={1}>
{latestVersion}&nbsp;&nbsp;
<Link target="_blank" href={STABLE_RELNOTES_URL} color="primary">
(changelog)
</Link>
{!isDev && upgradeAvailable && (
<Button
sx={{ ml: 2 }}
variant="outlined"
color="warning"
size="small"
onClick={() => showFirmwareDialog(false)}
>
Upgrade&hellip;
</Button>
)}
</Typography>
<Typography mb={1}>
{latestDevVersion}&nbsp;&nbsp;
<Link target="_blank" href={DEV_RELNOTES_URL} color="primary">
(changelog)
</Link>
{isDev && upgradeAvailable && (
<Button
sx={{ ml: 2 }}
variant="outlined"
color="warning"
size="small"
onClick={() => showFirmwareDialog(false)}
>
Upgrade&hellip;
</Button>
)}
</Typography>
</Grid>
</Grid>
{upgradeAvailable ? (
<Typography color="warning">
<InfoOutlinedIcon
color="warning"
sx={{ verticalAlign: 'middle', mr: 2 }}
/>
{LL.UPGRADE_AVAILABLE()}
</Typography>
) : (
<Typography color="success">
<CheckIcon
color="success"
sx={{ verticalAlign: 'middle', mr: 2 }}
/>
{LL.LATEST_VERSION()}
</Typography>
)}
</>
) : (
<Typography mb={1} color="warning">
not online
</Typography>
)}
{renderUploadDialog()}
</Box>
</>

View File

@@ -2,9 +2,9 @@ import { useContext, useState } from 'react';
import { useBlocker } from 'react-router-dom';
import CancelIcon from '@mui/icons-material/Cancel';
import CheckIcon from '@mui/icons-material/Check';
import CloseIcon from '@mui/icons-material/Close';
import DeleteIcon from '@mui/icons-material/Delete';
import CheckIcon from '@mui/icons-material/Done';
import EditIcon from '@mui/icons-material/Edit';
import PersonAddIcon from '@mui/icons-material/PersonAdd';
import VpnKeyIcon from '@mui/icons-material/VpnKey';

View File

@@ -177,7 +177,6 @@ const cz: Translation = {
SYSTEM_FACTORY_TEXT_DIALOG: 'Opravdu chcete resetovat zařízení EMS-ESP do továrního nastavení?',
STABLE: 'Stabilní',
DEVELOPMENT: 'Vývojová verze',
EMS_ESP_VER: 'Verze firmwaru',
UPTIME: 'Doba provozu systému',
FREE_MEMORY: 'Volná paměť',
PSRAM: 'PSRAM (Velikost / Volná)',
@@ -332,7 +331,7 @@ const cz: Translation = {
ALLVALUES: 'Všechny hodnoty',
SPECIAL_FUNCTIONS: 'Speciální funkce',
WAIT_FIRMWARE: 'Firmware se nahrává a instaluje',
INSTALL_VERSION: 'Tímto se nainstaluje verze {0}. Jste si jistí?',
INSTALL_VERSION: 'Tímto se {0} verze {1}. Jste si jistí?',
SWITCH_DEV: 'přepnout na vývojovou verzi',
UPGRADE_AVAILABLE: 'Je k dispozici aktualizace firmwaru!',
LATEST_VERSION: 'Používáte nejnovější verzi firmwaru.',

View File

@@ -177,7 +177,6 @@ const de: Translation = {
SYSTEM_FACTORY_TEXT_DIALOG: 'Sind Sie sicher, alle Einstellungen auf Werkseinstellung zu setzen?',
STABLE: 'Stabil',
DEVELOPMENT: 'Entwicklung',
EMS_ESP_VER: 'Firmware-Version',
UPTIME: 'Systembetriebszeit',
FREE_MEMORY: 'Freier RAM Speicher',
PSRAM: 'PSRAM (Größe / Frei)',
@@ -332,7 +331,7 @@ const de: Translation = {
ALLVALUES: 'Alle Werte',
SPECIAL_FUNCTIONS: 'Sonderfunktionen',
WAIT_FIRMWARE: 'Die Firmware wird hochgeladen und installiert.',
INSTALL_VERSION: 'Dadurch wird die Version installiert {0}. Sind Sie sicher?',
INSTALL_VERSION: 'Dadurch wird die Version {0} {1}. Sind Sie sicher?',
SWITCH_DEV: 'Wechseln Sie zur Entwicklungsversion!',
UPGRADE_AVAILABLE: 'Es ist ein Firmware-Upgrade verfügbar.',
LATEST_VERSION: 'Sie verwenden die neueste Firmware-Version.',

View File

@@ -177,7 +177,6 @@ const en: Translation = {
SYSTEM_FACTORY_TEXT_DIALOG: 'Are you sure you want to reset EMS-ESP to its factory defaults?',
STABLE: 'Stable',
DEVELOPMENT: 'Development',
EMS_ESP_VER: 'Firmware Version',
UPTIME: 'System Uptime',
FREE_MEMORY: 'Free Memory',
PSRAM: 'PSRAM (Size / Free)',
@@ -332,7 +331,7 @@ const en: Translation = {
ALLVALUES: 'All Values',
SPECIAL_FUNCTIONS: 'Special Functions',
WAIT_FIRMWARE: 'Firmware is uploading and installing',
INSTALL_VERSION: 'This will install version {0}. Are you sure?',
INSTALL_VERSION: 'This will {0} version {1}. Are you sure?',
SWITCH_DEV: 'switch to the development version',
UPGRADE_AVAILABLE: 'There is a firmware upgrade available!',
LATEST_VERSION: 'You are using the latest firmware version.',

View File

@@ -177,7 +177,6 @@ const fr: Translation = {
SYSTEM_FACTORY_TEXT_DIALOG: "Êtes-vous sûr de vouloir réinitialiser l'appareil à ses paramètres d'usine ?",
STABLE: 'Stable', // TODO translate
DEVELOPMENT: 'Développement',
EMS_ESP_VER: 'Firmware Version', // TODO translate
UPTIME: 'Durée de fonctionnement du système',
FREE_MEMORY: 'Libre Memory',
PSRAM: 'PSRAM (Taille / Libre)',
@@ -332,7 +331,7 @@ const fr: Translation = {
ALLVALUES: 'All Values', // TODO translate
SPECIAL_FUNCTIONS: 'Special Functions',
WAIT_FIRMWARE: 'Firmware is uploading and installing', // TODO translate
INSTALL_VERSION: 'This will install version {0}. Are you sure?', // TODO translate
INSTALL_VERSION: 'This will {0} version {1}. Are you sure?', // TODO translate
SWITCH_DEV: 'switch to the development version', // TODO translate
UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate
LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate

View File

@@ -177,7 +177,6 @@ const it: Translation = {
SYSTEM_FACTORY_TEXT_DIALOG: 'Sei sicuro di voler ripristinare il dispositivo alle impostazioni di fabbrica??',
STABLE: 'Stable', // TODO translate
DEVELOPMENT: 'Sviluppo',
EMS_ESP_VER: 'Versione Firmware',
UPTIME: 'Tempo di attività del sistema',
FREE_MEMORY: 'Free Memory',
PSRAM: 'PSRAM (Size / Free)',
@@ -332,7 +331,7 @@ const it: Translation = {
ALLVALUES: 'All Values', // TODO translate
SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate
WAIT_FIRMWARE: 'Firmware is uploading and installing', // TODO translate
INSTALL_VERSION: 'This will install version {0}. Are you sure?', // TODO translate
INSTALL_VERSION: 'This will {0} version {1}. Are you sure?', // TODO translate
SWITCH_DEV: 'switch to the development version', // TODO translate
UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate
LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate

View File

@@ -177,7 +177,6 @@ const nl: Translation = {
SYSTEM_FACTORY_TEXT_DIALOG: 'Weet je zeker dat je een reset naar fabrieksinstellingen uit wilt voeren?',
STABLE: 'Stable',
DEVELOPMENT: 'Development',
EMS_ESP_VER: 'Firmware Versie',
UPTIME: 'Systeem Uptime',
FREE_MEMORY: 'Free Memory',
PSRAM: 'PSRAM (Size / Free)',
@@ -332,7 +331,7 @@ const nl: Translation = {
ALLVALUES: 'All Values', // TODO translate
SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate
WAIT_FIRMWARE: 'Firmware is uploading and installing', // TODO translate
INSTALL_VERSION: 'This will install version {0}. Are you sure?', // TODO translate
INSTALL_VERSION: 'This will {0} version {1}. Are you sure?', // TODO translate
SWITCH_DEV: 'switch to the development version', // TODO translate
UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate
LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate

View File

@@ -177,7 +177,6 @@ const no: Translation = {
SYSTEM_FACTORY_TEXT_DIALOG: 'Er du sikker på at du vil resette enheten til fabrikkinstillinger?',
STABLE: 'Stable', // TODO translate
DEVELOPMENT: 'Development',
EMS_ESP_VER: 'Firmware Version', // TODO translate
UPTIME: 'System Oppetid',
FREE_MEMORY: 'Ledig Memory',
PSRAM: 'PSRAM (Størrelse / Ledig)',
@@ -332,7 +331,7 @@ const no: Translation = {
ALLVALUES: 'All Values', // TODO translate
SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate
WAIT_FIRMWARE: 'Firmware is uploading and installing', // TODO translate
INSTALL_VERSION: 'This will install version {0}. Are you sure?', // TODO translate
INSTALL_VERSION: 'This will {0} version {1}. Are you sure?', // TODO translate
SWITCH_DEV: 'switch to the development version', // TODO translate
UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate
LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate

View File

@@ -177,7 +177,6 @@ const pl: BaseTranslation = {
SYSTEM_FACTORY_TEXT_DIALOG: 'Na pewno chcesz przywrócić ustawienia fabryczne interfejsu EMS-ESP?',
STABLE: 'Stable', // TODO translate
DEVELOPMENT: 'Testowe',
EMS_ESP_VER: 'Wersja Firmware',
UPTIME: 'Czas działania systemu',
FREE_MEMORY: 'Wolne Memory',
PSRAM: 'PSRAM (rozmiar / wolne)',
@@ -332,7 +331,7 @@ const pl: BaseTranslation = {
ALLVALUES: 'All Values', // TODO translate
SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate
WAIT_FIRMWARE: 'Firmware is uploading and installing', // TODO translate
INSTALL_VERSION: 'This will install version {0}. Are you sure?', // TODO translate
INSTALL_VERSION: 'This will {0} version {1}. Are you sure?', // TODO translate
SWITCH_DEV: 'switch to the development version', // TODO translate
UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate
LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate

View File

@@ -177,7 +177,6 @@ const sk: Translation = {
SYSTEM_FACTORY_TEXT_DIALOG: 'Naozaj chcete resetovať EMS-ESP na predvolené výrobné nastavenia?',
STABLE: 'Stabilná',
DEVELOPMENT: 'Vývojárska',
EMS_ESP_VER: 'Firmware verzia',
UPTIME: 'Beh systému',
FREE_MEMORY: 'Voľné Memory',
PSRAM: 'PSRAM (Veľkosť / Voľné)',
@@ -332,7 +331,7 @@ const sk: Translation = {
ALLVALUES: 'Všetky hodnoty',
SPECIAL_FUNCTIONS: 'Špeciálne funkcie',
WAIT_FIRMWARE: 'Firmvér sa nahráva a inštaluje',
INSTALL_VERSION: 'Týmto sa nainštaluje verzia {0}. Si si istý?',
INSTALL_VERSION: 'Týmto sa {0} verzia {1}. Si si istý?',
SWITCH_DEV: 'prejsť na vývojovú verziu',
UPGRADE_AVAILABLE: 'K dispozícii je aktualizácia firmvéru!',
LATEST_VERSION: 'Používate poslednú verziu firmvéru.',

View File

@@ -177,7 +177,6 @@ const sv: Translation = {
SYSTEM_FACTORY_TEXT_DIALOG: 'Är du säker att du vill fabriksåterställa enheten?',
STABLE: 'Stable', // TODO translate
DEVELOPMENT: 'Utveckling',
EMS_ESP_VER: 'Firmware Version', // TODO translate
UPTIME: 'Systemets Upptid',
FREE_MEMORY: 'Ledigt Memory',
PSRAM: 'PSRAM (Storlek / Ledigt)',
@@ -332,7 +331,7 @@ const sv: Translation = {
ALLVALUES: 'All Values', // TODO translate
SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate
WAIT_FIRMWARE: 'Firmware is uploading and installing', // TODO translate
INSTALL_VERSION: 'This will install version {0}. Are you sure?', // TODO translate
INSTALL_VERSION: 'This will {0} version {1}. Are you sure?', // TODO translate
SWITCH_DEV: 'switch to the development version', // TODO translate
UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate
LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate

View File

@@ -177,7 +177,6 @@ const tr: Translation = {
SYSTEM_FACTORY_TEXT_DIALOG: 'Cihazı fabrika ayarlarına döndürmek istediğinize emin misiniz?',
STABLE: 'Stable', // TODO translate
DEVELOPMENT: 'Geliştirme',
EMS_ESP_VER: 'Firmware Sürümü',
UPTIME: 'Sistem Çalışma Süresi',
FREE_MEMORY: 'Yığın Memory',
PSRAM: 'PSRAM (Boyut / Boş)',
@@ -332,7 +331,7 @@ const tr: Translation = {
ALLVALUES: 'All Values', // TODO translate
SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate
WAIT_FIRMWARE: 'Firmware is uploading and installing', // TODO translate
INSTALL_VERSION: 'This will install version {0}. Are you sure?', // TODO translate
INSTALL_VERSION: 'This will {0} version {1}. Are you sure?', // TODO translate
SWITCH_DEV: 'switch to the development version', // TODO translate
UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate
LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate