From 195c6a40899160fbd90a40d5808e489bc12bb56f Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 15 Dec 2022 16:38:05 +0100 Subject: [PATCH] backend log improvements --- ...__delete_search_and_sql_console_history.js | 33 ++++++++++++++ .../0207__rename_search_and_sql_console.sql | 2 + package-lock.json | 5 +-- .../app/components/root_command_executor.js | 24 ++++++++-- src/public/app/widgets/buttons/global_menu.js | 34 +++++++++----- src/public/app/widgets/dialogs/backend_log.js | 8 +--- .../type_widgets/content/backend_log.js | 44 +++++++++++++++++++ .../widgets/type_widgets/content_widget.js | 4 +- src/services/app_info.js | 2 +- src/services/hidden_subtree.js | 18 ++++++-- src/services/special_notes.js | 28 +++++++++++- 11 files changed, 168 insertions(+), 34 deletions(-) create mode 100644 db/migrations/0206__delete_search_and_sql_console_history.js create mode 100644 db/migrations/0207__rename_search_and_sql_console.sql create mode 100644 src/public/app/widgets/type_widgets/content/backend_log.js diff --git a/db/migrations/0206__delete_search_and_sql_console_history.js b/db/migrations/0206__delete_search_and_sql_console_history.js new file mode 100644 index 000000000..1c6568f95 --- /dev/null +++ b/db/migrations/0206__delete_search_and_sql_console_history.js @@ -0,0 +1,33 @@ +// the history was previously not exposed and the fact they were not cleaned up is rather a side-effect than an intention + +module.exports = () => { + const cls = require("../../src/services/cls"); + const beccaLoader = require("../../src/becca/becca_loader"); + const becca = require("../../src/becca/becca"); + + cls.init(() => { + beccaLoader.load(); + + // deleting just branches because they might be cloned (and therefore saved) also outside of the hidden subtree + + const searchRoot = becca.getNote('search'); + + for (const searchBranch of searchRoot.getChildBranches()) { + const searchNote = searchBranch.getNote(); + + if (searchNote.type === 'search') { + searchBranch.deleteBranch('0206__delete_search_and_sql_console_history'); + } + } + + const sqlConsoleRoot = becca.getNote('sqlConsole'); + + for (const sqlConsoleBranch of sqlConsoleRoot.getChildBranches()) { + const sqlConsoleNote = sqlConsoleBranch.getNote(); + + if (sqlConsoleNote.type === 'code' && sqlConsoleNote.mime === 'text/x-sqlite;schema=trilium') { + sqlConsoleBranch.deleteBranch('0206__delete_search_and_sql_console_history'); + } + } + }); +}; diff --git a/db/migrations/0207__rename_search_and_sql_console.sql b/db/migrations/0207__rename_search_and_sql_console.sql new file mode 100644 index 000000000..79398fd4c --- /dev/null +++ b/db/migrations/0207__rename_search_and_sql_console.sql @@ -0,0 +1,2 @@ +UPDATE notes SET title = 'SQL Console History' WHERE noteId = 'sqlConsole'; +UPDATE notes SET title = 'Search History' WHERE noteId = 'search'; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index a7f5f3a24..701daf498 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,11 @@ { "name": "trilium", - "version": "0.57.4", + "version": "0.57.5", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "trilium", - "version": "0.57.4", + "version": "0.57.5", "hasInstallScript": true, "license": "AGPL-3.0-only", "dependencies": { diff --git a/src/public/app/components/root_command_executor.js b/src/public/app/components/root_command_executor.js index e4001ebb8..c053df4f4 100644 --- a/src/public/app/components/root_command_executor.js +++ b/src/public/app/components/root_command_executor.js @@ -72,19 +72,35 @@ export default class RootCommandExecutor extends Component { options.toggle('leftPaneVisible'); } + async showBackendLogCommand() { + await appContext.tabManager.openContextWithNote('backendLog', true); + } + async showLaunchBarSubtreeCommand() { - await appContext.tabManager.openContextWithNote('lbRoot', true, null, 'lbRoot'); + await this.showAndHoistSubtree('lbRoot'); } async showShareSubtreeCommand() { - await appContext.tabManager.openContextWithNote('share', true, null, 'share'); + await this.showAndHoistSubtree('share'); } async showHiddenSubtreeCommand() { - await appContext.tabManager.openContextWithNote('hidden', true, null, 'hidden'); + await this.showAndHoistSubtree('hidden'); } async showOptionsCommand() { - await appContext.tabManager.openContextWithNote('options', true, null, 'options') + await this.showAndHoistSubtree('options'); + } + + async showSQLConsoleHistoryCommand() { + await this.showAndHoistSubtree('sqlConsole'); + } + + async showSearchHistoryCommand() { + await this.showAndHoistSubtree('search'); + } + + async showAndHoistSubtree(subtreeNoteId) { + await appContext.tabManager.openContextWithNote(subtreeNoteId, true, null, subtreeNoteId); } } diff --git a/src/public/app/widgets/buttons/global_menu.js b/src/public/app/widgets/buttons/global_menu.js index 1f8594c03..01b08bfb3 100644 --- a/src/public/app/widgets/buttons/global_menu.js +++ b/src/public/app/widgets/buttons/global_menu.js @@ -102,18 +102,18 @@ const TPL = ` @@ -123,26 +123,26 @@ const TPL = `
- +   - + - +
diff --git a/src/public/app/widgets/dialogs/backend_log.js b/src/public/app/widgets/dialogs/backend_log.js index 0a6bb3889..dab76ac57 100644 --- a/src/public/app/widgets/dialogs/backend_log.js +++ b/src/public/app/widgets/dialogs/backend_log.js @@ -12,7 +12,7 @@ const TPL = ` -