link router/loading

This commit is contained in:
zadam 2019-06-02 17:12:18 +02:00
parent b5143c152b
commit 7eed076674
3 changed files with 29 additions and 0 deletions

View file

@ -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
View 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
};

View file

@ -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);