From 0557def0b699df4750c5cf05fb76fb6fce5a83b7 Mon Sep 17 00:00:00 2001 From: proddy Date: Wed, 24 Dec 2025 11:18:22 +0100 Subject: [PATCH] add install date to firmware versions --- interface/src/app/status/Version.tsx | 186 ++++++++++++++++++++------- interface/src/types/system.ts | 1 + mock-api/restServer.ts | 30 +++-- src/core/system.cpp | 32 +++-- src/core/system.h | 6 +- src/web/WebStatusService.cpp | 9 +- 6 files changed, 192 insertions(+), 72 deletions(-) diff --git a/interface/src/app/status/Version.tsx b/interface/src/app/status/Version.tsx index 9e33e006a..d8fb7f2d2 100644 --- a/interface/src/app/status/Version.tsx +++ b/interface/src/app/status/Version.tsx @@ -86,6 +86,9 @@ const VersionInfoDialog = memo( showVersionInfo, latestVersion, latestDevVersion, + previousVersion, + partition, + size, locale, LL, onClose @@ -93,6 +96,9 @@ const VersionInfoDialog = memo( showVersionInfo: number; latestVersion?: VersionInfo; latestDevVersion?: VersionInfo; + previousVersion?: VersionInfo | undefined; + partition: string; + size: number; locale: string; LL: TranslationFunctions; onClose: () => void; @@ -100,8 +106,19 @@ const VersionInfoDialog = memo( if (showVersionInfo === 0) return null; const isStable = showVersionInfo === 1; - const version = isStable ? latestVersion : latestDevVersion; - const relNotesUrl = isStable ? STABLE_RELNOTES_URL : DEV_RELNOTES_URL; + const isDev = showVersionInfo === 2; + const isPrevious = showVersionInfo === 3; + + const version = isStable + ? latestVersion + : isDev + ? latestDevVersion + : previousVersion; + const relNotesUrl = isStable + ? STABLE_RELNOTES_URL + : isDev + ? DEV_RELNOTES_URL + : ''; return ( @@ -119,13 +136,17 @@ const VersionInfoDialog = memo( pr: 1, py: 0.5, fontSize: 13, - width: 90 + width: 140 }} > - {LL.TYPE(0)} + {isPrevious ? LL.TYPE(0) : LL.RELEASE_TYPE()} - {isStable ? LL.STABLE() : LL.DEVELOPMENT()} + {isStable + ? LL.STABLE() + : isDev + ? LL.DEVELOPMENT() + : 'Partition ' + LL.VERSION()} @@ -143,9 +164,53 @@ const VersionInfoDialog = memo( {LL.VERSION()} - {version?.name} + {isPrevious + ? typeof version === 'string' + ? version + : version?.name + : version?.name} + {isPrevious && ( + + + Partition + + + {partition} + + + )} + {isPrevious && ( + + + Size + + + {size} KB + + + )} {version?.published_at && ( - Build Date + {isPrevious ? 'Install Date' : 'Build Date'} {prettyDateTime(locale, new Date(version.published_at))} @@ -170,15 +235,17 @@ const VersionInfoDialog = memo( - + {!isPrevious && ( + + )} @@ -328,7 +395,9 @@ const Version = () => { const [restarting, setRestarting] = useState(false); const [openInstallDialog, setOpenInstallDialog] = useState(false); - const [previousVersion, setPreviousVersion] = useState(''); + const [previousVersion, setPreviousVersion] = useState( + undefined + ); const [previousPartition, setPreviousPartition] = useState(''); const [openInstallPreviousDialog, setOpenInstallPreviousDialog] = useState(false); @@ -340,7 +409,8 @@ const Version = () => { useState(false); const [internetLive, setInternetLive] = useState(false); const [downloadOnly, setDownloadOnly] = useState(false); - const [showVersionInfo, setShowVersionInfo] = useState(0); + const [showVersionInfo, setShowVersionInfo] = useState(0); // 1 = stable, 2 = dev, 3 = previous + const [firmwareSize, setFirmwareSize] = useState(0); const { send: sendCheckUpgrade } = useRequest( (versions: string) => callAction({ action: 'checkUpgrade', param: versions }), @@ -389,6 +459,16 @@ const Version = () => { [data?.emsesp_version] ); + const setPreviousVersionInfo = useCallback( + (version: string, partition: string, size: number, install_date: string) => { + setShowVersionInfo(3); + setPreviousVersion({ name: version, published_at: install_date }); + setPreviousPartition(partition); + setFirmwareSize(size); + }, + [] + ); + const doRestart = useCallback(async () => { await sendAPI({ device: 'system', cmd: 'restart', id: 0 }).catch( (error: Error) => { @@ -418,11 +498,14 @@ const Version = () => { [sendSetPartition] ); - const showPreviousDialog = useCallback((version: string, partition: string) => { - setOpenInstallPreviousDialog(true); - setPreviousVersion(version); - setPreviousPartition(partition); - }, []); + const showPreviousDialog = useCallback( + (version: string, partition: string, install_date: string) => { + setOpenInstallPreviousDialog(true); + setPreviousVersion({ name: version, published_at: install_date }); + setPreviousPartition(partition); + }, + [] + ); const showFirmwareDialog = useCallback((useDevVersion: boolean) => { setFetchDevVersion(useDevVersion); @@ -439,6 +522,8 @@ const Version = () => { const handleVersionInfoClose = useCallback(() => { setShowVersionInfo(0); + setPreviousVersion(undefined); + setPreviousPartition(''); }, []); // check upgrades - only once when both versions are available @@ -485,7 +570,7 @@ const Version = () => { {LL.LATEST_VERSION(usingDevVersion ? LL.DEVELOPMENT() : LL.STABLE())}