feat: add response.data and fix styling for layout with download zip button

pull/94/head^2
Tim Schipper 2024-10-16 09:55:19 +02:00
parent 3a71083a05
commit 9911e78b50
2 changed files with 5 additions and 2 deletions

View File

@ -37,10 +37,10 @@ const ActionButtons = () => {
)} )}
onSubmit={(force) => dispatch(exportAllConfig(partialDiff, toggleNotification, formatMessage, post, get))} onSubmit={(force) => dispatch(exportAllConfig(partialDiff, toggleNotification, formatMessage, post, get))}
/> />
<Button onClick={() => dispatch(downloadZip(toggleNotification, formatMessage, post, get))}>{formatMessage({ id: 'config-sync.Buttons.DownloadConfig' })}</Button>
{!isEmpty(partialDiff) && ( {!isEmpty(partialDiff) && (
<Typography variant="epsilon">{Object.keys(partialDiff).length} {Object.keys(partialDiff).length === 1 ? "config change" : "config changes"}</Typography> <Typography variant="epsilon">{Object.keys(partialDiff).length} {Object.keys(partialDiff).length === 1 ? "config change" : "config changes"}</Typography>
)} )}
<Button onClick={() => dispatch(downloadZip(toggleNotification, formatMessage, post, get))}>{formatMessage({ id: 'config-sync.Buttons.DownloadConfig' })}</Button>
</ActionButtonsStyling> </ActionButtonsStyling>
); );
}; };
@ -53,6 +53,9 @@ const ActionButtonsStyling = styled.div`
> button { > button {
margin-right: 10px; margin-right: 10px;
} }
> button:last-of-type {
margin-left: auto;
}
`; `;
export default ActionButtons; export default ActionButtons;

View File

@ -56,7 +56,7 @@ export function downloadZip(toggleNotification, formatMessage, post, get) {
return async function(dispatch) { return async function(dispatch) {
dispatch(setLoadingState(true)); dispatch(setLoadingState(true));
try { try {
const { message, base64Data, name } = await get('/config-sync/zip'); const { message, base64Data, name } = (await get('/config-sync/zip')).data;
toggleNotification({ type: 'success', message }); toggleNotification({ type: 'success', message });
if (base64Data) { if (base64Data) {
saveAs(b64toBlob(base64Data, 'application/zip'), name, { type: 'application/zip' }); saveAs(b64toBlob(base64Data, 'application/zip'), name, { type: 'application/zip' });