This commit is contained in:
fyears
2022-04-06 00:24:27 +08:00
parent b39544b43b
commit b3c107ce58
19 changed files with 359 additions and 45 deletions
+72 -4
View File
@@ -9,18 +9,25 @@ import {
} from "obsidian";
import {
API_VER_REQURL,
DEFAULT_DEBUG_FOLDER,
SUPPORTED_SERVICES_TYPE,
SUPPORTED_SERVICES_TYPE_WITH_REMOTE_BASE_DIR,
VALID_REQURL,
WebdavAuthType,
WebdavDepthType,
} from "./baseTypes";
import { exportVaultSyncPlansToFiles } from "./debugMode";
import {
exportVaultSyncPlansToFiles,
exportVaultLoggerOutputToFiles,
} from "./debugMode";
import { exportQrCodeUri } from "./importExport";
import {
clearAllSyncMetaMapping,
clearAllSyncPlanRecords,
destroyDBs,
clearAllLoggerOutputRecords,
insertLoggerOutputByVault,
clearExpiredLoggerOutputRecords,
} from "./localdb";
import type RemotelySavePlugin from "./main"; // unavoidable
import { RemoteClient } from "./remote";
@@ -36,11 +43,14 @@ import {
} from "./remoteForOnedrive";
import { messyConfigToNormal } from "./configPersist";
import type { TransItemType } from "./i18n";
import * as origLog from "loglevel";
import { checkHasSpecialCharForDir } from "./misc";
import { applyWebdavPresetRulesInplace } from "./presetRules";
const log = origLog.getLogger("rs-default");
import {
applyLogWriterInplace,
log,
restoreLogWritterInplace,
} from "./moreOnLog";
class PasswordModal extends Modal {
plugin: RemotelySavePlugin;
@@ -1702,6 +1712,64 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
});
});
const logToDBDiv = debugDiv.createEl("div");
new Setting(logToDBDiv)
.setName(t("settings_logtodb"))
.setDesc(t("settings_logtodb_desc"))
.addDropdown(async (dropdown) => {
dropdown.addOption("enable", t("enable"));
dropdown.addOption("disable", t("disable"));
dropdown
.setValue(this.plugin.settings.logToDB ? "enable" : "disable")
.onChange(async (val: string) => {
const logToDB = val === "enable";
if (logToDB) {
applyLogWriterInplace((...msg: any[]) => {
insertLoggerOutputByVault(
this.plugin.db,
this.plugin.vaultRandomID,
...msg
);
});
} else {
restoreLogWritterInplace();
}
clearExpiredLoggerOutputRecords(this.plugin.db);
this.plugin.settings.logToDB = logToDB;
await this.plugin.saveSettings();
});
});
new Setting(logToDBDiv)
.setName(t("settings_logtodbexport"))
.setDesc(
t("settings_logtodbexport_desc", {
debugFolder: DEFAULT_DEBUG_FOLDER,
})
)
.addButton(async (button) => {
button.setButtonText(t("settings_logtodbexport_button"));
button.onClick(async () => {
await exportVaultLoggerOutputToFiles(
this.plugin.db,
this.app.vault,
this.plugin.vaultRandomID
);
new Notice(t("settings_logtodbexport_notice"));
});
});
new Setting(logToDBDiv)
.setName(t("settings_logtodbclear"))
.setDesc(t("settings_logtodbclear_desc"))
.addButton(async (button) => {
button.setButtonText(t("settings_logtodbclear_button"));
button.onClick(async () => {
await clearAllLoggerOutputRecords(this.plugin.db);
new Notice(t("settings_logtodbclear_notice"));
});
});
const syncMappingDiv = debugDiv.createEl("div");
new Setting(syncMappingDiv)
.setName(t("settings_delsyncmap"))