42 lines
947 B
JavaScript
Raw Normal View History

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