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

@@ -57,7 +57,10 @@ export const alovaInstance = createAlova({
}); });
export const alovaInstanceGH = createAlova({ export const alovaInstanceGH = createAlova({
baseURL: process.env.NODE_ENV === 'development' ? '/gh' : '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, statesHook: ReactHook,
requestAdapter: xhrRequestAdapter() requestAdapter: xhrRequestAdapter()
}); });

View File

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

View File

@@ -2,6 +2,8 @@ import { useEffect, useState } from 'react';
import { toast } from 'react-toastify'; 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 DownloadIcon from '@mui/icons-material/GetApp';
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'; import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
import WarningIcon from '@mui/icons-material/Warning'; import WarningIcon from '@mui/icons-material/Warning';
import { import {
@@ -11,7 +13,6 @@ import {
DialogActions, DialogActions,
DialogContent, DialogContent,
DialogTitle, DialogTitle,
Divider,
Link, Link,
Typography Typography
} from '@mui/material'; } from '@mui/material';
@@ -108,9 +109,13 @@ const Version = () => {
useLayoutTitle('EMS-ESP Firmware'); useLayoutTitle('EMS-ESP Firmware');
// see if we have internet access
const internet_live = const internet_live =
latestDevVersion !== undefined && latestVersion !== undefined; latestDevVersion !== undefined && latestVersion !== undefined;
// check for older boards where auto-upgrade is not supported
const download_only = data && !data.psram;
const renderUploadDialog = () => { const renderUploadDialog = () => {
if (!internet_live) { if (!internet_live) {
return null; return null;
@@ -123,26 +128,15 @@ const Version = () => {
onClose={() => setOpenDialog(false)} onClose={() => setOpenDialog(false)}
> >
<DialogTitle> <DialogTitle>
{LL.INSTALL('') + {(download_only ? LL.DOWNLOAD(0) : LL.INSTALL('')) + ' ' + ' Firmware'}
' ' +
(useDev ? LL.DEVELOPMENT() : LL.STABLE()) +
' Firmware'}
</DialogTitle> </DialogTitle>
<DialogContent dividers> <DialogContent dividers>
<Typography mb={2}> <Typography mb={2}>
{LL.INSTALL_VERSION(useDev ? latestDevVersion : latestVersion)} {LL.INSTALL_VERSION(
download_only ? LL.DOWNLOAD(1) : LL.INSTALL(''),
useDev ? latestDevVersion : latestVersion
)}
</Typography> </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> </DialogContent>
<DialogActions> <DialogActions>
<Button <Button
@@ -153,6 +147,17 @@ const Version = () => {
> >
{LL.CANCEL()} {LL.CANCEL()}
</Button> </Button>
<Button
startIcon={<DownloadIcon />}
variant="outlined"
onClick={() => setOpenDialog(false)}
color="primary"
>
<Link target="_blank" href={getBinURL(useDev)} color="primary">
{LL.DOWNLOAD(1)}
</Link>
</Button>
{!download_only && (
<Button <Button
startIcon={<WarningIcon color="warning" />} startIcon={<WarningIcon color="warning" />}
variant="outlined" variant="outlined"
@@ -161,12 +166,12 @@ const Version = () => {
> >
{LL.INSTALL('')} {LL.INSTALL('')}
</Button> </Button>
)}
</DialogActions> </DialogActions>
</Dialog> </Dialog>
); );
}; };
// useDevVersion = true to force using the dev version
const showFirmwareDialog = (useDevVersion: boolean) => { const showFirmwareDialog = (useDevVersion: boolean) => {
if (useDevVersion || data.emsesp_version.includes('dev')) { if (useDevVersion || data.emsesp_version.includes('dev')) {
setUseDev(true); setUseDev(true);
@@ -184,29 +189,23 @@ const Version = () => {
return ( return (
<> <>
<Box p={2} border="1px solid grey" borderRadius={2}> <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}> <Grid mb={1}>
<Typography mb={1} fontWeight={'fontWeightBold'}> <Typography mb={1} color="secondary">
{LL.VERSION()} {LL.VERSION()}
</Typography> </Typography>
<Typography mb={1} fontWeight={'fontWeightBold'}> <Typography mb={1} color="secondary">
Platform Platform
</Typography> </Typography>
<Typography mb={1} fontWeight={'fontWeightBold'}> <Typography mb={1} color="secondary">
Release Type Release Type
</Typography> </Typography>
{internet_live && (
<>
<Typography mb={1} fontWeight={'fontWeightBold'}>
Latest Stable Release
</Typography>
<Typography fontWeight={'fontWeightBold'}>
Latest Development Release
</Typography>
</>
)}
</Grid> </Grid>
<Grid> <Grid mb={1}>
<Typography mb={1}> <Typography mb={1}>
{data.emsesp_version} {data.emsesp_version}
{data.build_flags && ( {data.build_flags && (
@@ -216,16 +215,10 @@ const Version = () => {
)} )}
</Typography> </Typography>
<Typography mb={1}>{getPlatform()}</Typography> <Typography mb={1}>{getPlatform()}</Typography>
<Typography> <Typography mb={1}>
{isDev ? LL.DEVELOPMENT() : LL.STABLE()}&nbsp; {isDev ? LL.DEVELOPMENT() : LL.STABLE()}
<Link
target="_blank"
href={isDev ? DEV_RELNOTES_URL : STABLE_RELNOTES_URL}
color="primary"
>
(changelog)
</Link>
{!isDev && internet_live && ( {!isDev && internet_live && (
<Typography variant="caption">
<Button <Button
sx={{ ml: 2 }} sx={{ ml: 2 }}
variant="outlined" variant="outlined"
@@ -235,49 +228,87 @@ const Version = () => {
> >
{LL.SWITCH_DEV()} {LL.SWITCH_DEV()}
</Button> </Button>
</Typography>
)} )}
</Typography> </Typography>
{internet_live && ( </Grid>
</Grid>
<Typography sx={{ pb: 2 }} variant="h6" color="primary">
Latest Available Versions
</Typography>
{internet_live ? (
<> <>
<Typography mt={0.3}>{latestVersion}</Typography> <Grid container spacing={4}>
<Typography mt={1} mb={1}> <Grid mb={1}>
{latestDevVersion} <Typography mb={1} color="secondary">
Stable Release
</Typography>
<Typography mb={1} color="secondary">
Development Release
</Typography> </Typography>
</>
)}
</Grid> </Grid>
</Grid> <Grid mb={1}>
<Typography mb={1}>
<Divider /> {latestVersion}&nbsp;&nbsp;
<Link target="_blank" href={STABLE_RELNOTES_URL} color="primary">
<Typography mt={2} color="warning"> (changelog)
<InfoOutlinedIcon color="warning" sx={{ verticalAlign: 'middle' }} /> </Link>
&nbsp;&nbsp; {!isDev && upgradeAvailable && (
{upgradeAvailable ? LL.UPGRADE_AVAILABLE() : LL.LATEST_VERSION()}
{upgradeAvailable &&
internet_live &&
(data.psram ? (
<Button <Button
sx={{ ml: 2, textTransform: 'none' }} sx={{ ml: 2 }}
variant="outlined" variant="outlined"
color="primary" color="warning"
size="small" size="small"
onClick={() => showFirmwareDialog(false)} onClick={() => showFirmwareDialog(false)}
> >
{isDev Upgrade&hellip;
? LL.INSTALL('v' + latestDevVersion)
: LL.INSTALL('v' + latestVersion)}
</Button> </Button>
) : ( )}
<>
&nbsp;&nbsp;
<Link target="_blank" href={getBinURL(isDev)} color="primary">
{LL.DOWNLOAD(1)}&nbsp;v
{isDev ? latestDevVersion : latestVersion}
</Link>
</>
))}
</Typography> </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()} {renderUploadDialog()}
</Box> </Box>

View File

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

View File

@@ -331,7 +331,7 @@ const cz: Translation = {
ALLVALUES: 'Všechny hodnoty', ALLVALUES: 'Všechny hodnoty',
SPECIAL_FUNCTIONS: 'Speciální funkce', SPECIAL_FUNCTIONS: 'Speciální funkce',
WAIT_FIRMWARE: 'Firmware se nahrává a instaluje', 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', SWITCH_DEV: 'přepnout na vývojovou verzi',
UPGRADE_AVAILABLE: 'Je k dispozici aktualizace firmwaru!', UPGRADE_AVAILABLE: 'Je k dispozici aktualizace firmwaru!',
LATEST_VERSION: 'Používáte nejnovější verzi firmwaru.', LATEST_VERSION: 'Používáte nejnovější verzi firmwaru.',

View File

@@ -331,7 +331,7 @@ const de: Translation = {
ALLVALUES: 'Alle Werte', ALLVALUES: 'Alle Werte',
SPECIAL_FUNCTIONS: 'Sonderfunktionen', SPECIAL_FUNCTIONS: 'Sonderfunktionen',
WAIT_FIRMWARE: 'Die Firmware wird hochgeladen und installiert.', 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!', SWITCH_DEV: 'Wechseln Sie zur Entwicklungsversion!',
UPGRADE_AVAILABLE: 'Es ist ein Firmware-Upgrade verfügbar.', UPGRADE_AVAILABLE: 'Es ist ein Firmware-Upgrade verfügbar.',
LATEST_VERSION: 'Sie verwenden die neueste Firmware-Version.', LATEST_VERSION: 'Sie verwenden die neueste Firmware-Version.',

View File

@@ -331,7 +331,7 @@ const en: Translation = {
ALLVALUES: 'All Values', ALLVALUES: 'All Values',
SPECIAL_FUNCTIONS: 'Special Functions', SPECIAL_FUNCTIONS: 'Special Functions',
WAIT_FIRMWARE: 'Firmware is uploading and installing', 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', SWITCH_DEV: 'switch to the development version',
UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', UPGRADE_AVAILABLE: 'There is a firmware upgrade available!',
LATEST_VERSION: 'You are using the latest firmware version.', LATEST_VERSION: 'You are using the latest firmware version.',

View File

@@ -331,7 +331,7 @@ const fr: Translation = {
ALLVALUES: 'All Values', // TODO translate ALLVALUES: 'All Values', // TODO translate
SPECIAL_FUNCTIONS: 'Special Functions', SPECIAL_FUNCTIONS: 'Special Functions',
WAIT_FIRMWARE: 'Firmware is uploading and installing', // 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 SWITCH_DEV: 'switch to the development version', // TODO translate
UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate
LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate

View File

@@ -331,7 +331,7 @@ const it: Translation = {
ALLVALUES: 'All Values', // TODO translate ALLVALUES: 'All Values', // TODO translate
SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate
WAIT_FIRMWARE: 'Firmware is uploading and installing', // 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 SWITCH_DEV: 'switch to the development version', // TODO translate
UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate
LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate

View File

@@ -331,7 +331,7 @@ const nl: Translation = {
ALLVALUES: 'All Values', // TODO translate ALLVALUES: 'All Values', // TODO translate
SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate
WAIT_FIRMWARE: 'Firmware is uploading and installing', // 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 SWITCH_DEV: 'switch to the development version', // TODO translate
UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate
LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate

View File

@@ -331,7 +331,7 @@ const no: Translation = {
ALLVALUES: 'All Values', // TODO translate ALLVALUES: 'All Values', // TODO translate
SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate
WAIT_FIRMWARE: 'Firmware is uploading and installing', // 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 SWITCH_DEV: 'switch to the development version', // TODO translate
UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate
LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate

View File

@@ -331,7 +331,7 @@ const pl: BaseTranslation = {
ALLVALUES: 'All Values', // TODO translate ALLVALUES: 'All Values', // TODO translate
SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate
WAIT_FIRMWARE: 'Firmware is uploading and installing', // 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 SWITCH_DEV: 'switch to the development version', // TODO translate
UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate
LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate

View File

@@ -331,7 +331,7 @@ const sk: Translation = {
ALLVALUES: 'Všetky hodnoty', ALLVALUES: 'Všetky hodnoty',
SPECIAL_FUNCTIONS: 'Špeciálne funkcie', SPECIAL_FUNCTIONS: 'Špeciálne funkcie',
WAIT_FIRMWARE: 'Firmvér sa nahráva a inštaluje', 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', SWITCH_DEV: 'prejsť na vývojovú verziu',
UPGRADE_AVAILABLE: 'K dispozícii je aktualizácia firmvéru!', UPGRADE_AVAILABLE: 'K dispozícii je aktualizácia firmvéru!',
LATEST_VERSION: 'Používate poslednú verziu firmvéru.', LATEST_VERSION: 'Používate poslednú verziu firmvéru.',

View File

@@ -331,7 +331,7 @@ const sv: Translation = {
ALLVALUES: 'All Values', // TODO translate ALLVALUES: 'All Values', // TODO translate
SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate
WAIT_FIRMWARE: 'Firmware is uploading and installing', // 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 SWITCH_DEV: 'switch to the development version', // TODO translate
UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate
LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate

View File

@@ -331,7 +331,7 @@ const tr: Translation = {
ALLVALUES: 'All Values', // TODO translate ALLVALUES: 'All Values', // TODO translate
SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate SPECIAL_FUNCTIONS: 'Special Functions', // TODO translate
WAIT_FIRMWARE: 'Firmware is uploading and installing', // 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 SWITCH_DEV: 'switch to the development version', // TODO translate
UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate UPGRADE_AVAILABLE: 'There is a firmware upgrade available!', // TODO translate
LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate

View File

@@ -35,7 +35,11 @@ let LATEST_STABLE_VERSION = '3.7.0';
let LATEST_DEV_VERSION = '3.7.1-dev.4'; let LATEST_DEV_VERSION = '3.7.1-dev.4';
let VERSION_IS_UPGRADEABLE = false; let VERSION_IS_UPGRADEABLE = false;
// for testing // for testing - scenario 1
// THIS_VERSION = '3.7.1-dev.1';
// VERSION_IS_UPGRADEABLE = true;
// for testing - scenario 2
// THIS_VERSION = '3.6.5'; // THIS_VERSION = '3.6.5';
// VERSION_IS_UPGRADEABLE = true; // VERSION_IS_UPGRADEABLE = true;

View File

@@ -1029,17 +1029,21 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
// request.url("/rest/action"); // request.url("/rest/action");
// EMSESP::webStatusService.action(&request, doc.as<JsonVariant>()); // EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
// should show dev version and be updatable // test version checks
char data5[] = "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.99,3.7.0\"}"; // test with "current_version_s = "3.7.1-dev.8" in WebStatusService::checkUpgrade()
deserializeJson(doc, data5);
request.url("/rest/action"); request.url("/rest/action");
deserializeJson(doc, "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.9,3.7.0\"}"); // is upgradable
EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
deserializeJson(doc, "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.7,3.7.0\"}"); // is not upgradable
EMSESP::webStatusService.action(&request, doc.as<JsonVariant>()); EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
// should show dev version and not be updatable // test with "current_version_s = "3.6.5" in WebStatusService::checkUpgrade()
char data6[] = "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.4,3.7.0\"}"; // request.url("/rest/action");
deserializeJson(doc, data6); // deserializeJson(doc, "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.9,3.6.5\"}"); // is noy upgradable
request.url("/rest/action"); // EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
EMSESP::webStatusService.action(&request, doc.as<JsonVariant>()); // deserializeJson(doc, "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.7,3.7.0\"}"); // is upgradable
// EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
// char data6[] = "{\"device\":\"system\", \"cmd\":\"read\",\"value\":\"8 2 27 1\"}"; // char data6[] = "{\"device\":\"system\", \"cmd\":\"read\",\"value\":\"8 2 27 1\"}";
// deserializeJson(doc, data6); // deserializeJson(doc, data6);

View File

@@ -1 +1 @@
#define EMSESP_APP_VERSION "3.7.1-dev.4" #define EMSESP_APP_VERSION "3.7.1-dev.5"

View File

@@ -203,38 +203,42 @@ void WebStatusService::action(AsyncWebServerRequest * request, JsonVariant json)
} }
// action = checkUpgrade // action = checkUpgrade
// versions holds the latest development version and stable version in one string, comma separated
bool WebStatusService::checkUpgrade(JsonObject root, std::string & versions) { bool WebStatusService::checkUpgrade(JsonObject root, std::string & versions) {
std::string current_version; std::string current_version_s;
#ifndef EMSESP_STANDALONE #ifndef EMSESP_STANDALONE
current_version = EMSESP_APP_VERSION; // always send back current version current_version_s = EMSESP_APP_VERSION;
#else #else
// for testing only // for testing only - see api3 test in test.cpp
// current_version = "3.6.5"; // current_version_s = "3.6.5";
current_version = "3.7.0-dev-7"; current_version_s = "3.7.1-dev.8";
#endif #endif
if (!versions.empty()) { if (!versions.empty()) {
// versions holds the latest development version and stable version in one string, comma separated version::Semver200_version current_version(current_version_s);
std::string latest_dev_version = versions.substr(0, versions.find(',')); bool using_dev_version = !current_version.prerelease().find("dev"); // look for dev in the name to determine if we're using dev version
std::string latest_stable_version = versions.substr(versions.find(',') + 1); version::Semver200_version latest_version(using_dev_version ? versions.substr(0, versions.find(',')) : versions.substr(versions.find(',') + 1));
bool upgradeable = (latest_version > current_version);
version::Semver200_version this_version(current_version);
bool using_dev_version = !this_version.prerelease().find("dev");
version::Semver200_version latest_version(using_dev_version ? latest_dev_version : latest_stable_version); // latest version
root["upgradeable"] = (latest_version > this_version);
#if defined(EMSESP_DEBUG) #if defined(EMSESP_DEBUG)
emsesp::EMSESP::logger().debug("Checking for version upgrade. This version=%s, latest dev=%s, latest stable=%s. Using %s releases. Upgradeable=%s", emsesp::EMSESP::logger()
current_version.c_str(), .debug("Checking Version upgrade. Using %s release branch. current version=%d.%d.%d-%s, latest version=%d.%d.%d-%s (%s upgradeable)",
latest_dev_version.c_str(), (using_dev_version ? "dev" : "stable"),
latest_stable_version.c_str(), current_version.major(),
using_dev_version ? "dev" : "stable", current_version.minor(),
root["upgradeable"].as<bool>() ? "true" : "false"); current_version.patch(),
current_version.prerelease().c_str(),
latest_version.major(),
latest_version.minor(),
latest_version.patch(),
latest_version.prerelease().c_str(),
upgradeable ? "IS" : "NOT");
#endif #endif
root["upgradeable"] = upgradeable;
} }
root["emsesp_version"] = current_version; root["emsesp_version"] = current_version_s; // always send back current version
return true; return true;
} }