support json syncplans only

This commit is contained in:
fyears 2024-01-13 12:03:21 +08:00
parent 7422956621
commit 347c051d0c
6 changed files with 13 additions and 39 deletions

View File

@ -78,8 +78,7 @@ const turnSyncPlanToTable = (record: string) => {
export const exportVaultSyncPlansToFiles = async (
db: InternalDBs,
vault: Vault,
vaultRandomID: string,
toFormat: "table" | "json" = "json"
vaultRandomID: string
) => {
log.info("exporting");
await mkdirpInVault(DEFAULT_DEBUG_FOLDER, vault);
@ -88,16 +87,9 @@ export const exportVaultSyncPlansToFiles = async (
if (records.length === 0) {
md = "No sync plans history found";
} else {
if (toFormat === "json") {
md =
"Sync plans found:\n\n" +
records.map((x) => "```json\n" + x + "\n```\n").join("\n");
} else if (toFormat === "table") {
md =
"Sync plans found:\n\n" + records.map(turnSyncPlanToTable).join("\n\n");
} else {
const _: never = toFormat;
}
md =
"Sync plans found:\n\n" +
records.map((x) => "```json\n" + x + "\n```\n").join("\n");
}
const ts = Date.now();
const filePath = `${DEFAULT_DEBUG_FOLDER}${DEFAULT_SYNC_PLANS_HISTORY_FILE_PREFIX}${ts}.md`;

View File

@ -261,9 +261,8 @@
"settings_outputsettingsconsole_button": "Output",
"settings_outputsettingsconsole_notice": "Finished outputing in console.",
"settings_syncplans": "Export Sync Plans",
"settings_syncplans_desc": "Sync plans are created every time after you trigger sync and before the actual sync. Useful to know what would actually happen in those sync. Click the button to export sync plans. You can choose to export to json or table format inside Markdown, which are equivalent.",
"settings_syncplans_button_json": "Export (json)",
"settings_syncplans_button_table": "Export (table)",
"settings_syncplans_desc": "Sync plans are created every time after you trigger sync and before the actual sync. Useful to know what would actually happen in those sync. Click the button to export sync plans.",
"settings_syncplans_button_json": "Export",
"settings_syncplans_notice": "Sync plans history exported.",
"settings_delsyncplans": "Delete Sync Plans History In DB",
"settings_delsyncplans_desc": "Delete sync plans history in DB.",

View File

@ -38,7 +38,6 @@
"command_startsync": "开始同步start sync",
"command_drynrun": "开始同步空跑模式start sync (dry run only)",
"command_exportsyncplans_json": "导出同步计划为 json 格式export sync plans in json format",
"command_exportsyncplans_table": "导出同步计划为表格格式export sync plans in table format",
"command_exportlogsindb": "从数据库导出终端日志export logs saved in db",
"statusbar_time_years": "{{time}} 年前",
@ -261,9 +260,8 @@
"settings_outputsettingsconsole_button": "输出",
"settings_outputsettingsconsole_notice": "已输出到终端",
"settings_syncplans": "导出同步计划",
"settings_syncplans_desc": "每次您启动同步,并在实际上传下载前,插件会生成同步计划。它可以使您知道每次同步发生了什么。点击按钮可以导出同步计划。并且,您可以选择导出为内嵌在 Markdown 里的 json 格式或表格格式,它们是等价的。",
"settings_syncplans_button_json": "导出json",
"settings_syncplans_button_table": "导出(表格)",
"settings_syncplans_desc": "每次您启动同步,并在实际上传下载前,插件会生成同步计划。它可以使您知道每次同步发生了什么。点击按钮可以导出同步计划。",
"settings_syncplans_button_json": "导出",
"settings_syncplans_notice": "同步计划已导出",
"settings_delsyncplans": "删除数据库里的同步计划历史",
"settings_delsyncplans_desc": "删除数据库里的同步计划历史。",

View File

@ -38,7 +38,6 @@
"command_startsync": "開始同步start sync",
"command_drynrun": "開始同步空跑模式start sync (dry run only)",
"command_exportsyncplans_json": "匯出同步計劃為 json 格式export sync plans in json format",
"command_exportsyncplans_table": "匯出同步計劃為表格格式export sync plans in table format",
"command_exportlogsindb": "從資料庫匯出終端日誌export logs saved in db",
"statusbar_time_years": "{{time}} 年前",
@ -261,9 +260,8 @@
"settings_outputsettingsconsole_button": "輸出",
"settings_outputsettingsconsole_notice": "已輸出到終端",
"settings_syncplans": "匯出同步計劃",
"settings_syncplans_desc": "每次您啟動同步,並在實際上傳下載前,外掛會生成同步計劃。它可以使您知道每次同步發生了什麼。點選按鈕可以匯出同步計劃。並且,您可以選擇匯出為內嵌在 Markdown 裡的 json 格式或表格格式,它們是等價的。",
"settings_syncplans_button_json": "匯出json",
"settings_syncplans_button_table": "匯出(表格)",
"settings_syncplans_desc": "每次您啟動同步,並在實際上傳下載前,外掛會生成同步計劃。它可以使您知道每次同步發生了什麼。點選按鈕可以匯出同步計劃。",
"settings_syncplans_button_json": "匯出",
"settings_syncplans_notice": "同步計劃已匯出",
"settings_delsyncplans": "刪除資料庫裡的同步計劃歷史",
"settings_delsyncplans_desc": "刪除資料庫裡的同步計劃歷史。",

View File

@ -789,8 +789,7 @@ export default class RemotelySavePlugin extends Plugin {
await exportVaultSyncPlansToFiles(
this.db,
this.app.vault,
this.vaultRandomID,
"json"
this.vaultRandomID
);
new Notice(t("settings_syncplans_notice"));
},

View File

@ -2052,24 +2052,12 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
await exportVaultSyncPlansToFiles(
this.plugin.db,
this.app.vault,
this.plugin.vaultRandomID,
"json"
);
new Notice(t("settings_syncplans_notice"));
});
})
.addButton(async (button) => {
button.setButtonText(t("settings_syncplans_button_table"));
button.onClick(async () => {
await exportVaultSyncPlansToFiles(
this.plugin.db,
this.app.vault,
this.plugin.vaultRandomID,
"table"
this.plugin.vaultRandomID
);
new Notice(t("settings_syncplans_notice"));
});
});
new Setting(debugDiv)
.setName(t("settings_delsyncplans"))
.setDesc(t("settings_delsyncplans_desc"))