diff --git a/src/js/commandline-lists.js b/src/js/commandline-lists.js index a07256def..a82a4ded3 100644 --- a/src/js/commandline-lists.js +++ b/src/js/commandline-lists.js @@ -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) => { + }, + }, ], }; diff --git a/src/js/config.js b/src/js/config.js index 3b8e76247..0fc1284f2 100644 --- a/src/js/config.js +++ b/src/js/config.js @@ -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); }