This commit is contained in:
proddy
2024-11-10 16:52:39 +01:00
parent 00beb2a039
commit 6b3cb00917
19 changed files with 182 additions and 136 deletions

View File

@@ -2,6 +2,8 @@ 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';
@@ -108,9 +109,13 @@ const Version = () => {
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;
@@ -123,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
@@ -154,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);
@@ -184,29 +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'}>
<Typography mb={1} color="secondary">
Release Type
</Typography>
{internet_live && (
<>
<Typography mb={1} fontWeight={'fontWeightBold'}>
Latest Stable Release
</Typography>
<Typography fontWeight={'fontWeightBold'}>
Latest Development Release
</Typography>
</>
)}
</Grid>
<Grid>
<Grid mb={1}>
<Typography mb={1}>
{data.emsesp_version}
{data.build_flags && (
@@ -216,69 +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 && (
<Button
sx={{ ml: 2 }}
variant="outlined"
color="primary"
size="small"
onClick={() => showFirmwareDialog(true)}
>
{LL.SWITCH_DEV()}
</Button>
<Typography variant="caption">
<Button
sx={{ ml: 2 }}
variant="outlined"
color="primary"
size="small"
onClick={() => showFirmwareDialog(true)}
>
{LL.SWITCH_DEV()}
</Button>
</Typography>
)}
</Typography>
{internet_live && (
<>
<Typography mt={0.3}>{latestVersion}</Typography>
<Typography mt={1} mb={1}>
{latestDevVersion}
</Typography>
</>
)}
</Grid>
</Grid>
<Divider />
<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>
</>