Skip to content

Build your personal knowledge base with Trilium Notes

link router/loading

zadam7eed0766749e
diff --git a/src/public/javascripts/dialogs/link_map.js b/src/public/javascripts/dialogs/link_map.js
index 0df8ab83e7..67f084186d 100644
--- a/src/public/javascripts/dialogs/link_map.js
+++ b/src/public/javascripts/dialogs/link_map.js
@@ -1,8 +1,17 @@
+import server from '../services/server.js';
+import noteDetailService from "../services/note_detail.js";
+
const $dialog = $("#link-map-dialog");
async function showDialog() {
glob.activeDialog = $dialog;
+ const noteId = noteDetailService.getActiveNoteId();
+
+ const links = await server.get(`notes/${noteId}/links`);
+
+ console.log(links);
+
$dialog.modal();
}
diff --git a/src/routes/api/links.js b/src/routes/api/links.js
new file mode 100644
index 0000000000..4e6181fecc
--- /dev/null
+++ b/src/routes/api/links.js
@@ -0,0 +1,17 @@
+"use strict";
+
+const sql = require('../../services/sql');
+
+async function getNoteLinks(req) {
+ const {noteId} = req.params;
+
+ return await sql.getRows(`
+ SELECT noteId, targetNoteId, type FROM links WHERE (noteId = ? OR targetNoteId = ?) AND isDeleted = 0
+ UNION
+ SELECT noteId, value, 'relation' FROM attributes WHERE (noteId = ? OR value = ?) AND type = 'relation' AND isDeleted = 0
+ `, [noteId, noteId, noteId, noteId]);
+}
+
+module.exports = {
+ getNoteLinks
+};
\ No newline at end of file
diff --git a/src/routes/routes.js b/src/routes/routes.js
index d4f444174a..160dfd6fe1 100644
--- a/src/routes/routes.js
+++ b/src/routes/routes.js
@@ -31,6 +31,7 @@ const senderRoute = require('./api/sender');
const filesRoute = require('./api/file_upload');
const searchRoute = require('./api/search');
const dateNotesRoute = require('./api/date_notes');
+const linksRoute = require('./api/links');
const log = require('../services/log');
const express = require('express');
@@ -154,6 +155,8 @@ function register(app) {
apiRoute(GET, '/api/attributes/names', attributesRoute.getAttributeNames);
apiRoute(GET, '/api/attributes/values/:attributeName', attributesRoute.getValuesForAttribute);
+ apiRoute(GET, '/api/notes/:noteId/links', linksRoute.getNoteLinks);
+
apiRoute(GET, '/api/date-notes/date/:date', dateNotesRoute.getDateNote);
apiRoute(GET, '/api/date-notes/month/:month', dateNotesRoute.getMonthNote);
apiRoute(GET, '/api/date-notes/year/:year', dateNotesRoute.getYearNote);