diff --git a/src/components/Config/ConfigChanger.tsx b/src/components/Config/ConfigChanger.tsx
index 5b8836803..8d4be4db8 100644
--- a/src/components/Config/ConfigChanger.tsx
+++ b/src/components/Config/ConfigChanger.tsx
@@ -9,7 +9,7 @@ export default function ConfigChanger() {
useEffect(() => {
getConfigs().then((configs) => setConfigList(configs));
// setConfig(initialConfig);
- }, [config]);
+ }, [config.name]);
// If configlist is empty, return a loading indicator
if (configList.length === 0) {
return (
diff --git a/src/components/Config/SaveConfig.tsx b/src/components/Config/SaveConfig.tsx
index cfaf196d4..a0b7997e7 100644
--- a/src/components/Config/SaveConfig.tsx
+++ b/src/components/Config/SaveConfig.tsx
@@ -1,18 +1,96 @@
-import { Button } from '@mantine/core';
+import { Button, Group, Modal, TextInput } from '@mantine/core';
+import { useForm } from '@mantine/form';
+import { showNotification } from '@mantine/notifications';
+import axios from 'axios';
import fileDownload from 'js-file-download';
-import { Download } from 'tabler-icons-react';
+import { useState } from 'react';
+import { Check, Download, Plus, Trash, X } from 'tabler-icons-react';
import { useConfig } from '../../tools/state';
export default function SaveConfigComponent(props: any) {
- const { config } = useConfig();
+ const [opened, setOpened] = useState(false);
+ const { config, setConfig } = useConfig();
+ const form = useForm({
+ initialValues: {
+ configName: config.name,
+ },
+ });
function onClick(e: any) {
if (config) {
fileDownload(JSON.stringify(config, null, '\t'), `${config.name}.json`);
}
}
return (
- } variant="outline" onClick={onClick}>
- Download your config
-
+
+ setOpened(false)}
+ title="Choose the name of your new config"
+ >
+
+
+ } variant="outline" onClick={onClick}>
+ Download your config
+
+ }
+ variant="outline"
+ onClick={() => {
+ axios
+ .delete(`/api/configs/${config.name}`)
+ .then(() => {
+ showNotification({
+ title: 'Config deleted',
+ icon: ,
+ color: 'green',
+ autoClose: 1500,
+ radius: 'md',
+ message: 'Config deleted',
+ });
+ })
+ .catch(() => {
+ showNotification({
+ title: 'Config delete failed',
+ icon: ,
+ color: 'red',
+ autoClose: 1500,
+ radius: 'md',
+ message: 'Config delete failed',
+ });
+ });
+ setConfig({ ...config, name: 'default' });
+ }}
+ >
+ Delete current config
+
+ } variant="outline" onClick={() => setOpened(true)}>
+ Save a copy of your config
+
+
);
}