mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	link router/loading
This commit is contained in:
		| @@ -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(); | ||||
| } | ||||
|  | ||||
|   | ||||
							
								
								
									
										17
									
								
								src/routes/api/links.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								src/routes/api/links.js
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||
| }; | ||||
| @@ -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); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user