added import export settings to the command line

This commit is contained in:
Miodec 2021-05-17 16:03:12 +01:00
parent 7cf0a816fb
commit 4801edd1b4
2 changed files with 32 additions and 1 deletions

View file

@ -16,6 +16,7 @@ import * as TagController from "./tag-controller";
import * as PresetController from "./preset-controller";
import * as Commandline from "./commandline";
import * as CustomText from "./custom-text";
import * as Settings from "./settings";
export let current = [];
@ -2009,6 +2010,32 @@ export let defaultCommands = {
Commandline.show();
},
},
{
id: "importSettingsJSON",
display: "Import settings JSON",
input: true,
exec: (input) => {
try {
UpdateConfig.apply(JSON.parse(input));
UpdateConfig.saveToLocalStorage();
Settings.update();
Notifications.add("Done",1);
} catch (e) {
Notifications.add(
"An error occured while importing settings: " + e,
-1
);
}
},
},
{
id: "exportSettingsJSON",
display: "Export settings JSON",
input: true,
defaultValue:"",
exec: (input) => {
},
},
],
};

View file

@ -144,7 +144,11 @@ export async function saveToLocalStorage(noDbCheck = false) {
// });
let save = config;
delete save.resultFilters;
window.localStorage.setItem("config", JSON.stringify(save));
let stringified = JSON.stringify(save);
window.localStorage.setItem("config", stringified);
CommandlineLists.defaultCommands.list.filter(
(command) => command.id == "exportSettingsJSON"
)[0].defaultValue = stringified;
// restartCount = 0;
if (!noDbCheck) await DB.saveConfig(save);
}