add commands
This commit is contained in:
parent
0cf8023278
commit
df53ea957f
@ -1 +1 @@
|
|||||||
Subproject commit c46d302441819ee64c8af0170a9ac1aa29dc470f
|
Subproject commit 6bfbaa3c1b5c54885b300d6fb93f9c98d50f54e4
|
||||||
43
src/main.ts
43
src/main.ts
@ -8,7 +8,7 @@ import {
|
|||||||
FileSystemAdapter,
|
FileSystemAdapter,
|
||||||
} from "obsidian";
|
} from "obsidian";
|
||||||
import cloneDeep from "lodash/cloneDeep";
|
import cloneDeep from "lodash/cloneDeep";
|
||||||
import { createElement, RotateCcw, RefreshCcw } from "lucide";
|
import { createElement, RotateCcw, RefreshCcw, FileText } from "lucide";
|
||||||
import type { RemotelySavePluginSettings } from "./baseTypes";
|
import type { RemotelySavePluginSettings } from "./baseTypes";
|
||||||
import {
|
import {
|
||||||
COMMAND_CALLBACK,
|
COMMAND_CALLBACK,
|
||||||
@ -57,6 +57,10 @@ import { applyPresetRulesInplace } from "./presetRules";
|
|||||||
|
|
||||||
import { applyLogWriterInplace, log } from "./moreOnLog";
|
import { applyLogWriterInplace, log } from "./moreOnLog";
|
||||||
import AggregateError from "aggregate-error";
|
import AggregateError from "aggregate-error";
|
||||||
|
import {
|
||||||
|
exportVaultLoggerOutputToFiles,
|
||||||
|
exportVaultSyncPlansToFiles,
|
||||||
|
} from "./debugMode";
|
||||||
|
|
||||||
const DEFAULT_SETTINGS: RemotelySavePluginSettings = {
|
const DEFAULT_SETTINGS: RemotelySavePluginSettings = {
|
||||||
s3: DEFAULT_S3_CONFIG,
|
s3: DEFAULT_S3_CONFIG,
|
||||||
@ -89,6 +93,7 @@ type SyncTriggerSourceType = "manual" | "auto" | "dry" | "autoOnceInit";
|
|||||||
|
|
||||||
const iconNameSyncWait = `remotely-save-sync-wait`;
|
const iconNameSyncWait = `remotely-save-sync-wait`;
|
||||||
const iconNameSyncRunning = `remotely-save-sync-running`;
|
const iconNameSyncRunning = `remotely-save-sync-running`;
|
||||||
|
const iconNameLogs = `remotely-save-logs`;
|
||||||
|
|
||||||
const getIconSvg = () => {
|
const getIconSvg = () => {
|
||||||
const iconSvgSyncWait = createElement(RotateCcw);
|
const iconSvgSyncWait = createElement(RotateCcw);
|
||||||
@ -97,13 +102,18 @@ const getIconSvg = () => {
|
|||||||
const iconSvgSyncRunning = createElement(RefreshCcw);
|
const iconSvgSyncRunning = createElement(RefreshCcw);
|
||||||
iconSvgSyncRunning.setAttribute("width", "100");
|
iconSvgSyncRunning.setAttribute("width", "100");
|
||||||
iconSvgSyncRunning.setAttribute("height", "100");
|
iconSvgSyncRunning.setAttribute("height", "100");
|
||||||
|
const iconSvgLogs = createElement(FileText);
|
||||||
|
iconSvgLogs.setAttribute("width", "100");
|
||||||
|
iconSvgLogs.setAttribute("height", "100");
|
||||||
const res = {
|
const res = {
|
||||||
iconSvgSyncWait: iconSvgSyncWait.outerHTML,
|
iconSvgSyncWait: iconSvgSyncWait.outerHTML,
|
||||||
iconSvgSyncRunning: iconSvgSyncRunning.outerHTML,
|
iconSvgSyncRunning: iconSvgSyncRunning.outerHTML,
|
||||||
|
iconSvgLogs: iconSvgLogs.outerHTML,
|
||||||
};
|
};
|
||||||
|
|
||||||
iconSvgSyncWait.empty();
|
iconSvgSyncWait.empty();
|
||||||
iconSvgSyncRunning.empty();
|
iconSvgSyncRunning.empty();
|
||||||
|
iconSvgLogs.empty();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -369,10 +379,11 @@ export default class RemotelySavePlugin extends Plugin {
|
|||||||
async onload() {
|
async onload() {
|
||||||
log.info(`loading plugin ${this.manifest.id}`);
|
log.info(`loading plugin ${this.manifest.id}`);
|
||||||
|
|
||||||
const { iconSvgSyncWait, iconSvgSyncRunning } = getIconSvg();
|
const { iconSvgSyncWait, iconSvgSyncRunning, iconSvgLogs } = getIconSvg();
|
||||||
|
|
||||||
addIcon(iconNameSyncWait, iconSvgSyncWait);
|
addIcon(iconNameSyncWait, iconSvgSyncWait);
|
||||||
addIcon(iconNameSyncRunning, iconSvgSyncRunning);
|
addIcon(iconNameSyncRunning, iconSvgSyncRunning);
|
||||||
|
addIcon(iconNameLogs, iconSvgLogs);
|
||||||
|
|
||||||
this.oauth2Info = {
|
this.oauth2Info = {
|
||||||
verifier: "",
|
verifier: "",
|
||||||
@ -664,6 +675,34 @@ export default class RemotelySavePlugin extends Plugin {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.addCommand({
|
||||||
|
id: "export-sync-plans",
|
||||||
|
name: t("command_exportsyncplans"),
|
||||||
|
icon: iconNameLogs,
|
||||||
|
callback: async () => {
|
||||||
|
await exportVaultSyncPlansToFiles(
|
||||||
|
this.db,
|
||||||
|
this.app.vault,
|
||||||
|
this.vaultRandomID
|
||||||
|
);
|
||||||
|
new Notice(t("settings_syncplans_notice"));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
this.addCommand({
|
||||||
|
id: "export-logs-in-db",
|
||||||
|
name: t("command_exportlogsindb"),
|
||||||
|
icon: iconNameLogs,
|
||||||
|
callback: async () => {
|
||||||
|
await exportVaultLoggerOutputToFiles(
|
||||||
|
this.db,
|
||||||
|
this.app.vault,
|
||||||
|
this.vaultRandomID
|
||||||
|
);
|
||||||
|
new Notice(t("settings_logtodbexport_notice"));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
this.addSettingTab(new RemotelySaveSettingTab(this.app, this));
|
this.addSettingTab(new RemotelySaveSettingTab(this.app, this));
|
||||||
|
|
||||||
// this.registerDomEvent(document, "click", (evt: MouseEvent) => {
|
// this.registerDomEvent(document, "click", (evt: MouseEvent) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user