mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-01-31 02:59:10 +03:00
switch between dev and stable
This commit is contained in:
@@ -4,7 +4,6 @@ import { toast } from 'react-toastify';
|
|||||||
import CancelIcon from '@mui/icons-material/Cancel';
|
import CancelIcon from '@mui/icons-material/Cancel';
|
||||||
import CheckIcon from '@mui/icons-material/Done';
|
import CheckIcon from '@mui/icons-material/Done';
|
||||||
import DownloadIcon from '@mui/icons-material/GetApp';
|
import DownloadIcon from '@mui/icons-material/GetApp';
|
||||||
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
|
|
||||||
import WarningIcon from '@mui/icons-material/Warning';
|
import WarningIcon from '@mui/icons-material/Warning';
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
@@ -44,6 +43,7 @@ const Version = () => {
|
|||||||
const [restarting, setRestarting] = useState<boolean>(false);
|
const [restarting, setRestarting] = useState<boolean>(false);
|
||||||
const [openInstallDialog, setOpenInstallDialog] = useState<boolean>(false);
|
const [openInstallDialog, setOpenInstallDialog] = useState<boolean>(false);
|
||||||
const [usingDevVersion, setUsingDevVersion] = useState<boolean>(false);
|
const [usingDevVersion, setUsingDevVersion] = useState<boolean>(false);
|
||||||
|
const [fetchDevVersion, setFetchDevVersion] = useState<boolean>(false);
|
||||||
const [devUpgradeAvailable, setDevUpgradeAvailable] = useState<boolean>(false);
|
const [devUpgradeAvailable, setDevUpgradeAvailable] = useState<boolean>(false);
|
||||||
const [stableUpgradeAvailable, setStableUpgradeAvailable] =
|
const [stableUpgradeAvailable, setStableUpgradeAvailable] =
|
||||||
useState<boolean>(false);
|
useState<boolean>(false);
|
||||||
@@ -151,14 +151,14 @@ const Version = () => {
|
|||||||
}
|
}
|
||||||
const filename =
|
const filename =
|
||||||
'EMS-ESP-' +
|
'EMS-ESP-' +
|
||||||
(usingDevVersion ? latestDevVersion.name : latestVersion.name).replaceAll(
|
(fetchDevVersion ? latestDevVersion.name : latestVersion.name).replaceAll(
|
||||||
'.',
|
'.',
|
||||||
'_'
|
'_'
|
||||||
) +
|
) +
|
||||||
'-' +
|
'-' +
|
||||||
getPlatform() +
|
getPlatform() +
|
||||||
'.bin';
|
'.bin';
|
||||||
return usingDevVersion
|
return fetchDevVersion
|
||||||
? DEV_URL + filename
|
? DEV_URL + filename
|
||||||
: STABLE_URL + 'v' + latestVersion.name + '/' + filename;
|
: STABLE_URL + 'v' + latestVersion.name + '/' + filename;
|
||||||
};
|
};
|
||||||
@@ -191,13 +191,13 @@ const Version = () => {
|
|||||||
<DialogTitle>
|
<DialogTitle>
|
||||||
{LL.INSTALL() +
|
{LL.INSTALL() +
|
||||||
' ' +
|
' ' +
|
||||||
(usingDevVersion ? LL.DEVELOPMENT() : LL.STABLE()) +
|
(fetchDevVersion ? LL.DEVELOPMENT() : LL.STABLE()) +
|
||||||
' Firmware'}
|
' Firmware'}
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<DialogContent dividers>
|
<DialogContent dividers>
|
||||||
<Typography mb={2}>
|
<Typography mb={2}>
|
||||||
{LL.INSTALL_VERSION(
|
{LL.INSTALL_VERSION(
|
||||||
usingDevVersion ? latestDevVersion?.name : latestVersion?.name
|
fetchDevVersion ? latestDevVersion?.name : latestVersion?.name
|
||||||
)}
|
)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
@@ -233,22 +233,43 @@ const Version = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const showFirmwareDialog = (useDevVersion?: boolean) => {
|
const showFirmwareDialog = (useDevVersion: boolean) => {
|
||||||
setUsingDevVersion(useDevVersion || usingDevVersion);
|
setFetchDevVersion(useDevVersion);
|
||||||
setOpenInstallDialog(true);
|
setOpenInstallDialog(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeInstallDialog = () => {
|
const closeInstallDialog = () => {
|
||||||
setOpenInstallDialog(false);
|
setOpenInstallDialog(false);
|
||||||
setUsingDevVersion(data.emsesp_version.includes('dev'));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const showButtons = (showDev: boolean) => {
|
const showButtons = (showingDev: boolean) => {
|
||||||
if (
|
const choice = showingDev
|
||||||
!me.admin ||
|
? !usingDevVersion
|
||||||
(showDev && !devUpgradeAvailable) ||
|
? LL.SWITCH_RELEASE_TYPE(LL.DEVELOPMENT())
|
||||||
(!showDev && !stableUpgradeAvailable)
|
: devUpgradeAvailable
|
||||||
) {
|
? LL.UPDATE_AVAILABLE()
|
||||||
|
: undefined
|
||||||
|
: usingDevVersion
|
||||||
|
? LL.SWITCH_RELEASE_TYPE(LL.STABLE())
|
||||||
|
: stableUpgradeAvailable
|
||||||
|
? LL.UPDATE_AVAILABLE()
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
if (!choice) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<CheckIcon
|
||||||
|
color="success"
|
||||||
|
sx={{ verticalAlign: 'middle', ml: 0.5, mr: 0.5 }}
|
||||||
|
/>
|
||||||
|
<span style={{ color: '#66bb6a', fontSize: '0.8em' }}>
|
||||||
|
{LL.LATEST_VERSION(usingDevVersion ? LL.DEVELOPMENT() : LL.STABLE())}
|
||||||
|
</span>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!me.admin) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,15 +294,11 @@ const Version = () => {
|
|||||||
<Button
|
<Button
|
||||||
sx={{ ml: 2 }}
|
sx={{ ml: 2 }}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
color="warning"
|
color={choice === LL.UPDATE_AVAILABLE() ? 'success' : 'warning'}
|
||||||
size="small"
|
size="small"
|
||||||
onClick={() => showFirmwareDialog(showDev)}
|
onClick={() => showFirmwareDialog(showingDev)}
|
||||||
>
|
>
|
||||||
{(devUpgradeAvailable && showDev) || (stableUpgradeAvailable && !showDev)
|
{choice}
|
||||||
? showDev && !usingDevVersion
|
|
||||||
? LL.SWITCH_RELEASE_TYPE()
|
|
||||||
: LL.UPGRADE()
|
|
||||||
: LL.INSTALL()}
|
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -411,7 +428,7 @@ const Version = () => {
|
|||||||
{formatTimeAgo(new Date(latestVersion.published_at))})
|
{formatTimeAgo(new Date(latestVersion.published_at))})
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
{!usingDevVersion && showButtons(false)}
|
{showButtons(false)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
@@ -433,26 +450,6 @@ const Version = () => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
{(devUpgradeAvailable && usingDevVersion) ||
|
|
||||||
(stableUpgradeAvailable && !usingDevVersion) ? (
|
|
||||||
<Typography mt={2} color="warning">
|
|
||||||
<InfoOutlinedIcon
|
|
||||||
color="warning"
|
|
||||||
sx={{ verticalAlign: 'middle', mr: 2 }}
|
|
||||||
/>
|
|
||||||
{LL.UPGRADE_AVAILABLE()}
|
|
||||||
</Typography>
|
|
||||||
) : (
|
|
||||||
<Typography mt={2} color="success">
|
|
||||||
<CheckIcon
|
|
||||||
color="success"
|
|
||||||
sx={{ verticalAlign: 'middle', mr: 2 }}
|
|
||||||
/>
|
|
||||||
{LL.LATEST_VERSION(
|
|
||||||
usingDevVersion ? LL.DEVELOPMENT() : LL.STABLE()
|
|
||||||
)}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<Typography mt={2} color="warning">
|
<Typography mt={2} color="warning">
|
||||||
|
|||||||
Reference in New Issue
Block a user