mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-09 06:55:51 +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 { showNotification } from '@mantine/notifications';
|
||||||
import { useRef } from 'react';
|
import { useRef } from 'react';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
|
import { setCookies } from 'cookies-next';
|
||||||
import { useConfig } from '../../tools/state';
|
import { useConfig } from '../../tools/state';
|
||||||
import { Config } from '../../tools/types';
|
import { Config } from '../../tools/types';
|
||||||
|
|
||||||
@@ -69,15 +70,21 @@ export default function LoadConfigComponent(props: any) {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const newConfig: Config = JSON.parse(e);
|
||||||
showNotification({
|
showNotification({
|
||||||
autoClose: 5000,
|
autoClose: 5000,
|
||||||
radius: 'md',
|
radius: 'md',
|
||||||
title: <Text>Config loaded successfully</Text>,
|
title: (
|
||||||
|
<Text>
|
||||||
|
Config <b>{newConfig.name}</b> loaded successfully
|
||||||
|
</Text>
|
||||||
|
),
|
||||||
color: 'green',
|
color: 'green',
|
||||||
icon: <Check />,
|
icon: <Check />,
|
||||||
message: undefined,
|
message: undefined,
|
||||||
});
|
});
|
||||||
setConfig(JSON.parse(e));
|
setCookies('config-name', newConfig.name, { maxAge: 60 * 60 * 24 * 30 });
|
||||||
|
setConfig(newConfig);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
accept={['application/json']}
|
accept={['application/json']}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export default function SaveConfigComponent(props: any) {
|
|||||||
const { config } = useConfig();
|
const { config } = useConfig();
|
||||||
function onClick(e: any) {
|
function onClick(e: any) {
|
||||||
if (config) {
|
if (config) {
|
||||||
fileDownload(JSON.stringify(config, null, '\t'), 'config.json');
|
fileDownload(JSON.stringify(config, null, '\t'), `${config.name}.json`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user