mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	Merge remote-tracking branch 'origin/master'
This commit is contained in:
		
						commit
						1640a8aa7d
					
				
							
								
								
									
										33
									
								
								db/migrations/0206__delete_search_and_sql_console_history.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								db/migrations/0206__delete_search_and_sql_console_history.js
									
									
									
									
									
										Normal file
									
								
							| @ -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'); | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
| }; | ||||
							
								
								
									
										2
									
								
								db/migrations/0207__rename_search_and_sql_console.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								db/migrations/0207__rename_search_and_sql_console.sql
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| UPDATE notes SET title = 'SQL Console History' WHERE noteId = 'sqlConsole'; | ||||
| UPDATE notes SET title = 'Search History' WHERE noteId = 'search'; | ||||
							
								
								
									
										5
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										5
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @ -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": { | ||||
|  | ||||
| @ -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); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -102,18 +102,18 @@ const TPL = ` | ||||
| 
 | ||||
|         <li class="dropdown-item" data-trigger-command="openNewWindow"> | ||||
|             <span class="bx bx-window-open"></span> | ||||
|             Open new window | ||||
|             Open New Window | ||||
|             <kbd data-command="openNewWindow"></kbd> | ||||
|         </li> | ||||
| 
 | ||||
|         <li class="dropdown-item switch-to-mobile-version-button" data-trigger-command="switchToMobileVersion"> | ||||
|             <span class="bx bx-mobile"></span> | ||||
|             Switch to mobile version | ||||
|             Switch to Mobile Version | ||||
|         </li> | ||||
|          | ||||
|         <li class="dropdown-item switch-to-desktop-version-button" data-trigger-command="switchToDesktopVersion"> | ||||
|             <span class="bx bx-desktop"></span> | ||||
|             Switch to desktop version | ||||
|             Switch to Desktop Version | ||||
|         </li> | ||||
|          | ||||
|         <span class="zoom-container dropdown-item"> | ||||
| @ -123,26 +123,26 @@ const TPL = ` | ||||
|             </div> | ||||
|              | ||||
|             <div class="zoom-buttons"> | ||||
|                 <a data-trigger-command="toggleFullscreen" title="Toggle fullscreen" class="bx bx-expand-alt"></a> | ||||
|                 <a data-trigger-command="toggleFullscreen" title="Toggle Fullscreen" class="bx bx-expand-alt"></a> | ||||
|                  | ||||
|                   | ||||
|                  | ||||
|                 <a data-trigger-command="zoomOut" title="Zoom out" class="bx bx-minus"></a> | ||||
|                 <a data-trigger-command="zoomOut" title="Zoom Out" class="bx bx-minus"></a> | ||||
|                  | ||||
|                 <span class="zoom-state"></span> | ||||
|                  | ||||
|                 <a data-trigger-command="zoomIn" title="Zoom in" class="bx bx-plus"></a> | ||||
|                 <a data-trigger-command="zoomIn" title="Zoom In" class="bx bx-plus"></a> | ||||
|             </div> | ||||
|         </span> | ||||
| 
 | ||||
