mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-08 22:45:49 +01:00
Fix cookie in Upload form and fix download name
This commit is contained in:
@@ -4,6 +4,7 @@ import { DropzoneStatus, FullScreenDropzone } from '@mantine/dropzone';
|
||||
import { showNotification } from '@mantine/notifications';
|
||||
import { useRef } from 'react';
|
||||
import { useRouter } from 'next/router';
|
||||
import { setCookies } from 'cookies-next';
|
||||
import { useConfig } from '../../tools/state';
|
||||
import { Config } from '../../tools/types';
|
||||
|
||||
@@ -69,15 +70,21 @@ export default function LoadConfigComponent(props: any) {
|
||||
});
|
||||
return;
|
||||
}
|
||||
const newConfig: Config = JSON.parse(e);
|
||||
showNotification({
|
||||
autoClose: 5000,
|
||||
radius: 'md',
|
||||
title: <Text>Config loaded successfully</Text>,
|
||||
title: (
|
||||
<Text>
|
||||
Config <b>{newConfig.name}</b> loaded successfully
|
||||
</Text>
|
||||
),
|
||||
color: 'green',
|
||||
icon: <Check />,
|
||||
message: undefined,
|
||||
});
|
||||
setConfig(JSON.parse(e));
|
||||
setCookies('config-name', newConfig.name, { maxAge: 60 * 60 * 24 * 30 });
|
||||
setConfig(newConfig);
|
||||
});
|
||||
}}
|
||||
accept={['application/json']}
|
||||
|
||||
@@ -7,7 +7,7 @@ export default function SaveConfigComponent(props: any) {
|
||||
const { config } = useConfig();
|
||||
function onClick(e: any) {
|
||||
if (config) {
|
||||
fileDownload(JSON.stringify(config, null, '\t'), 'config.json');
|
||||
fileDownload(JSON.stringify(config, null, '\t'), `${config.name}.json`);
|
||||
}
|
||||
}
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user