2022-12-01 13:07:23 +01:00
|
|
|
import Component from "./component.js";
|
2020-02-17 22:14:39 +01:00
|
|
|
import appContext from "./app_context.js";
|
2020-05-08 23:39:46 +02:00
|
|
|
import dateNoteService from "../services/date_notes.js";
|
2020-12-05 23:00:28 +01:00
|
|
|
import treeService from "../services/tree.js";
|
2022-12-01 13:07:23 +01:00
|
|
|
import openService from "../services/open.js";
|
|
|
|
import protectedSessionService from "../services/protected_session.js";
|
|
|
|
import options from "../services/options.js";
|
|
|
|
import froca from "../services/froca.js";
|
2020-01-20 22:35:52 +01:00
|
|
|
|
2021-04-24 22:18:25 +02:00
|
|
|
export default class RootCommandExecutor extends Component {
|
2021-06-24 20:27:04 +02:00
|
|
|
editReadOnlyNoteCommand() {
|
|
|
|
const noteContext = appContext.tabManager.getActiveContext();
|
2023-01-24 16:24:51 +01:00
|
|
|
noteContext.viewScope.readOnlyTemporarilyDisabled = true;
|
2021-06-24 20:27:04 +02:00
|
|
|
|
|
|
|
appContext.triggerEvent("readOnlyTemporarilyDisabled", { noteContext });
|
|
|
|
}
|
|
|
|
|
2020-05-08 23:39:46 +02:00
|
|
|
async showSQLConsoleCommand() {
|
|
|
|
const sqlConsoleNote = await dateNoteService.createSqlConsole();
|
|
|
|
|
2023-02-14 16:06:49 +01:00
|
|
|
const noteContext = await appContext.tabManager.openContextWithNote(sqlConsoleNote.noteId, { activate: true });
|
2020-05-08 23:39:46 +02:00
|
|
|
|
2021-05-22 12:26:45 +02:00
|
|
|
appContext.triggerEvent('focusOnDetail', {ntxId: noteContext.ntxId});
|
2020-02-16 19:54:11 +01:00
|
|
|
}
|
|
|
|
|
2021-01-18 22:52:07 +01:00
|
|
|
async searchNotesCommand({searchString, ancestorNoteId}) {
|
|
|
|
const searchNote = await dateNoteService.createSearchNote({searchString, ancestorNoteId});
|
2020-10-25 23:02:12 +01:00
|
|
|
|
2022-01-10 20:37:33 +01:00
|
|
|
// force immediate search
|
|
|
|
await froca.loadSearchNote(searchNote.noteId);
|
|
|
|
|
2022-01-10 20:44:59 +01:00
|
|
|
const activeNoteContext = appContext.tabManager.getActiveContext();
|
|
|
|
const hoistedNoteId = activeNoteContext?.hoistedNoteId || 'root';
|
|
|
|
|
2023-02-14 16:06:49 +01:00
|
|
|
const noteContext = await appContext.tabManager.openContextWithNote(searchNote.noteId, {
|
|
|
|
activate: true,
|
|
|
|
hoistedNoteId
|
|
|
|
});
|
2020-10-25 23:02:12 +01:00
|
|
|
|
2021-05-22 12:26:45 +02:00
|
|
|
appContext.triggerCommand('focusOnSearchDefinition', {ntxId: noteContext.ntxId});
|
2020-10-25 23:02:12 +01:00
|
|
|
}
|
|
|
|
|
2020-12-05 23:00:28 +01:00
|
|
|
async searchInSubtreeCommand({notePath}) {
|
|
|
|
const noteId = treeService.getNoteIdFromNotePath(notePath);
|
|
|
|
|
2021-01-18 22:52:07 +01:00
|
|
|
this.searchNotesCommand({ancestorNoteId: noteId});
|
2020-12-05 23:00:28 +01:00
|
|
|
}
|
|
|
|
|
2021-04-24 22:18:25 +02:00
|
|
|
openNoteExternallyCommand() {
|
2021-05-22 12:35:41 +02:00
|
|
|
const noteId = appContext.tabManager.getActiveContextNoteId();
|
2022-09-21 21:41:51 -04:00
|
|
|
const mime = appContext.tabManager.getActiveContextNoteMime()
|
2022-12-01 13:07:23 +01:00
|
|
|
|
2021-04-24 22:18:25 +02:00
|
|
|
if (noteId) {
|
2022-09-21 21:41:51 -04:00
|
|
|
openService.openNoteExternally(noteId, mime);
|
2021-04-24 22:18:25 +02:00
|
|
|
}
|
|
|
|
}
|
2021-05-18 22:14:35 +02:00
|
|
|
|
|
|
|
enterProtectedSessionCommand() {
|
|
|
|
protectedSessionService.enterProtectedSession();
|
|
|
|
}
|
|
|
|
|
|
|
|
leaveProtectedSessionCommand() {
|
|
|
|
protectedSessionService.leaveProtectedSession();
|
|
|
|
}
|
2021-10-12 19:29:42 +02:00
|
|
|
|
|
|
|
hideLeftPaneCommand() {
|
|
|
|
options.save(`leftPaneVisible`, "false");
|
|
|
|
}
|
|
|
|
|
|
|
|
showLeftPaneCommand() {
|
|
|
|
options.save(`leftPaneVisible`, "true");
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleLeftPaneCommand() {
|
|
|
|
options.toggle('leftPaneVisible');
|
|
|
|
}
|
2022-08-04 23:00:32 +02:00
|
|
|
|
2022-12-15 16:38:05 +01:00
|
|
|
async showBackendLogCommand() {
|
2023-02-14 16:06:49 +01:00
|
|
|
await appContext.tabManager.openContextWithNote('_backendLog', { activate: true });
|
2022-12-15 16:38:05 +01:00
|
|
|
}
|
|
|
|
|
2022-12-01 10:03:04 +01:00
|
|
|
async showLaunchBarSubtreeCommand() {
|
2022-12-21 16:11:00 +01:00
|
|
|
await this.showAndHoistSubtree('_lbRoot');
|
2022-11-25 15:29:57 +01:00
|
|
|
}
|
2022-08-05 16:44:26 +02:00
|
|
|
|
2022-11-25 15:29:57 +01:00
|
|
|
async showShareSubtreeCommand() {
|
2022-12-21 16:11:00 +01:00
|
|
|
await this.showAndHoistSubtree('_share');
|
2022-11-25 15:29:57 +01:00
|
|
|
}
|
2022-08-05 16:44:26 +02:00
|
|
|
|
2022-11-25 15:29:57 +01:00
|
|
|
async showHiddenSubtreeCommand() {
|
2022-12-21 16:11:00 +01:00
|
|
|
await this.showAndHoistSubtree('_hidden');
|
2022-08-04 23:00:32 +02:00
|
|
|
}
|
2022-12-05 23:57:29 +01:00
|
|
|
|
2023-01-23 23:37:58 +01:00
|
|
|
async showOptionsCommand({section}) {
|
2023-02-14 16:06:49 +01:00
|
|
|
await appContext.tabManager.openContextWithNote(section || '_options', {
|
|
|
|
activate: true,
|
|
|
|
hoistedNoteId: '_options'
|
|
|
|
});
|
2022-12-15 16:38:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
async showSQLConsoleHistoryCommand() {
|
2022-12-21 16:11:00 +01:00
|
|
|
await this.showAndHoistSubtree('_sqlConsole');
|
2022-12-15 16:38:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
async showSearchHistoryCommand() {
|
2022-12-21 16:11:00 +01:00
|
|
|
await this.showAndHoistSubtree('_search');
|
2022-12-15 16:38:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
async showAndHoistSubtree(subtreeNoteId) {
|
2023-02-14 16:06:49 +01:00
|
|
|
await appContext.tabManager.openContextWithNote(subtreeNoteId, {
|
|
|
|
activate: true,
|
|
|
|
hoistedNoteId: subtreeNoteId
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-02-15 14:32:12 +01:00
|
|
|
async showNoteSourceCommand() {
|
2023-02-14 16:06:49 +01:00
|
|
|
const notePath = appContext.tabManager.getActiveContextNotePath();
|
|
|
|
|
|
|
|
if (notePath) {
|
|
|
|
await appContext.tabManager.openContextWithNote(notePath, { activate: true, viewMode: 'source' });
|
|
|
|
}
|
2022-12-05 23:57:29 +01:00
|
|
|
}
|
2020-07-04 10:18:01 +02:00
|
|
|
}
|