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