|         <li class="dropdown-item" data-trigger-command="showLaunchBarSubtree"> | ||||
|             <span class="bx bx-sidebar"></span> | ||||
|             Configure launchbar | ||||
|             Configure Launchbar | ||||
|         </li> | ||||
|          | ||||
|         <li class="dropdown-item" data-trigger-command="showShareSubtree"> | ||||
|             <span class="bx bx-share-alt"></span> | ||||
|             Show share subtree | ||||
|             Show Shared Notes Subtree | ||||
|         </li> | ||||
|          | ||||
|         <li class="dropdown-item dropdown-submenu"> | ||||
| @ -153,7 +153,7 @@ const TPL = ` | ||||
|              | ||||
|             <ul class="dropdown-menu"> | ||||
|                 <li class="dropdown-item open-dev-tools-button" data-trigger-command="openDevTools"> | ||||
|                     <span class="bx bx-terminal"></span> | ||||
|                     <span class="bx bx-bug-alt"></span> | ||||
|                     Open Dev Tools | ||||
|                     <kbd data-command="openDevTools"></kbd> | ||||
|                 </li> | ||||
| @ -163,23 +163,33 @@ const TPL = ` | ||||
|                     Open SQL Console | ||||
|                     <kbd data-command="showSQLConsole"></kbd> | ||||
|                 </li> | ||||
|                  | ||||
|                 <li class="dropdown-item" data-trigger-command="showSQLConsoleHistory"> | ||||
|                     <span class="bx bx-empty"></span> | ||||
|                     Open SQL Console History | ||||
|                 </li> | ||||
|                  | ||||
|                 <li class="dropdown-item" data-trigger-command="showSearchHistory"> | ||||
|                     <span class="bx bx-empty"></span> | ||||
|                     Open Search History | ||||
|                 </li> | ||||
|          | ||||
|                 <li class="dropdown-item" data-trigger-command="showBackendLog"> | ||||
|                     <span class="bx bx-empty"></span> | ||||
|                     Show backend log | ||||
|                     Show Backend Log | ||||
|                     <kbd data-command="showBackendLog"></kbd> | ||||
|                 </li> | ||||
|                  | ||||
|                 <li class="dropdown-item" data-trigger-command="reloadFrontendApp"  | ||||
|                     title="Reload can help with some visual glitches without restarting the whole app."> | ||||
|                     <span class="bx bx-empty"></span> | ||||
|                     Reload frontend | ||||
|                     Reload Frontend | ||||
|                     <kbd data-command="reloadFrontendApp"></kbd> | ||||
|                 </li> | ||||
|                  | ||||
|                 <li class="dropdown-item" data-trigger-command="showHiddenSubtree"> | ||||
|                     <span class="bx bx-empty"></span> | ||||
|                     Show hidden subtree | ||||
|                     Show Hidden Subtree | ||||
|                 </li> | ||||
|             </ul> | ||||
|         </li> | ||||
|  | ||||
| @ -12,7 +12,7 @@ const TPL = ` | ||||
|                     <span aria-hidden="true">×</span> | ||||
|                 </button> | ||||
|             </div> | ||||
|             <div class="modal-body"> | ||||
|             e<div class="modal-body"> | ||||
|                 <textarea class="backend-log-textarea" readonly="readonly" style="min-height: 600px; width: 100%;"></textarea> | ||||
|             </div> | ||||
|             <div class="modal-footer"> | ||||
| @ -44,10 +44,4 @@ export default class BackendLogDialog extends BasicWidget { | ||||
| 
 | ||||
|         this.scrollToBottom(); | ||||
|     } | ||||
| 
 | ||||
|     async showBackendLogEvent() { | ||||
|         utils.openDialog(this.$widget); | ||||
| 
 | ||||
|         this.load(); | ||||
|     } | ||||
| } | ||||
|  | ||||
							
								
								
									
										44
									
								
								src/public/app/widgets/type_widgets/content/backend_log.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								src/public/app/widgets/type_widgets/content/backend_log.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,44 @@ | ||||
| import NoteContextAwareWidget from "../../note_context_aware_widget.js"; | ||||
| import server from "../../../services/server.js"; | ||||
| 
 | ||||
| const TPL = `<div style="height: 100%; display: flex; flex-direction: column;">
 | ||||
|     <style> | ||||
|         .backend-log-textarea { | ||||
|             flex-grow: 1;  | ||||
|             width: 100%; | ||||
|             border: none; | ||||
|         }    | ||||
|     </style> | ||||
| 
 | ||||
