mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-01-26 16:49:11 +03:00
rollback to other partitions - #2837
This commit is contained in:
@@ -269,6 +269,52 @@ const InstallDialog = memo(
|
||||
}
|
||||
);
|
||||
|
||||
const InstallPreviousDialog = memo(
|
||||
({
|
||||
openInstallPreviousDialog,
|
||||
version,
|
||||
partition,
|
||||
LL,
|
||||
onClose,
|
||||
onInstall
|
||||
}: {
|
||||
openInstallPreviousDialog: boolean;
|
||||
version: string;
|
||||
partition: string;
|
||||
LL: TranslationFunctions;
|
||||
onClose: () => void;
|
||||
onInstall: (partition: string) => void;
|
||||
}) => {
|
||||
return (
|
||||
<Dialog sx={dialogStyle} open={openInstallPreviousDialog} onClose={onClose}>
|
||||
<DialogTitle>Rollback Firmware</DialogTitle>
|
||||
<DialogContent dividers>
|
||||
<Typography mb={2}>{LL.INSTALL_VERSION(LL.INSTALL(), version)}</Typography>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button
|
||||
startIcon={<CancelIcon />}
|
||||
variant="outlined"
|
||||
onClick={onClose}
|
||||
color="secondary"
|
||||
>
|
||||
{LL.CANCEL()}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
startIcon={<WarningIcon color="warning" />}
|
||||
variant="outlined"
|
||||
onClick={() => onInstall(partition)}
|
||||
color="primary"
|
||||
>
|
||||
{LL.INSTALL()}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
// Helper function moved outside component
|
||||
const getPlatform = (data: VersionData): string => {
|
||||
return `${data.esp_platform}-${data.flash_chip_size >= 16384 ? '16MB' : '4MB'}${data.psram ? '+' : ''}`;
|
||||
@@ -281,6 +327,12 @@ const Version = () => {
|
||||
// State management
|
||||
const [restarting, setRestarting] = useState<boolean>(false);
|
||||
const [openInstallDialog, setOpenInstallDialog] = useState<boolean>(false);
|
||||
|
||||
const [previousVersion, setPreviousVersion] = useState<string>('');
|
||||
const [previousPartition, setPreviousPartition] = useState<string>('');
|
||||
const [openInstallPreviousDialog, setOpenInstallPreviousDialog] =
|
||||
useState<boolean>(false);
|
||||
|
||||
const [usingDevVersion, setUsingDevVersion] = useState<boolean>(false);
|
||||
const [fetchDevVersion, setFetchDevVersion] = useState<boolean>(false);
|
||||
const [devUpgradeAvailable, setDevUpgradeAvailable] = useState<boolean>(false);
|
||||
@@ -299,6 +351,11 @@ const Version = () => {
|
||||
setStableUpgradeAvailable(data.stable_upgradeable);
|
||||
});
|
||||
|
||||
const { send: sendSetPartition } = useRequest(
|
||||
(partition: string) => callAction({ action: 'setPartition', param: partition }),
|
||||
{ immediate: false }
|
||||
);
|
||||
|
||||
const {
|
||||
data,
|
||||
send: loadData,
|
||||
@@ -331,12 +388,12 @@ const Version = () => {
|
||||
);
|
||||
|
||||
const doRestart = useCallback(async () => {
|
||||
setRestarting(true);
|
||||
await sendAPI({ device: 'system', cmd: 'restart', id: 0 }).catch(
|
||||
(error: Error) => {
|
||||
toast.error(error.message);
|
||||
}
|
||||
);
|
||||
setRestarting(true);
|
||||
}, [sendAPI]);
|
||||
|
||||
const installFirmwareURL = useCallback(
|
||||
@@ -344,11 +401,27 @@ const Version = () => {
|
||||
await sendUploadURL(url).catch((error: Error) => {
|
||||
toast.error(error.message);
|
||||
});
|
||||
setRestarting(true);
|
||||
doRestart();
|
||||
},
|
||||
[sendUploadURL]
|
||||
);
|
||||
|
||||
const installPreviousFirmware = useCallback(
|
||||
async (partition: string) => {
|
||||
await sendSetPartition(partition).catch((error: Error) => {
|
||||
toast.error(error.message);
|
||||
});
|
||||
setRestarting(true);
|
||||
},
|
||||
[sendSetPartition]
|
||||
);
|
||||
|
||||
const showPreviousDialog = useCallback((version: string, partition: string) => {
|
||||
setOpenInstallPreviousDialog(true);
|
||||
setPreviousVersion(version);
|
||||
setPreviousPartition(partition);
|
||||
}, []);
|
||||
|
||||
const showFirmwareDialog = useCallback((useDevVersion: boolean) => {
|
||||
setFetchDevVersion(useDevVersion);
|
||||
setOpenInstallDialog(true);
|
||||
@@ -358,6 +431,10 @@ const Version = () => {
|
||||
setOpenInstallDialog(false);
|
||||
}, []);
|
||||
|
||||
const closeInstallPreviousDialog = useCallback(() => {
|
||||
setOpenInstallPreviousDialog(false);
|
||||
}, []);
|
||||
|
||||
const handleVersionInfoClose = useCallback(() => {
|
||||
setShowVersionInfo(0);
|
||||
}, []);
|
||||
@@ -531,6 +608,28 @@ const Version = () => {
|
||||
alignItems: 'baseline'
|
||||
}}
|
||||
>
|
||||
<Grid size={{ xs: 4, md: 2 }}>
|
||||
<Typography color="secondary">{LL.PREVIOUS_VERSIONS()}</Typography>
|
||||
</Grid>
|
||||
<Grid size={{ xs: 8, md: 10 }}>
|
||||
{data.partitions.map((partition) => (
|
||||
<Typography key={partition.partition} mb={1}>
|
||||
v{partition.version} ({partition.partition}: {partition.size}
|
||||
{' KB'})
|
||||
<Button
|
||||
sx={{ ml: 2 }}
|
||||
variant="outlined"
|
||||
size="small"
|
||||
onClick={() =>
|
||||
showPreviousDialog(partition.version, partition.partition)
|
||||
}
|
||||
>
|
||||
{LL.INSTALL()}
|
||||
</Button>
|
||||
</Typography>
|
||||
))}
|
||||
</Grid>
|
||||
|
||||
<Grid size={{ xs: 4, md: 2 }}>
|
||||
<Typography color="secondary">{LL.STABLE()}</Typography>
|
||||
</Grid>
|
||||
@@ -591,6 +690,14 @@ const Version = () => {
|
||||
onClose={closeInstallDialog}
|
||||
onInstall={installFirmwareURL}
|
||||
/>
|
||||
<InstallPreviousDialog
|
||||
openInstallPreviousDialog={openInstallPreviousDialog}
|
||||
version={previousVersion}
|
||||
partition={previousPartition}
|
||||
LL={LL}
|
||||
onClose={closeInstallPreviousDialog}
|
||||
onInstall={installPreviousFirmware}
|
||||
/>
|
||||
<Typography sx={{ pt: 2, pb: 2 }} variant="h6" color="primary">
|
||||
{LL.UPLOAD()}
|
||||
</Typography>
|
||||
|
||||
@@ -355,7 +355,8 @@ const cz: Translation = {
|
||||
SWITCH_RELEASE_TYPE: 'Přepnout na {0} verzi',
|
||||
FIRMWARE_VERSION_INFO: 'Informace o verzi firmwaru',
|
||||
NO_DATA: 'Žádná data',
|
||||
USER_PROFILE: 'Uživatelský profil'
|
||||
USER_PROFILE: 'Uživatelský profil',
|
||||
PREVIOUS_VERSIONS: 'Předchozí verze'
|
||||
};
|
||||
|
||||
export default cz;
|
||||
|
||||
@@ -355,7 +355,8 @@ const de: Translation = {
|
||||
SWITCH_RELEASE_TYPE: 'Zum {0}-Release wechseln',
|
||||
FIRMWARE_VERSION_INFO: 'Firmware-Versionsinformation',
|
||||
NO_DATA: 'Keine Daten',
|
||||
USER_PROFILE: 'Benutzerprofil'
|
||||
USER_PROFILE: 'Benutzerprofil',
|
||||
PREVIOUS_VERSIONS: 'Vorherige Versionen'
|
||||
};
|
||||
|
||||
export default de;
|
||||
|
||||
@@ -355,7 +355,8 @@ const en: Translation = {
|
||||
SWITCH_RELEASE_TYPE: 'Switch to {0} release',
|
||||
FIRMWARE_VERSION_INFO: 'Firmware Version Information',
|
||||
NO_DATA: 'No data',
|
||||
USER_PROFILE: 'User Profile'
|
||||
USER_PROFILE: 'User Profile',
|
||||
PREVIOUS_VERSIONS: 'Previous Versions'
|
||||
};
|
||||
|
||||
export default en;
|
||||
|
||||
@@ -355,7 +355,8 @@ const fr: Translation = {
|
||||
SWITCH_RELEASE_TYPE: 'Passer à la version {0}',
|
||||
FIRMWARE_VERSION_INFO: 'Informations sur la version du firmware',
|
||||
NO_DATA: 'Aucune donnée',
|
||||
USER_PROFILE: 'Profil utilisateur'
|
||||
USER_PROFILE: 'Profil utilisateur',
|
||||
PREVIOUS_VERSIONS: 'Versions précédentes'
|
||||
};
|
||||
|
||||
export default fr;
|
||||
|
||||
@@ -355,7 +355,8 @@ const it: Translation = {
|
||||
SWITCH_RELEASE_TYPE: 'Cambia in {0} rilascio',
|
||||
FIRMWARE_VERSION_INFO: 'Informazioni sulla versione del firmware',
|
||||
NO_DATA: 'Nessun dato',
|
||||
USER_PROFILE: 'Profilo utente'
|
||||
USER_PROFILE: 'Profilo utente',
|
||||
PREVIOUS_VERSIONS: 'Versioni precedenti'
|
||||
};
|
||||
|
||||
export default it;
|
||||
|
||||
@@ -355,7 +355,8 @@ const nl: Translation = {
|
||||
SWITCH_RELEASE_TYPE: 'Switch naar {0} release',
|
||||
FIRMWARE_VERSION_INFO: 'Informatie over firmwareversie',
|
||||
NO_DATA: 'Geen data',
|
||||
USER_PROFILE: 'Gebruikersprofiel'
|
||||
USER_PROFILE: 'Gebruikersprofiel',
|
||||
PREVIOUS_VERSIONS: 'Vorige versies'
|
||||
};
|
||||
|
||||
export default nl;
|
||||
@@ -355,7 +355,8 @@ const no: Translation = {
|
||||
SWITCH_RELEASE_TYPE: 'Bytt til {0} utgivelse',
|
||||
FIRMWARE_VERSION_INFO: 'Informasjon om firmwareversjon',
|
||||
NO_DATA: 'Ingen data',
|
||||
USER_PROFILE: 'Brukerprofil'
|
||||
USER_PROFILE: 'Brukerprofil',
|
||||
PREVIOUS_VERSIONS: 'Tidligere versjoner'
|
||||
};
|
||||
|
||||
export default no;
|
||||
|
||||
@@ -355,7 +355,8 @@ const pl: BaseTranslation = {
|
||||
SWITCH_RELEASE_TYPE: 'Zmień na {0} wydanie',
|
||||
FIRMWARE_VERSION_INFO: 'Informacje o wersji firmware',
|
||||
NO_DATA: 'Brak danych',
|
||||
USER_PROFILE: 'Profil użytkownika'
|
||||
USER_PROFILE: 'Profil użytkownika',
|
||||
PREVIOUS_VERSIONS: 'Poprzednie wersje'
|
||||
};
|
||||
|
||||
export default pl;
|
||||
|
||||
@@ -355,7 +355,8 @@ const sk: Translation = {
|
||||
SWITCH_RELEASE_TYPE: 'Prepnúť na {0} verziu',
|
||||
FIRMWARE_VERSION_INFO: 'Informácie o verzii firmware',
|
||||
NO_DATA: 'Žiadne dáta',
|
||||
USER_PROFILE: 'Profil používateľa'
|
||||
USER_PROFILE: 'Profil používateľa',
|
||||
PREVIOUS_VERSIONS: 'Predchádzajúce verzie'
|
||||
};
|
||||
|
||||
export default sk;
|
||||
|
||||
@@ -355,7 +355,8 @@ const sv: Translation = {
|
||||
SWITCH_RELEASE_TYPE: 'Byt till {0} utgåva',
|
||||
FIRMWARE_VERSION_INFO: 'Information om firmwareversion',
|
||||
NO_DATA: 'Ingen data',
|
||||
USER_PROFILE: 'Användarprofil'
|
||||
USER_PROFILE: 'Användarprofil',
|
||||
PREVIOUS_VERSIONS: 'Tidigare versioner'
|
||||
};
|
||||
|
||||
export default sv;
|
||||
|
||||
@@ -355,7 +355,8 @@ const tr: Translation = {
|
||||
SWITCH_RELEASE_TYPE: '{0} sürümüne geç',
|
||||
FIRMWARE_VERSION_INFO: 'Firmware Sürüm Bilgisi',
|
||||
NO_DATA: 'Hiçbir veri yok',
|
||||
USER_PROFILE: 'Kullanıcı Profili'
|
||||
USER_PROFILE: 'Kullanıcı Profili',
|
||||
PREVIOUS_VERSIONS: 'Önceki Sürümler'
|
||||
};
|
||||
|
||||
export default tr;
|
||||
|
||||
@@ -52,7 +52,13 @@ export interface SystemStatus {
|
||||
model: string;
|
||||
has_loader: boolean;
|
||||
has_partition: boolean;
|
||||
partitions: {
|
||||
partition: string;
|
||||
version: string;
|
||||
size: number;
|
||||
}[];
|
||||
status: number; // System Status Codes which matches SYSTEM_STATUS in System.h
|
||||
developer_mode: boolean;
|
||||
temperature?: number;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user