rename to stored version, use same infoDialog

This commit is contained in:
proddy
2025-12-24 12:54:08 +01:00
parent 0557def0b6
commit 71281bc82d
14 changed files with 123 additions and 106 deletions

View File

@@ -86,8 +86,9 @@ const VersionInfoDialog = memo(
showVersionInfo, showVersionInfo,
latestVersion, latestVersion,
latestDevVersion, latestDevVersion,
previousVersion, partitionVersion,
partition, partition,
currentPartition,
size, size,
locale, locale,
LL, LL,
@@ -96,8 +97,9 @@ const VersionInfoDialog = memo(
showVersionInfo: number; showVersionInfo: number;
latestVersion?: VersionInfo; latestVersion?: VersionInfo;
latestDevVersion?: VersionInfo; latestDevVersion?: VersionInfo;
previousVersion?: VersionInfo | undefined; partitionVersion?: VersionInfo | undefined;
partition: string; partition: string;
currentPartition: string;
size: number; size: number;
locale: string; locale: string;
LL: TranslationFunctions; LL: TranslationFunctions;
@@ -107,13 +109,13 @@ const VersionInfoDialog = memo(
const isStable = showVersionInfo === 1; const isStable = showVersionInfo === 1;
const isDev = showVersionInfo === 2; const isDev = showVersionInfo === 2;
const isPrevious = showVersionInfo === 3; const isPartition = showVersionInfo === 3;
const version = isStable const version = isStable
? latestVersion ? latestVersion
: isDev : isDev
? latestDevVersion ? latestDevVersion
: previousVersion; : partitionVersion;
const relNotesUrl = isStable const relNotesUrl = isStable
? STABLE_RELNOTES_URL ? STABLE_RELNOTES_URL
: isDev : isDev
@@ -135,18 +137,17 @@ const VersionInfoDialog = memo(
borderBottom: 'none', borderBottom: 'none',
pr: 1, pr: 1,
py: 0.5, py: 0.5,
fontSize: 13, fontSize: 13
width: 140
}} }}
> >
{isPrevious ? LL.TYPE(0) : LL.RELEASE_TYPE()} {LL.VERSION()}
</TableCell> </TableCell>
<TableCell sx={{ borderBottom: 'none', py: 0.5, fontSize: 13 }}> <TableCell sx={{ borderBottom: 'none', py: 0.5, fontSize: 13 }}>
{isStable {isPartition
? LL.STABLE() ? typeof version === 'string'
: isDev ? version
? LL.DEVELOPMENT() : version?.name
: 'Partition ' + LL.VERSION()} : version?.name}
</TableCell> </TableCell>
</TableRow> </TableRow>
<TableRow sx={{ height: 24, borderBottom: 'none' }}> <TableRow sx={{ height: 24, borderBottom: 'none' }}>
@@ -158,20 +159,22 @@ const VersionInfoDialog = memo(
borderBottom: 'none', borderBottom: 'none',
pr: 1, pr: 1,
py: 0.5, py: 0.5,
fontSize: 13 fontSize: 13,
width: 140
}} }}
> >
{LL.VERSION()} {isPartition ? LL.TYPE(0) : LL.RELEASE_TYPE()}
</TableCell> </TableCell>
<TableCell sx={{ borderBottom: 'none', py: 0.5, fontSize: 13 }}> <TableCell sx={{ borderBottom: 'none', py: 0.5, fontSize: 13 }}>
{isPrevious {partition === currentPartition && LL.ACTIVE() + ' '}
? typeof version === 'string' {isStable
? version ? LL.STABLE()
: version?.name : isDev
: version?.name} ? LL.DEVELOPMENT()
: 'Partition ' + LL.VERSION()}
</TableCell> </TableCell>
</TableRow> </TableRow>
{isPrevious && ( {isPartition && (
<TableRow sx={{ height: 24, borderBottom: 'none' }}> <TableRow sx={{ height: 24, borderBottom: 'none' }}>
<TableCell <TableCell
component="th" component="th"
@@ -191,7 +194,7 @@ const VersionInfoDialog = memo(
</TableCell> </TableCell>
</TableRow> </TableRow>
)} )}
{isPrevious && ( {isPartition && (
<TableRow sx={{ height: 24, borderBottom: 'none' }}> <TableRow sx={{ height: 24, borderBottom: 'none' }}>
<TableCell <TableCell
component="th" component="th"
@@ -224,7 +227,7 @@ const VersionInfoDialog = memo(
fontSize: 13 fontSize: 13
}} }}
> >
{isPrevious ? 'Install Date' : 'Build Date'} {isPartition ? 'Install Date' : 'Build Date'}
</TableCell> </TableCell>
<TableCell sx={{ borderBottom: 'none', py: 0.5, fontSize: 13 }}> <TableCell sx={{ borderBottom: 'none', py: 0.5, fontSize: 13 }}>
{prettyDateTime(locale, new Date(version.published_at))} {prettyDateTime(locale, new Date(version.published_at))}
@@ -235,7 +238,7 @@ const VersionInfoDialog = memo(
</Table> </Table>
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
{!isPrevious && ( {!isPartition && (
<Button <Button
variant="outlined" variant="outlined"
component="a" component="a"
@@ -336,16 +339,16 @@ const InstallDialog = memo(
} }
); );
const InstallPreviousDialog = memo( const InstallPartitionDialog = memo(
({ ({
openInstallPreviousDialog, openInstallPartitionDialog,
version, version,
partition, partition,
LL, LL,
onClose, onClose,
onInstall onInstall
}: { }: {
openInstallPreviousDialog: boolean; openInstallPartitionDialog: boolean;
version: string; version: string;
partition: string; partition: string;
LL: TranslationFunctions; LL: TranslationFunctions;
@@ -353,7 +356,7 @@ const InstallPreviousDialog = memo(
onInstall: (partition: string) => void; onInstall: (partition: string) => void;
}) => { }) => {
return ( return (
<Dialog sx={dialogStyle} open={openInstallPreviousDialog} onClose={onClose}> <Dialog sx={dialogStyle} open={openInstallPartitionDialog} onClose={onClose}>
<DialogTitle>Rollback Firmware</DialogTitle> <DialogTitle>Rollback Firmware</DialogTitle>
<DialogContent dividers> <DialogContent dividers>
<Typography mb={2}>{LL.INSTALL_VERSION(LL.INSTALL(), version)}</Typography> <Typography mb={2}>{LL.INSTALL_VERSION(LL.INSTALL(), version)}</Typography>
@@ -395,11 +398,11 @@ 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 [previousVersion, setPreviousVersion] = useState<VersionInfo | undefined>( const [partitionVersion, setPartitionVersion] = useState<VersionInfo | undefined>(
undefined undefined
); );
const [previousPartition, setPreviousPartition] = useState<string>(''); const [partition, setPartition] = useState<string>('');
const [openInstallPreviousDialog, setOpenInstallPreviousDialog] = const [openInstallPartitionDialog, setOpenInstallPartitionDialog] =
useState<boolean>(false); useState<boolean>(false);
const [usingDevVersion, setUsingDevVersion] = useState<boolean>(false); const [usingDevVersion, setUsingDevVersion] = useState<boolean>(false);
@@ -409,7 +412,7 @@ const Version = () => {
useState<boolean>(false); useState<boolean>(false);
const [internetLive, setInternetLive] = useState<boolean>(false); const [internetLive, setInternetLive] = useState<boolean>(false);
const [downloadOnly, setDownloadOnly] = useState<boolean>(false); const [downloadOnly, setDownloadOnly] = useState<boolean>(false);
const [showVersionInfo, setShowVersionInfo] = useState<number>(0); // 1 = stable, 2 = dev, 3 = previous const [showVersionInfo, setShowVersionInfo] = useState<number>(0); // 1 = stable, 2 = dev, 3 = partition
const [firmwareSize, setFirmwareSize] = useState<number>(0); const [firmwareSize, setFirmwareSize] = useState<number>(0);
const { send: sendCheckUpgrade } = useRequest( const { send: sendCheckUpgrade } = useRequest(
@@ -459,14 +462,22 @@ const Version = () => {
[data?.emsesp_version] [data?.emsesp_version]
); );
const setPreviousVersionInfo = useCallback( const setPartitionVersionInfo = useCallback(
(version: string, partition: string, size: number, install_date: string) => { (partition: string) => {
setShowVersionInfo(3); setShowVersionInfo(3);
setPreviousVersion({ name: version, published_at: install_date });
setPreviousPartition(partition); // search for the partition in the data.partitions array
setFirmwareSize(size); const partitionData = data?.partitions.find((p) => p.partition === partition);
if (partitionData) {
setPartitionVersion({
name: partitionData.version,
published_at: partitionData.install_date ?? ''
});
setPartition(partitionData.partition);
setFirmwareSize(partitionData.size);
}
}, },
[] [data]
); );
const doRestart = useCallback(async () => { const doRestart = useCallback(async () => {
@@ -488,7 +499,7 @@ const Version = () => {
[sendUploadURL] [sendUploadURL]
); );
const installPreviousFirmware = useCallback( const installPartitionFirmware = useCallback(
async (partition: string) => { async (partition: string) => {
await sendSetPartition(partition).catch((error: Error) => { await sendSetPartition(partition).catch((error: Error) => {
toast.error(error.message); toast.error(error.message);
@@ -498,11 +509,11 @@ const Version = () => {
[sendSetPartition] [sendSetPartition]
); );
const showPreviousDialog = useCallback( const showPartitionDialog = useCallback(
(version: string, partition: string, install_date: string) => { (version: string, partition: string, install_date: string) => {
setOpenInstallPreviousDialog(true); setOpenInstallPartitionDialog(true);
setPreviousVersion({ name: version, published_at: install_date }); setPartitionVersion({ name: version, published_at: install_date });
setPreviousPartition(partition); setPartition(partition);
}, },
[] []
); );
@@ -516,14 +527,14 @@ const Version = () => {
setOpenInstallDialog(false); setOpenInstallDialog(false);
}, []); }, []);
const closeInstallPreviousDialog = useCallback(() => { const closeInstallPartitionDialog = useCallback(() => {
setOpenInstallPreviousDialog(false); setOpenInstallPartitionDialog(false);
}, []); }, []);
const handleVersionInfoClose = useCallback(() => { const handleVersionInfoClose = useCallback(() => {
setShowVersionInfo(0); setShowVersionInfo(0);
setPreviousVersion(undefined); setPartitionVersion(undefined);
setPreviousPartition(''); setPartition('');
}, []); }, []);
// check upgrades - only once when both versions are available // check upgrades - only once when both versions are available
@@ -620,7 +631,6 @@ const Version = () => {
<Grid <Grid
container container
direction="row" direction="row"
// rowSpacing={0}
sx={{ sx={{
justifyContent: 'flex-start', justifyContent: 'flex-start',
alignItems: 'baseline' alignItems: 'baseline'
@@ -638,7 +648,7 @@ const Version = () => {
</Typography> </Typography>
)} )}
<IconButton <IconButton
onClick={() => setShowVersionInfo(isDev ? 2 : 1)} onClick={() => setPartitionVersionInfo(data.partition)}
aria-label={LL.FIRMWARE_VERSION_INFO()} aria-label={LL.FIRMWARE_VERSION_INFO()}
> >
<InfoOutlinedIcon color="primary" sx={{ fontSize: 18 }} /> <InfoOutlinedIcon color="primary" sx={{ fontSize: 18 }} />
@@ -696,45 +706,44 @@ const Version = () => {
<> <>
<Grid size={{ xs: 4, md: 2 }}> <Grid size={{ xs: 4, md: 2 }}>
<Typography color="secondary"> <Typography color="secondary">
{LL.PREVIOUS_VERSIONS()} {LL.STORED_VERSIONS()}
</Typography> </Typography>
</Grid> </Grid>
<Grid size={{ xs: 8, md: 10 }}> <Grid size={{ xs: 8, md: 10 }}>
{data.partitions.map((partition) => ( {data.partitions
<Typography key={partition.partition} mb={1}> .filter(
{partition.version} (partition) => partition.partition !== data.partition
<IconButton )
onClick={() => .map((partition) => (
setPreviousVersionInfo( <Typography key={partition.partition} mb={1}>
partition.version, {partition.version}
partition.partition ?? '', <IconButton
partition.size ?? '', onClick={() =>
partition.install_date ?? '' setPartitionVersionInfo(partition.partition)
) }
} aria-label={LL.FIRMWARE_VERSION_INFO()}
aria-label={LL.FIRMWARE_VERSION_INFO()} >
> <InfoOutlinedIcon
<InfoOutlinedIcon color="primary"
color="primary" sx={{ fontSize: 18 }}
sx={{ fontSize: 18 }} />
/> </IconButton>
</IconButton> <Button
<Button sx={{ ml: 0 }}
sx={{ ml: 0 }} variant="outlined"
variant="outlined" size="small"
size="small" onClick={() =>
onClick={() => showPartitionDialog(
showPreviousDialog( partition.version,
partition.version, partition.partition,
partition.partition, partition.install_date ?? ''
partition.install_date ?? '' )
) }
} >
> {LL.INSTALL()}
{LL.INSTALL()} </Button>
</Button> </Typography>
</Typography> ))}
))}
</Grid> </Grid>
</> </>
)} )}
@@ -783,9 +792,10 @@ const Version = () => {
showVersionInfo={showVersionInfo} showVersionInfo={showVersionInfo}
latestVersion={latestVersion} latestVersion={latestVersion}
latestDevVersion={latestDevVersion} latestDevVersion={latestDevVersion}
previousVersion={previousVersion} partitionVersion={partitionVersion}
locale={locale} locale={locale}
partition={previousPartition} partition={partition}
currentPartition={data?.partition ?? ''}
size={firmwareSize} size={firmwareSize}
LL={LL} LL={LL}
onClose={handleVersionInfoClose} onClose={handleVersionInfoClose}
@@ -801,13 +811,13 @@ const Version = () => {
onClose={closeInstallDialog} onClose={closeInstallDialog}
onInstall={installFirmwareURL} onInstall={installFirmwareURL}
/> />
<InstallPreviousDialog <InstallPartitionDialog
openInstallPreviousDialog={openInstallPreviousDialog} openInstallPartitionDialog={openInstallPartitionDialog}
version={previousVersion?.name || ''} version={partitionVersion?.name || ''}
partition={previousPartition} partition={partition}
LL={LL} LL={LL}
onClose={closeInstallPreviousDialog} onClose={closeInstallPartitionDialog}
onInstall={installPreviousFirmware} onInstall={installPartitionFirmware}
/> />
<Typography sx={{ pt: 2, pb: 2 }} variant="h6" color="primary"> <Typography sx={{ pt: 2, pb: 2 }} variant="h6" color="primary">
{LL.UPLOAD()} {LL.UPLOAD()}

View File

@@ -356,7 +356,7 @@ const cz: Translation = {
FIRMWARE_VERSION_INFO: 'Informace o verzi firmwaru', FIRMWARE_VERSION_INFO: 'Informace o verzi firmwaru',
NO_DATA: 'Žádná data', NO_DATA: 'Žádná data',
USER_PROFILE: 'Uživatelský profil', USER_PROFILE: 'Uživatelský profil',
PREVIOUS_VERSIONS: 'Předchozí verze' STORED_VERSIONS: 'Uložené verze'
}; };
export default cz; export default cz;

View File

@@ -356,7 +356,7 @@ const de: Translation = {
FIRMWARE_VERSION_INFO: 'Firmware-Versionsinformation', FIRMWARE_VERSION_INFO: 'Firmware-Versionsinformation',
NO_DATA: 'Keine Daten', NO_DATA: 'Keine Daten',
USER_PROFILE: 'Benutzerprofil', USER_PROFILE: 'Benutzerprofil',
PREVIOUS_VERSIONS: 'Vorherige Versionen' STORED_VERSIONS: 'Gespeicherte Versionen'
}; };
export default de; export default de;

View File

@@ -356,7 +356,7 @@ const en: Translation = {
FIRMWARE_VERSION_INFO: 'Firmware Version Information', FIRMWARE_VERSION_INFO: 'Firmware Version Information',
NO_DATA: 'No data', NO_DATA: 'No data',
USER_PROFILE: 'User Profile', USER_PROFILE: 'User Profile',
PREVIOUS_VERSIONS: 'Previous Versions' STORED_VERSIONS: 'Stored Versions'
}; };
export default en; export default en;

View File

@@ -356,7 +356,7 @@ const fr: Translation = {
FIRMWARE_VERSION_INFO: 'Informations sur la version du firmware', FIRMWARE_VERSION_INFO: 'Informations sur la version du firmware',
NO_DATA: 'Aucune donnée', NO_DATA: 'Aucune donnée',
USER_PROFILE: 'Profil utilisateur', USER_PROFILE: 'Profil utilisateur',
PREVIOUS_VERSIONS: 'Versions précédentes' STORED_VERSIONS: 'Versions stockées'
}; };
export default fr; export default fr;

View File

@@ -356,7 +356,7 @@ const it: Translation = {
FIRMWARE_VERSION_INFO: 'Informazioni sulla versione del firmware', FIRMWARE_VERSION_INFO: 'Informazioni sulla versione del firmware',
NO_DATA: 'Nessun dato', NO_DATA: 'Nessun dato',
USER_PROFILE: 'Profilo utente', USER_PROFILE: 'Profilo utente',
PREVIOUS_VERSIONS: 'Versioni precedenti' STORED_VERSIONS: 'Versioni memorizzate'
}; };
export default it; export default it;

View File

@@ -356,7 +356,7 @@ const nl: Translation = {
FIRMWARE_VERSION_INFO: 'Informatie over firmwareversie', FIRMWARE_VERSION_INFO: 'Informatie over firmwareversie',
NO_DATA: 'Geen data', NO_DATA: 'Geen data',
USER_PROFILE: 'Gebruikersprofiel', USER_PROFILE: 'Gebruikersprofiel',
PREVIOUS_VERSIONS: 'Vorige versies' STORED_VERSIONS: 'Opgeslagen versies'
}; };
export default nl; export default nl;

View File

@@ -356,7 +356,7 @@ const no: Translation = {
FIRMWARE_VERSION_INFO: 'Informasjon om firmwareversjon', FIRMWARE_VERSION_INFO: 'Informasjon om firmwareversjon',
NO_DATA: 'Ingen data', NO_DATA: 'Ingen data',
USER_PROFILE: 'Brukerprofil', USER_PROFILE: 'Brukerprofil',
PREVIOUS_VERSIONS: 'Tidligere versjoner' STORED_VERSIONS: 'Lagret versjoner'
}; };
export default no; export default no;

View File

@@ -356,7 +356,7 @@ const pl: BaseTranslation = {
FIRMWARE_VERSION_INFO: 'Informacje o wersji firmware', FIRMWARE_VERSION_INFO: 'Informacje o wersji firmware',
NO_DATA: 'Brak danych', NO_DATA: 'Brak danych',
USER_PROFILE: 'Profil użytkownika', USER_PROFILE: 'Profil użytkownika',
PREVIOUS_VERSIONS: 'Poprzednie wersje' STORED_VERSIONS: 'Zapisane wersje'
}; };
export default pl; export default pl;

View File

@@ -356,7 +356,7 @@ const sk: Translation = {
FIRMWARE_VERSION_INFO: 'Informácie o verzii firmware', FIRMWARE_VERSION_INFO: 'Informácie o verzii firmware',
NO_DATA: 'Žiadne dáta', NO_DATA: 'Žiadne dáta',
USER_PROFILE: 'Profil používateľa', USER_PROFILE: 'Profil používateľa',
PREVIOUS_VERSIONS: 'Predchádzajúce verzie' STORED_VERSIONS: 'Uložené verzie'
}; };
export default sk; export default sk;

View File

@@ -356,7 +356,7 @@ const sv: Translation = {
FIRMWARE_VERSION_INFO: 'Information om firmwareversion', FIRMWARE_VERSION_INFO: 'Information om firmwareversion',
NO_DATA: 'Ingen data', NO_DATA: 'Ingen data',
USER_PROFILE: 'Användarprofil', USER_PROFILE: 'Användarprofil',
PREVIOUS_VERSIONS: 'Tidigare versioner' STORED_VERSIONS: 'Lagrad versioner'
}; };
export default sv; export default sv;

View File

@@ -356,7 +356,7 @@ const tr: Translation = {
FIRMWARE_VERSION_INFO: 'Firmware Sürüm Bilgisi', FIRMWARE_VERSION_INFO: 'Firmware Sürüm Bilgisi',
NO_DATA: 'Hiçbir veri yok', NO_DATA: 'Hiçbir veri yok',
USER_PROFILE: 'Kullanıcı Profili', USER_PROFILE: 'Kullanıcı Profili',
PREVIOUS_VERSIONS: 'Önceki Sürümler' STORED_VERSIONS: 'Kaydedilmiş Sürümler'
}; };
export default tr; export default tr;

View File

@@ -108,6 +108,12 @@ let system_status = {
has_loader: true, has_loader: true,
has_partition: true, has_partition: true,
partitions: [ partitions: [
{
partition: 'app0', // this one is active
version: 'XX.XX.XX', // defined later
install_date: '2025-03-01T13:29:13.999Z',
size: 4672
},
{ {
partition: 'app1', partition: 'app1',
version: '3.7.3-dev.41', version: '3.7.3-dev.41',
@@ -179,6 +185,7 @@ switch (version_test as number) {
// set the version // set the version
system_status.emsesp_version = THIS_VERSION; system_status.emsesp_version = THIS_VERSION;
system_status.partitions[0].version = THIS_VERSION; // app0
// set the ESP platform - using ESP32 will disable OTA and automatic version downloading // set the ESP platform - using ESP32 will disable OTA and automatic version downloading
let emulate_esp: string; let emulate_esp: string;

View File

@@ -146,12 +146,12 @@ void WebStatusService::systemStatus(AsyncWebServerRequest * request) {
root["has_partition"] = false; root["has_partition"] = false;
} }
// get the partition info // get the partition info for each partition, including the running one
EMSESP::system_.get_partition_info(); EMSESP::system_.get_partition_info();
JsonArray partitions = root["partitions"].to<JsonArray>(); JsonArray partitions = root["partitions"].to<JsonArray>();
for (const auto & partition : EMSESP::system_.partition_info_) { for (const auto & partition : EMSESP::system_.partition_info_) {
// Skip partition if it's the running one, version is empty, or size is 0 // Skip partition if it has no version, or it's size is 0
if (partition.first == (const char *)esp_ota_get_running_partition()->label || partition.second.version.empty() || partition.second.size == 0) { if (partition.second.version.empty() || partition.second.size == 0) {
continue; continue;
} }
JsonObject part = partitions.add<JsonObject>(); JsonObject part = partitions.add<JsonObject>();