|     <textarea class="backend-log-textarea" readonly="readonly"></textarea> | ||||
|      | ||||
|     <div style="display: flex; justify-content: space-around; margin-top: 10px;"> | ||||
|         <button class="refresh-backend-log-button btn btn-primary">Refresh</button> | ||||
|     </div> | ||||
| </div>`; | ||||
| 
 | ||||
| export default class ContentLogWidget extends NoteContextAwareWidget { | ||||
|     doRender() { | ||||
|         this.$widget = $(TPL); | ||||
|         this.$backendLogTextArea = this.$widget.find(".backend-log-textarea"); | ||||
|         this.$refreshBackendLog = this.$widget.find(".refresh-backend-log-button"); | ||||
| 
 | ||||
|         this.$refreshBackendLog.on('click', () => this.load()); | ||||
|     } | ||||
| 
 | ||||
|     scrollToBottom() { | ||||
|         this.$backendLogTextArea.scrollTop(this.$backendLogTextArea[0].scrollHeight); | ||||
|     } | ||||
| 
 | ||||
|     async refresh() { | ||||
|         await this.load(); | ||||
|     } | ||||
| 
 | ||||
|     async load() { | ||||
|         const backendLog = await server.get('backend-log'); | ||||
| 
 | ||||
|         this.$backendLogTextArea.text(backendLog); | ||||
| 
 | ||||
|         this.scrollToBottom(); | ||||
|     } | ||||
| } | ||||
| @ -27,6 +27,7 @@ import DatabaseIntegrityCheckOptions from "./options/advanced/database_integrity | ||||
| import ConsistencyChecksOptions from "./options/advanced/consistency_checks.js"; | ||||
| import VacuumDatabaseOptions from "./options/advanced/vacuum_database.js"; | ||||
| import DatabaseAnonymizationOptions from "./options/advanced/database_anonymization.js"; | ||||
| import ContentLogWidget from "./content/backend_log.js"; | ||||
| 
 | ||||
| const TPL = `<div class="note-detail-content-widget note-detail-printable">
 | ||||
|     <style> | ||||
| @ -85,7 +86,8 @@ const CONTENT_WIDGETS = { | ||||
|         DatabaseAnonymizationOptions, | ||||
|         AdvancedSyncOptions, | ||||
|         VacuumDatabaseOptions | ||||
|     ] | ||||
|     ], | ||||
|     backendLog: [ ContentLogWidget ] | ||||
| }; | ||||
| 
 | ||||
