mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	link map fixes
This commit is contained in:
		| @@ -4,21 +4,24 @@ import noteDetailService from "../services/note_detail.js"; | ||||
|  | ||||
| const $linkMapContainer = $("#link-map-container"); | ||||
|  | ||||
| const LINK_TYPES = [ "hyper", "image", "relation", "relation-map" ]; | ||||
|  | ||||
| const $dialog = $("#link-map-dialog"); | ||||
| const $maxNotesInput = $("#link-map-max-notes"); | ||||
|  | ||||
| let linkMapService; | ||||
|  | ||||
| function getOptions() { | ||||
|     return { | ||||
|         maxNotes: $maxNotesInput.val() | ||||
|     }; | ||||
| } | ||||
|  | ||||
| export async function showDialog() { | ||||
|     utils.closeActiveDialog(); | ||||
|  | ||||
|     glob.activeDialog = $dialog; | ||||
|  | ||||
|     // set default settings | ||||
|     $maxNotesInput.val(10); | ||||
|     LINK_TYPES.forEach(lt => $("#link-map-" + lt).prop('checked', true)); | ||||
|     $maxNotesInput.val(20); | ||||
|  | ||||
|     const note = noteDetailService.getActiveNote(); | ||||
|  | ||||
| @@ -28,12 +31,11 @@ export async function showDialog() { | ||||
|  | ||||
|     $linkMapContainer.css("height", $("body").height() - 150); | ||||
|  | ||||
|     linkMapService = new LinkMapService(note, $linkMapContainer); | ||||
|     linkMapService = new LinkMapService(note, $linkMapContainer, getOptions()); | ||||
|  | ||||
|     linkMapService.render(); | ||||
|  | ||||
|     $dialog.modal(); | ||||
| } | ||||
|  | ||||
| $(".link-map-settings").change(() => linkMapService.loadNotesAndRelations()); | ||||
|  | ||||
| $maxNotesInput.on("input", () => linkMapService.loadNotesAndRelations()); | ||||
| $maxNotesInput.on("input", () => linkMapService.loadNotesAndRelations(getOptions())); | ||||
|   | ||||
| @@ -18,6 +18,7 @@ export default class LinkMap { | ||||
|         this.note = note; | ||||
|         this.options = $.extend({ | ||||
|             maxDepth: 10, | ||||
|             maxNotes: 30, | ||||
|             zoom: 1.0 | ||||
|         }, options); | ||||
|  | ||||
| @@ -37,13 +38,13 @@ export default class LinkMap { | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     async loadNotesAndRelations() { | ||||
|     async loadNotesAndRelations(options = {}) { | ||||
|         this.options = $.extend(this.options, options); | ||||
|  | ||||
|         this.cleanup(); | ||||
|  | ||||
|         const maxNotes = 50; | ||||
|  | ||||
|         const links = await server.post(`notes/${this.note.noteId}/link-map`, { | ||||
|             maxNotes, | ||||
|             maxNotes: this.options.maxNotes, | ||||
|             maxDepth: this.options.maxDepth | ||||
|         }); | ||||
|  | ||||
|   | ||||
| @@ -2,13 +2,15 @@ | ||||
|  | ||||
| const sql = require('../../services/sql'); | ||||
|  | ||||
| async function getRelations(noteIds, relationNames) { | ||||
| async function getRelations(noteIds) { | ||||
|     return (await sql.getManyRows(` | ||||
|         SELECT noteId, name, value AS targetNoteId | ||||
|         FROM attributes | ||||
|         WHERE (noteId IN (???) OR value IN (???)) | ||||
|           AND type = 'relation' | ||||
|           AND isDeleted = 0 | ||||
|           AND noteId != '' | ||||
|           AND value != '' | ||||
|     `, Array.from(noteIds))); | ||||
| } | ||||
|  | ||||
| @@ -35,9 +37,9 @@ async function getLinkMap(req) { | ||||
|             // no new note discovered, no need to search any further | ||||
|             break; | ||||
|         } | ||||
|  | ||||
|         console.log(newNoteIds.size, maxNotes); | ||||
|         if (newNoteIds.size > maxNotes) { | ||||
|             // to many notes to display | ||||
|             // too many notes to display | ||||
|             break; | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -280,7 +280,7 @@ async function saveLinks(note, content) { | ||||
|                 noteId: note.noteId, | ||||
|                 type: 'relation', | ||||
|                 name: foundLink.name, | ||||
|                 value: foundLink.targetNoteId, | ||||
|                 value: foundLink.value, | ||||
|             }).save(); | ||||
|         } | ||||
|         else if (existingLink.isDeleted) { | ||||
|   | ||||
| @@ -5,32 +5,12 @@ | ||||
|                 <h5 class="modal-title" style="width: auto;">Link map</h5> | ||||
|  | ||||
|                 <div style="vertical-align: middle;"> | ||||
|                     <div class="form-check form-check-inline"> | ||||
|                         <input class="form-check-input link-map-settings" type="checkbox" id="link-map-hyper"> | ||||
|                         <label class="form-check-label" for="link-map-hyper">text links</label> | ||||
|                     </div> | ||||
|  | ||||
|                     <div class="form-check form-check-inline"> | ||||
|                         <input class="form-check-input link-map-settings" type="checkbox" id="link-map-image"> | ||||
|                         <label class="form-check-label" for="link-map-image">image links</label> | ||||
|                     </div> | ||||
|  | ||||
|                     <div class="form-check form-check-inline"> | ||||
|                         <input class="form-check-input link-map-settings" type="checkbox" id="link-map-relation"> | ||||
|                         <label class="form-check-label" for="link-map-relation">relations</label> | ||||
|                     </div> | ||||
|  | ||||
|                     <div class="form-check form-check-inline"> | ||||
|                         <input class="form-check-input link-map-settings" type="checkbox" id="link-map-relation-map"> | ||||
|                         <label class="form-check-label" for="link-map-relation-map">relation map links</label> | ||||
|                     </div> | ||||
|  | ||||
|                     <div style="display: inline-block; position: relative; top: -3px;"> | ||||
|                         <label for="link-map-max-notes" title="Max number of displayed notes"> | ||||
|                             <strong>max notes:</strong> | ||||
|                         </label> | ||||
|  | ||||
|                         <input id="link-map-max-notes" type="number" value="50" min="5" max="1000" step="5" | ||||
|                         <input id="link-map-max-notes" type="number" value="20" min="5" max="1000" step="5" | ||||
|                                class="form-control form-control-sm" | ||||
|                                style="width: 80px; display: inline-block; text-align: right;"/> | ||||
|                     </div> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user