mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 04:16:17 +01:00 
			
		
		
		
	refactoring of "date-notes" to "special-notes"
This commit is contained in:
		@@ -4,7 +4,7 @@ import ws from "./ws.js";
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/** @return {NoteShort} */
 | 
					/** @return {NoteShort} */
 | 
				
			||||||
async function getInboxNote() {
 | 
					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);
 | 
					    return await froca.getNote(note.noteId);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -16,7 +16,7 @@ async function getTodayNote() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/** @return {NoteShort} */
 | 
					/** @return {NoteShort} */
 | 
				
			||||||
async function getDateNote(date) {
 | 
					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();
 | 
					    await ws.waitForMaxKnownEntityChangeId();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -25,7 +25,7 @@ async function getDateNote(date) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/** @return {NoteShort} */
 | 
					/** @return {NoteShort} */
 | 
				
			||||||
async function getMonthNote(month) {
 | 
					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();
 | 
					    await ws.waitForMaxKnownEntityChangeId();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -34,7 +34,7 @@ async function getMonthNote(month) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/** @return {NoteShort} */
 | 
					/** @return {NoteShort} */
 | 
				
			||||||
async function getYearNote(year) {
 | 
					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();
 | 
					    await ws.waitForMaxKnownEntityChangeId();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -43,7 +43,7 @@ async function getYearNote(year) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/** @return {NoteShort} */
 | 
					/** @return {NoteShort} */
 | 
				
			||||||
async function createSqlConsole() {
 | 
					async function createSqlConsole() {
 | 
				
			||||||
    const note = await server.post('sql-console');
 | 
					    const note = await server.post('special-notes/sql-console');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    await ws.waitForMaxKnownEntityChangeId();
 | 
					    await ws.waitForMaxKnownEntityChangeId();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -52,7 +52,7 @@ async function createSqlConsole() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/** @return {NoteShort} */
 | 
					/** @return {NoteShort} */
 | 
				
			||||||
async function createSearchNote(opts = {}) {
 | 
					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();
 | 
					    await ws.waitForMaxKnownEntityChangeId();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -174,7 +174,7 @@ class Froca {
 | 
				
			|||||||
            return;
 | 
					            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)) {
 | 
					        if (!Array.isArray(searchResultNoteIds)) {
 | 
				
			||||||
            throw new Error(`Search note ${note.noteId} failed: ${searchResultNoteIds}`);
 | 
					            throw new Error(`Search note ${note.noteId} failed: ${searchResultNoteIds}`);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -145,7 +145,7 @@ export default class CalendarMenuWidget extends BasicWidget {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    async createMonth() {
 | 
					    async createMonth() {
 | 
				
			||||||
        const month = utils.formatDateISO(this.date).substr(0, 7);
 | 
					        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();
 | 
					        this.$month.empty();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -268,7 +268,7 @@ export default class SearchDefinitionWidget extends NoteContextAwareWidget {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        this.$saveToNoteButton = this.$widget.find('.save-to-note-button');
 | 
					        this.$saveToNoteButton = this.$widget.find('.save-to-note-button');
 | 
				
			||||||
        this.$saveToNoteButton.on('click', async () => {
 | 
					        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();
 | 
					            await ws.waitForMaxKnownEntityChangeId();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -40,7 +40,7 @@ export default class EditableCodeTypeWidget extends TypeWidget {
 | 
				
			|||||||
        this.$executeButton = this.$widget.find('.execute-button');
 | 
					        this.$executeButton = this.$widget.find('.execute-button');
 | 
				
			||||||
        this.$saveToNoteButton = this.$widget.find('.save-to-note-button');
 | 
					        this.$saveToNoteButton = this.$widget.find('.save-to-note-button');
 | 
				
			||||||
        this.$saveToNoteButton.on('click', async () => {
 | 
					        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();
 | 
					            await ws.waitForMaxKnownEntityChangeId();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -137,6 +137,22 @@ function getSpecialNoteRoot() {
 | 
				
			|||||||
    return specialNoteRoot;
 | 
					    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() {
 | 
					function getSqlConsoleRoot() {
 | 
				
			||||||
    let sqlConsoleRoot = becca.getNote('sqlconsole');
 | 
					    let sqlConsoleRoot = becca.getNote('sqlconsole');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -31,7 +31,7 @@ const scriptRoute = require('./api/script');
 | 
				
			|||||||
const senderRoute = require('./api/sender');
 | 
					const senderRoute = require('./api/sender');
 | 
				
			||||||
const filesRoute = require('./api/files');
 | 
					const filesRoute = require('./api/files');
 | 
				
			||||||
const searchRoute = require('./api/search');
 | 
					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 linkMapRoute = require('./api/link_map');
 | 
				
			||||||
const clipperRoute = require('./api/clipper');
 | 
					const clipperRoute = require('./api/clipper');
 | 
				
			||||||
const similarNotesRoute = require('./api/similar_notes');
 | 
					const similarNotesRoute = require('./api/similar_notes');
 | 
				
			||||||
@@ -222,15 +222,15 @@ function register(app) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    apiRoute(POST, '/api/notes/:noteId/link-map', linkMapRoute.getLinkMap);
 | 
					    apiRoute(POST, '/api/notes/:noteId/link-map', linkMapRoute.getLinkMap);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    apiRoute(GET, '/api/date-notes/inbox/:date', dateNotesRoute.getInboxNote);
 | 
					    apiRoute(GET, '/api/special-notes/inbox/:date', specialNotesRoute.getInboxNote);
 | 
				
			||||||
    apiRoute(GET, '/api/date-notes/date/:date', dateNotesRoute.getDateNote);
 | 
					    apiRoute(GET, '/api/special-notes/date/:date', specialNotesRoute.getDateNote);
 | 
				
			||||||
    apiRoute(GET, '/api/date-notes/month/:month', dateNotesRoute.getMonthNote);
 | 
					    apiRoute(GET, '/api/special-notes/month/:month', specialNotesRoute.getMonthNote);
 | 
				
			||||||
    apiRoute(GET, '/api/date-notes/year/:year', dateNotesRoute.getYearNote);
 | 
					    apiRoute(GET, '/api/special-notes/year/:year', specialNotesRoute.getYearNote);
 | 
				
			||||||
    apiRoute(GET, '/api/date-notes/notes-for-month/:month', dateNotesRoute.getDateNotesForMonth);
 | 
					    apiRoute(GET, '/api/special-notes/notes-for-month/:month', specialNotesRoute.getDateNotesForMonth);
 | 
				
			||||||
    apiRoute(POST, '/api/sql-console', dateNotesRoute.createSqlConsole);
 | 
					    apiRoute(POST, '/api/special-notes/sql-console', specialNotesRoute.createSqlConsole);
 | 
				
			||||||
    apiRoute(POST, '/api/save-sql-console', dateNotesRoute.saveSqlConsole);
 | 
					    apiRoute(POST, '/api/special-notes/save-sql-console', specialNotesRoute.saveSqlConsole);
 | 
				
			||||||
    apiRoute(POST, '/api/search-note', dateNotesRoute.createSearchNote);
 | 
					    apiRoute(POST, '/api/special-notes/search-note', specialNotesRoute.createSearchNote);
 | 
				
			||||||
    apiRoute(POST, '/api/save-search-note', dateNotesRoute.saveSearchNote);
 | 
					    apiRoute(POST, '/api/special-notes/save-search-note', specialNotesRoute.saveSearchNote);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    route(GET, '/api/images/:noteId/:filename', [auth.checkApiAuthOrElectron], imageRoute.returnImage);
 | 
					    route(GET, '/api/images/:noteId/:filename', [auth.checkApiAuthOrElectron], imageRoute.returnImage);
 | 
				
			||||||
    route(POST, '/api/images', [auth.checkApiAuthOrElectron, uploadMiddleware, csrfMiddleware], imageRoute.uploadImage, apiResultHandler);
 | 
					    route(POST, '/api/images', [auth.checkApiAuthOrElectron, uploadMiddleware, csrfMiddleware], imageRoute.uploadImage, apiResultHandler);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user