From 069e993fb025ad7318c90c3005445a62824c9587 Mon Sep 17 00:00:00 2001 From: fyears <1142836+fyears@users.noreply.github.com> Date: Tue, 3 May 2022 22:45:23 +0800 Subject: [PATCH] split chooser and basic settings --- src/langs | 2 +- src/settings.ts | 230 ++++++++++++++++++++++++------------------------ 2 files changed, 117 insertions(+), 115 deletions(-) diff --git a/src/langs b/src/langs index ad48de9..4726d51 160000 --- a/src/langs +++ b/src/langs @@ -1 +1 @@ -Subproject commit ad48de922720d668477583a6b313a5eaaf4a7516 +Subproject commit 4726d51d60bcd8f7c4920736b256dc5131e8c0f3 diff --git a/src/settings.ts b/src/settings.ts index 397ca81..dd2e32e 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -675,123 +675,13 @@ export class RemotelySaveSettingTab extends PluginSettingTab { containerEl.createEl("h1", { text: "Remotely Save" }); ////////////////////////////////////////////////// - // below for general - ////////////////////////////////////////////////// - - const generalDiv = containerEl.createEl("div"); - generalDiv.createEl("h2", { text: t("settings_general") }); - - const passwordDiv = generalDiv.createEl("div"); - let newPassword = `${this.plugin.settings.password}`; - new Setting(passwordDiv) - .setName(t("settings_password")) - .setDesc(t("settings_password_desc")) - .addText((text) => { - wrapTextWithPasswordHide(text); - text - .setPlaceholder("") - .setValue(`${this.plugin.settings.password}`) - .onChange(async (value) => { - newPassword = value.trim(); - }); - }) - .addButton(async (button) => { - button.setButtonText(t("confirm")); - button.onClick(async () => { - new PasswordModal(this.app, this.plugin, newPassword).open(); - }); - }); - - const scheduleDiv = generalDiv.createEl("div"); - new Setting(scheduleDiv) - .setName(t("settings_autorun")) - .setDesc(t("settings_autorun_desc")) - .addDropdown((dropdown) => { - dropdown.addOption("-1", t("settings_autorun_notset")); - dropdown.addOption(`${1000 * 60 * 1}`, t("settings_autorun_1min")); - dropdown.addOption(`${1000 * 60 * 5}`, t("settings_autorun_5min")); - dropdown.addOption(`${1000 * 60 * 10}`, t("settings_autorun_10min")); - dropdown.addOption(`${1000 * 60 * 30}`, t("settings_autorun_30min")); - - dropdown - .setValue(`${this.plugin.settings.autoRunEveryMilliseconds}`) - .onChange(async (val: string) => { - const realVal = parseInt(val); - this.plugin.settings.autoRunEveryMilliseconds = realVal; - await this.plugin.saveSettings(); - if ( - (realVal === undefined || realVal === null || realVal <= 0) && - this.plugin.autoRunIntervalID !== undefined - ) { - // clear - window.clearInterval(this.plugin.autoRunIntervalID); - this.plugin.autoRunIntervalID = undefined; - } else if ( - realVal !== undefined && - realVal !== null && - realVal > 0 - ) { - const intervalID = window.setInterval(() => { - this.plugin.syncRun("auto"); - }, realVal); - this.plugin.autoRunIntervalID = intervalID; - this.plugin.registerInterval(intervalID); - } - }); - }); - - const runOnceStartUpDiv = generalDiv.createEl("div"); - new Setting(runOnceStartUpDiv) - .setName(t("settings_runoncestartup")) - .setDesc(t("settings_runoncestartup_desc")) - .addDropdown((dropdown) => { - dropdown.addOption("-1", t("settings_runoncestartup_notset")); - dropdown.addOption( - `${1000 * 1 * 1}`, - t("settings_runoncestartup_1sec") - ); - dropdown.addOption( - `${1000 * 10 * 1}`, - t("settings_runoncestartup_10sec") - ); - dropdown.addOption( - `${1000 * 30 * 1}`, - t("settings_runoncestartup_30sec") - ); - dropdown - .setValue(`${this.plugin.settings.initRunAfterMilliseconds}`) - .onChange(async (val: string) => { - const realVal = parseInt(val); - this.plugin.settings.initRunAfterMilliseconds = realVal; - await this.plugin.saveSettings(); - }); - }); - - const skipLargeFilesDiv = generalDiv.createEl("div"); - new Setting(skipLargeFilesDiv) - .setName(t("settings_skiplargefiles")) - .setDesc(t("settings_skiplargefiles_desc")) - .addDropdown((dropdown) => { - dropdown.addOption("-1", t("settings_skiplargefiles_notset")); - - const mbs = [1, 5, 10, 50, 100, 500, 1000]; - for (const mb of mbs) { - dropdown.addOption(`${mb * 1000 * 1000}`, `${mb} MB`); - } - dropdown - .setValue(`${this.plugin.settings.skipSizeLargerThan}`) - .onChange(async (val) => { - this.plugin.settings.skipSizeLargerThan = parseInt(val); - await this.plugin.saveSettings(); - }); - }); - - ////////////////////////////////////////////////// - // below for general chooser (part 1/2) + // below for service chooser (part 1/2) ////////////////////////////////////////////////// // we need to create the div in advance of any other service divs - const serviceChooserDiv = generalDiv.createEl("div"); + const serviceChooserFragDiv = containerEl.createEl("div"); + serviceChooserFragDiv.createEl("h2", { text: t("settings_chooseservice") }); + const serviceChooserDiv = serviceChooserFragDiv.createEl("div"); ////////////////////////////////////////////////// // below for s3 @@ -1588,6 +1478,118 @@ export class RemotelySaveSettingTab extends PluginSettingTab { }); }); + ////////////////////////////////////////////////// + // below for basic settings + ////////////////////////////////////////////////// + + const basicDiv = containerEl.createEl("div"); + basicDiv.createEl("h2", { text: t("settings_basic") }); + + const passwordDiv = basicDiv.createEl("div"); + let newPassword = `${this.plugin.settings.password}`; + new Setting(passwordDiv) + .setName(t("settings_password")) + .setDesc(t("settings_password_desc")) + .addText((text) => { + wrapTextWithPasswordHide(text); + text + .setPlaceholder("") + .setValue(`${this.plugin.settings.password}`) + .onChange(async (value) => { + newPassword = value.trim(); + }); + }) + .addButton(async (button) => { + button.setButtonText(t("confirm")); + button.onClick(async () => { + new PasswordModal(this.app, this.plugin, newPassword).open(); + }); + }); + + const scheduleDiv = basicDiv.createEl("div"); + new Setting(scheduleDiv) + .setName(t("settings_autorun")) + .setDesc(t("settings_autorun_desc")) + .addDropdown((dropdown) => { + dropdown.addOption("-1", t("settings_autorun_notset")); + dropdown.addOption(`${1000 * 60 * 1}`, t("settings_autorun_1min")); + dropdown.addOption(`${1000 * 60 * 5}`, t("settings_autorun_5min")); + dropdown.addOption(`${1000 * 60 * 10}`, t("settings_autorun_10min")); + dropdown.addOption(`${1000 * 60 * 30}`, t("settings_autorun_30min")); + + dropdown + .setValue(`${this.plugin.settings.autoRunEveryMilliseconds}`) + .onChange(async (val: string) => { + const realVal = parseInt(val); + this.plugin.settings.autoRunEveryMilliseconds = realVal; + await this.plugin.saveSettings(); + if ( + (realVal === undefined || realVal === null || realVal <= 0) && + this.plugin.autoRunIntervalID !== undefined + ) { + // clear + window.clearInterval(this.plugin.autoRunIntervalID); + this.plugin.autoRunIntervalID = undefined; + } else if ( + realVal !== undefined && + realVal !== null && + realVal > 0 + ) { + const intervalID = window.setInterval(() => { + this.plugin.syncRun("auto"); + }, realVal); + this.plugin.autoRunIntervalID = intervalID; + this.plugin.registerInterval(intervalID); + } + }); + }); + + const runOnceStartUpDiv = basicDiv.createEl("div"); + new Setting(runOnceStartUpDiv) + .setName(t("settings_runoncestartup")) + .setDesc(t("settings_runoncestartup_desc")) + .addDropdown((dropdown) => { + dropdown.addOption("-1", t("settings_runoncestartup_notset")); + dropdown.addOption( + `${1000 * 1 * 1}`, + t("settings_runoncestartup_1sec") + ); + dropdown.addOption( + `${1000 * 10 * 1}`, + t("settings_runoncestartup_10sec") + ); + dropdown.addOption( + `${1000 * 30 * 1}`, + t("settings_runoncestartup_30sec") + ); + dropdown + .setValue(`${this.plugin.settings.initRunAfterMilliseconds}`) + .onChange(async (val: string) => { + const realVal = parseInt(val); + this.plugin.settings.initRunAfterMilliseconds = realVal; + await this.plugin.saveSettings(); + }); + }); + + const skipLargeFilesDiv = basicDiv.createEl("div"); + new Setting(skipLargeFilesDiv) + .setName(t("settings_skiplargefiles")) + .setDesc(t("settings_skiplargefiles_desc")) + .addDropdown((dropdown) => { + dropdown.addOption("-1", t("settings_skiplargefiles_notset")); + + const mbs = [1, 5, 10, 50, 100, 500, 1000]; + for (const mb of mbs) { + dropdown.addOption(`${mb * 1000 * 1000}`, `${mb} MB`); + } + dropdown + .setValue(`${this.plugin.settings.skipSizeLargerThan}`) + .onChange(async (val) => { + this.plugin.settings.skipSizeLargerThan = parseInt(val); + await this.plugin.saveSettings(); + }); + }); + ////////////////////////////////////////////////// // below for advanced settings //////////////////////////////////////////////////