refactoring of "date-notes" to "special-notes"

This commit is contained in:
zadam 2021-09-16 21:59:34 +02:00
parent 2b017a956e
commit 2d82da32d4
7 changed files with 36 additions and 20 deletions

View file

@ -4,7 +4,7 @@ import ws from "./ws.js";
/** @return {NoteShort} */
async function getInboxNote() {
const note = await server.get('date-notes/inbox/' + dayjs().format("YYYY-MM-DD"), "date-note");
const note = await server.get('special-notes/inbox/' + dayjs().format("YYYY-MM-DD"), "date-note");
return await froca.getNote(note.noteId);
}
@ -16,7 +16,7 @@ async function getTodayNote() {
/** @return {NoteShort} */
async function getDateNote(date) {
const note = await server.get('date-notes/date/' + date, "date-note");
const note = await server.get('special-notes/date/' + date, "date-note");
await ws.waitForMaxKnownEntityChangeId();
@ -25,7 +25,7 @@ async function getDateNote(date) {
/** @return {NoteShort} */
async function getMonthNote(month) {
const note = await server.get('date-notes/month/' + month, "date-note");
const note = await server.get('special-notes/month/' + month, "date-note");
await ws.waitForMaxKnownEntityChangeId();
@ -34,7 +34,7 @@ async function getMonthNote(month) {
/** @return {NoteShort} */
async function getYearNote(year) {
const note = await server.get('date-notes/year/' + year, "date-note");
const note = await server.get('special-notes/year/' + year, "date-note");
await ws.waitForMaxKnownEntityChangeId();
@ -43,7 +43,7 @@ async function getYearNote(year) {
/** @return {NoteShort} */
async function createSqlConsole() {
const note = await server.post('sql-console');
const note = await server.post('special-notes/sql-console');
await ws.waitForMaxKnownEntityChangeId();
@ -52,7 +52,7 @@ async function createSqlConsole() {
/** @return {NoteShort} */
async function createSearchNote(opts = {}) {
const note = await server.post('search-note', opts);
const note = await server.post('special-notes/search-note', opts);
await ws.waitForMaxKnownEntityChangeId();

View file

@ -174,7 +174,7 @@ class Froca {
return;
}
const searchResultNoteIds = await server.get('search-note/' + note.noteId);
const searchResultNoteIds = await server.get('special-notes/search-note/' + note.noteId);
if (!Array.isArray(searchResultNoteIds)) {
throw new Error(`Search note ${note.noteId} failed: ${searchResultNoteIds}`);

View file

@ -145,7 +145,7 @@ export default class CalendarMenuWidget extends BasicWidget {
async createMonth() {
const month = utils.formatDateISO(this.date).substr(0, 7);
const dateNotesForMonth = await server.get('date-notes/notes-for-month/' + month);
const dateNotesForMonth = await server.get('special-notes/notes-for-month/' + month);
this.$month.empty();

View file

@ -268,7 +268,7 @@ export default class SearchDefinitionWidget extends NoteContextAwareWidget {
this.$saveToNoteButton = this.$widget.find('.save-to-note-button');
this.$saveToNoteButton.on('click', async () => {
const {notePath} = await server.post("save-search-note", {searchNoteId: this.noteId});
const {notePath} = await server.post("special-notes/save-search-note", {searchNoteId: this.noteId});
await ws.waitForMaxKnownEntityChangeId();

View file

@ -40,7 +40,7 @@ export default class EditableCodeTypeWidget extends TypeWidget {
this.$executeButton = this.$widget.find('.execute-button');
this.$saveToNoteButton = this.$widget.find('.save-to-note-button');
this.$saveToNoteButton.on('click', async () => {
const {notePath} = await server.post("save-sql-console", {sqlConsoleNoteId: this.noteId});
const {notePath} = await server.post("special-notes/save-sql-console", {sqlConsoleNoteId: this.noteId});
await ws.waitForMaxKnownEntityChangeId();

View file

@ -137,6 +137,22 @@ function getSpecialNoteRoot() {
return specialNoteRoot;
}
function getGlobalLinkMapNote() {
let globalLinkMapNote = becca.getNote('global-link-map');
if (!globalLinkMapNote) {
globalLinkMapNote = noteService.createNewNote({
noteId: 'global-link-map',
title: 'global-link-map',
type: 'global-link-map',
content: '',
parentNoteId: getSpecialNoteRoot().noteId
}).note;
}
return globalLinkMapNote;
}
function getSqlConsoleRoot() {
let sqlConsoleRoot = becca.getNote('sqlconsole');

View file

@ -31,7 +31,7 @@ const scriptRoute = require('./api/script');
const senderRoute = require('./api/sender');
const filesRoute = require('./api/files');
const searchRoute = require('./api/search');
const dateNotesRoute = require('./api/date_notes');
const specialNotesRoute = require('./api/special_notes.js');
const linkMapRoute = require('./api/link_map');
const clipperRoute = require('./api/clipper');
const similarNotesRoute = require('./api/similar_notes');
@ -222,15 +222,15 @@ function register(app) {
apiRoute(POST, '/api/notes/:noteId/link-map', linkMapRoute.getLinkMap);
apiRoute(GET, '/api/date-notes/inbox/:date', dateNotesRoute.getInboxNote);
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);
apiRoute(GET, '/api/date-notes/notes-for-month/:month', dateNotesRoute.getDateNotesForMonth);
apiRoute(POST, '/api/sql-console', dateNotesRoute.createSqlConsole);
apiRoute(POST, '/api/save-sql-console', dateNotesRoute.saveSqlConsole);
apiRoute(POST, '/api/search-note', dateNotesRoute.createSearchNote);
apiRoute(POST, '/api/save-search-note', dateNotesRoute.saveSearchNote);
apiRoute(GET, '/api/special-notes/inbox/:date', specialNotesRoute.getInboxNote);
apiRoute(GET, '/api/special-notes/date/:date', specialNotesRoute.getDateNote);
apiRoute(GET, '/api/special-notes/month/:month', specialNotesRoute.getMonthNote);
apiRoute(GET, '/api/special-notes/year/:year', specialNotesRoute.getYearNote);
apiRoute(GET, '/api/special-notes/notes-for-month/:month', specialNotesRoute.getDateNotesForMonth);
apiRoute(POST, '/api/special-notes/sql-console', specialNotesRoute.createSqlConsole);
apiRoute(POST, '/api/special-notes/save-sql-console', specialNotesRoute.saveSqlConsole);
apiRoute(POST, '/api/special-notes/search-note', specialNotesRoute.createSearchNote);
apiRoute(POST, '/api/special-notes/save-search-note', specialNotesRoute.saveSearchNote);
route(GET, '/api/images/:noteId/:filename', [auth.checkApiAuthOrElectron], imageRoute.returnImage);
route(POST, '/api/images', [auth.checkApiAuthOrElectron, uploadMiddleware, csrfMiddleware], imageRoute.uploadImage, apiResultHandler);