trilium/src/public/javascripts/dialogs/link_map.js

42 lines
944 B
JavaScript
Raw Normal View History

import utils from "../services/utils.js";
2019-08-28 03:24:31 +08:00
import LinkMapService from "../services/link_map.js";
import noteDetailService from "../services/note_detail.js";
2019-06-04 04:55:59 +08:00
const $linkMapContainer = $("#link-map-container");
2019-06-02 21:35:57 +08:00
const $dialog = $("#link-map-dialog");
const $maxNotesInput = $("#link-map-max-notes");
2019-06-02 21:35:57 +08:00
2019-08-28 03:24:31 +08:00
let linkMapService;
2019-06-04 04:55:59 +08:00
2019-08-28 04:47:10 +08:00
function getOptions() {
return {
maxNotes: $maxNotesInput.val()
};
}
export async function showDialog() {
utils.closeActiveDialog();
2019-06-02 21:35:57 +08:00
glob.activeDialog = $dialog;
// set default settings
2019-08-28 04:47:10 +08:00
$maxNotesInput.val(20);
2019-08-28 04:19:32 +08:00
const note = noteDetailService.getActiveNote();
2019-06-04 04:55:59 +08:00
2019-08-28 03:24:31 +08:00
if (!note) {
2019-06-04 04:55:59 +08:00
return;
}
2019-08-28 04:19:32 +08:00
$linkMapContainer.css("height", $("body").height() - 150);
2019-08-28 04:47:10 +08:00
linkMapService = new LinkMapService(note, $linkMapContainer, getOptions());
2019-08-28 03:24:31 +08:00
linkMapService.render();
2019-06-04 04:55:59 +08:00
2019-08-28 03:24:31 +08:00
$dialog.modal();
2019-06-04 04:55:59 +08:00
}
2019-08-28 04:47:10 +08:00
$maxNotesInput.on("input", () => linkMapService.loadNotesAndRelations(getOptions()));