mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	converted backend log dialog to new pattern
This commit is contained in:
		| @@ -1,28 +0,0 @@ | |||||||
| import server from "../services/server.js"; |  | ||||||
| import utils from "../services/utils.js"; |  | ||||||
|  |  | ||||||
| const $dialog = $("#backend-log-dialog"); |  | ||||||
| const $backendLogTextArea = $("#backend-log-textarea"); |  | ||||||
| const $refreshBackendLog = $("#refresh-backend-log-button"); |  | ||||||
|  |  | ||||||
| export async function showDialog() { |  | ||||||
|     utils.openDialog($dialog); |  | ||||||
|  |  | ||||||
|     load(); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function scrollToBottom() { |  | ||||||
|     $backendLogTextArea.scrollTop($backendLogTextArea[0].scrollHeight); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| async function load() { |  | ||||||
|     const backendLog = await server.get('backend-log'); |  | ||||||
|  |  | ||||||
|     $backendLogTextArea.text(backendLog); |  | ||||||
|  |  | ||||||
|     scrollToBottom(); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| $refreshBackendLog.on('click', load); |  | ||||||
|  |  | ||||||
| $dialog.on('shown.bs.modal', scrollToBottom); |  | ||||||
| @@ -55,6 +55,7 @@ import AboutDialog from "../widgets/dialogs/about.js"; | |||||||
| import NoteSourceDialog from "../dialogs/note_source.js"; | import NoteSourceDialog from "../dialogs/note_source.js"; | ||||||
| import HelpDialog from "../widgets/dialogs/help.js"; | import HelpDialog from "../widgets/dialogs/help.js"; | ||||||
| import RecentChangesDialog from "../widgets/dialogs/recent_changes.js"; | import RecentChangesDialog from "../widgets/dialogs/recent_changes.js"; | ||||||
|  | import BackendLogDialog from "../widgets/dialogs/backend_log.js"; | ||||||
|  |  | ||||||
| export default class DesktopLayout { | export default class DesktopLayout { | ||||||
|     constructor(customWidgets) { |     constructor(customWidgets) { | ||||||
| @@ -184,6 +185,7 @@ export default class DesktopLayout { | |||||||
|             .child(new AboutDialog()) |             .child(new AboutDialog()) | ||||||
|             .child(new NoteSourceDialog()) |             .child(new NoteSourceDialog()) | ||||||
|             .child(new HelpDialog()) |             .child(new HelpDialog()) | ||||||
|             .child(new RecentChangesDialog()); |             .child(new RecentChangesDialog()) | ||||||
|  |             .child(new BackendLogDialog()); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -78,10 +78,6 @@ export default class RootCommandExecutor extends Component { | |||||||
|         this.searchNotesCommand({ancestorNoteId: noteId}); |         this.searchNotesCommand({ancestorNoteId: noteId}); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     showBackendLogCommand() { |  | ||||||
|         import("../dialogs/backend_log.js").then(d => d.showDialog()); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     openNoteExternallyCommand() { |     openNoteExternallyCommand() { | ||||||
|         const noteId = appContext.tabManager.getActiveContextNoteId(); |         const noteId = appContext.tabManager.getActiveContextNoteId(); | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										53
									
								
								src/public/app/widgets/dialogs/backend_log.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								src/public/app/widgets/dialogs/backend_log.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,53 @@ | |||||||
|  | import server from "../../services/server.js"; | ||||||
|  | import utils from "../../services/utils.js"; | ||||||
|  | import BasicWidget from "../basic_widget.js"; | ||||||
|  |  | ||||||
|  | const TPL = ` | ||||||
|  | <div class="backend-log-dialog modal fade mx-auto" tabindex="-1" role="dialog"> | ||||||
|  |     <div class="modal-dialog modal-xl" role="document"> | ||||||
|  |         <div class="modal-content"> | ||||||
|  |             <div class="modal-header"> | ||||||
|  |                 <h5 class="modal-title">Backend log</h5> | ||||||
|  |                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||||||
|  |                     <span aria-hidden="true">×</span> | ||||||
|  |                 </button> | ||||||
|  |             </div> | ||||||
|  |             <div class="modal-body"> | ||||||
|  |                 <textarea class="backend-log-textarea" readonly="readonly" style="min-height: 600px; width: 100%;"></textarea> | ||||||
|  |             </div> | ||||||
|  |             <div class="modal-footer"> | ||||||
|  |                 <button class="refresh-backend-log-button btn btn-primary">Refresh</button> | ||||||
|  |             </div> | ||||||
|  |         </div> | ||||||
|  |     </div> | ||||||
|  | </div>`; | ||||||
|  |  | ||||||
|  | export default class BackendLogDialog extends BasicWidget { | ||||||
|  |     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()); | ||||||
|  |  | ||||||
|  |         this.$widget.on('shown.bs.modal', () => this.scrollToBottom()); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     scrollToBottom() { | ||||||
|  |         this.$backendLogTextArea.scrollTop(this.$backendLogTextArea[0].scrollHeight); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     async load() { | ||||||
|  |         const backendLog = await server.get('backend-log'); | ||||||
|  |  | ||||||
|  |         this.$backendLogTextArea.text(backendLog); | ||||||
|  |  | ||||||
|  |         this.scrollToBottom(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     async showBackendLogEvent() { | ||||||
|  |         utils.openDialog(this.$widget); | ||||||
|  |  | ||||||
|  |         this.load(); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -31,7 +31,6 @@ | |||||||
| <%- include('dialogs/confirm.ejs') %> | <%- include('dialogs/confirm.ejs') %> | ||||||
| <%- include('dialogs/clone_to.ejs') %> | <%- include('dialogs/clone_to.ejs') %> | ||||||
| <%- include('dialogs/move_to.ejs') %> | <%- include('dialogs/move_to.ejs') %> | ||||||
| <%- include('dialogs/backend_log.ejs') %> |  | ||||||
| <%- include('dialogs/include_note.ejs') %> | <%- include('dialogs/include_note.ejs') %> | ||||||
| <%- include('dialogs/sort_child_notes.ejs') %> | <%- include('dialogs/sort_child_notes.ejs') %> | ||||||
| <%- include('dialogs/delete_notes.ejs') %> | <%- include('dialogs/delete_notes.ejs') %> | ||||||
|   | |||||||
| @@ -1,18 +0,0 @@ | |||||||
| <div id="backend-log-dialog" class="modal fade mx-auto" tabindex="-1" role="dialog"> |  | ||||||
|     <div class="modal-dialog modal-xl" role="document"> |  | ||||||
|         <div class="modal-content"> |  | ||||||
|             <div class="modal-header"> |  | ||||||
|                 <h5 class="modal-title">Backend log</h5> |  | ||||||
|                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"> |  | ||||||
|                     <span aria-hidden="true">×</span> |  | ||||||
|                 </button> |  | ||||||
|             </div> |  | ||||||
|             <div class="modal-body"> |  | ||||||
|                 <textarea id="backend-log-textarea" readonly="readonly" style="min-height: 600px; width: 100%;"></textarea> |  | ||||||
|             </div> |  | ||||||
|             <div class="modal-footer"> |  | ||||||
|                 <button id="refresh-backend-log-button" class="btn btn-primary">Refresh</button> |  | ||||||
|             </div> |  | ||||||
|         </div> |  | ||||||
|     </div> |  | ||||||
| </div> |  | ||||||
		Reference in New Issue
	
	Block a user