| export default class ContentWidgetTypeWidget extends TypeWidget { | ||||
|  | ||||
| @ -4,7 +4,7 @@ const build = require('./build'); | ||||
| const packageJson = require('../../package'); | ||||
| const {TRILIUM_DATA_DIR} = require('./data_dir'); | ||||
| 
 | ||||
| const APP_DB_VERSION = 205; | ||||
| const APP_DB_VERSION = 207; | ||||
| const SYNC_VERSION = 28; | ||||
| const CLIPPER_PROTOCOL_VERSION = "1.0"; | ||||
| 
 | ||||
|  | ||||
| @ -28,7 +28,7 @@ const HIDDEN_SUBTREE_DEFINITION = { | ||||
|     children: [ | ||||
|         { | ||||
|             id: 'search', | ||||
|             title: 'search', | ||||
|             title: 'Search History', | ||||
|             type: 'doc' | ||||
|         }, | ||||
|         { | ||||
| @ -42,7 +42,7 @@ const HIDDEN_SUBTREE_DEFINITION = { | ||||
|         }, | ||||
|         { | ||||
|             id: 'sqlConsole', | ||||
|             title: 'SQL Console', | ||||
|             title: 'SQL Console History', | ||||
|             type: 'doc', | ||||
|             icon: 'bx-data' | ||||
|         }, | ||||
| @ -57,6 +57,15 @@ const HIDDEN_SUBTREE_DEFINITION = { | ||||
|             title: 'Bulk action', | ||||
|             type: 'doc', | ||||
|         }, | ||||
|         { | ||||
|             id: 'backendLog', | ||||
|             title: 'Backend Log', | ||||
|             type: 'contentWidget', | ||||
|             icon: 'bx-terminal', | ||||
|             attributes: [ | ||||
|                 { type: 'label', name: 'keepCurrentHoisting' } | ||||
|             ] | ||||
|         }, | ||||
|         { | ||||
|             // place for user scripts hidden stuff (scripts should not create notes directly under hidden root)
 | ||||
|             id: 'userHidden', | ||||
| @ -158,8 +167,9 @@ const HIDDEN_SUBTREE_DEFINITION = { | ||||
|                     isExpanded: true, | ||||
|                     attributes: [ { type: 'label', name: 'docName', value: 'launchbar_intro' } ], | ||||
|                     children: [ | ||||
|                         { id: 'lbBackInHistory', title: 'Back in history', type: 'launcher', builtinWidget: 'backInHistoryButton', icon: 'bx bxs-left-arrow-square' }, | ||||
|                         { id: 'lbForwardInHistory', title: 'Forward in history', type: 'launcher', builtinWidget: 'forwardInHistoryButton', icon: 'bx bxs-right-arrow-square' }, | ||||
|                         { id: 'lbBackInHistory', title: 'Back in History', type: 'launcher', builtinWidget: 'backInHistoryButton', icon: 'bx bxs-left-arrow-square' }, | ||||
|                         { id: 'lbForwardInHistory', title: 'Forward in History', type: 'launcher', builtinWidget: 'forwardInHistoryButton', icon: 'bx bxs-right-arrow-square' }, | ||||
|                         { id: 'lbBackendLog', title: 'Backend Log', type: 'launcher', targetNoteId: 'backendLog', icon: 'bx bx-terminal' }, | ||||
|                     ] | ||||
|                 }, | ||||
|                 { | ||||
|  | ||||
| @ -6,6 +6,8 @@ const cls = require("./cls"); | ||||
| const dateUtils = require("./date_utils"); | ||||
| const log = require("./log"); | ||||
| const hiddenSubtreeService = require("./hidden_subtree"); | ||||
| const searchService = require("./search/services/search.js"); | ||||
| const SearchContext = require("./search/search_context.js"); | ||||
| 
 | ||||
| function getInboxNote(date) { | ||||
|     const hoistedNote = getHoistedNote(); | ||||
| @ -33,7 +35,7 @@ function getInboxNote(date) { | ||||
| 
 | ||||
| function createSqlConsole() { | ||||
|     const {note} = noteService.createNewNote({ | ||||
|         parentNoteId: 'sqlConsole', | ||||
|         parentNoteId: getMonthlyParentNoteId('sqlConsole'), | ||||
|         title: 'SQL Console', | ||||
|         content: "SELECT title, isDeleted, isProtected FROM notes WHERE noteId = ''\n\n\n\n", | ||||
|         type: 'code', | ||||
| @ -68,7 +70,7 @@ function saveSqlConsole(sqlConsoleNoteId) { | ||||
| 
 | ||||
| function createSearchNote(searchString, ancestorNoteId) { | ||||
|     const {note} = noteService.createNewNote({ | ||||
|         parentNoteId: 'search', | ||||
|         parentNoteId: getMonthlyParentNoteId('search'), | ||||
|         title: 'Search: ' + searchString, | ||||
|         content: "", | ||||
|         type: 'search', | ||||
| @ -115,6 +117,28 @@ function saveSearchNote(searchNoteId) { | ||||
|     return result; | ||||
| } | ||||
| 
 | ||||
| function getMonthlyParentNoteId(rootNoteId) { | ||||
|     const month = dateUtils.localNowDate().substring(0, 7); | ||||
|     const labelName = `${rootNoteId}MonthNote`; | ||||
| 
 | ||||
|     let monthNote = searchService.findFirstNoteWithQuery(`#${labelName}="${month}"`, | ||||
|         new SearchContext({ancestorNoteId: rootNoteId})); | ||||
| 
 | ||||
|     if (!monthNote) { | ||||
|         monthNote = noteService.createNewNote({ | ||||
|             parentNoteId: rootNoteId, | ||||
|             title: month, | ||||
|             content: '', | ||||
|             isProtected: false, | ||||
|             type: 'book' | ||||
|         }).note | ||||
| 
 | ||||
|         monthNote.addLabel(labelName, month); | ||||
|     } | ||||
| 
 | ||||
|     return monthNote.noteId; | ||||
| } | ||||
| 
 | ||||
| function getHoistedNote() { | ||||
|     return becca.getNote(cls.getHoistedNoteId()); | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam