Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
Add week notes to frontend_script_api (#2253)
Sathyam M Vellal3b551e3e4dd3
diff --git a/src/public/app/services/date_notes.js b/src/public/app/services/date_notes.jsindex dc1a4b13c1..e8ff61cfbc 100644--- a/src/public/app/services/date_notes.js+++ b/src/public/app/services/date_notes.js@@ -23,6 +23,15 @@ async function getDateNote(date) {return await froca.getNote(note.noteId);}+/** @return {NoteShort} */+async function getWeekNote(date) {+ const note = await server.get('special-notes/week/' + date, "date-note");++ await ws.waitForMaxKnownEntityChangeId();++ return await froca.getNote(note.noteId);+}+/** @return {NoteShort} */async function getMonthNote(month) {const note = await server.get('special-notes/month/' + month, "date-note");@@ -63,6 +72,7 @@ export default {getInboxNote,getTodayNote,getDateNote,+ getWeekNote,getMonthNote,getYearNote,createSqlConsole,diff --git a/src/public/app/services/frontend_script_api.js b/src/public/app/services/frontend_script_api.jsindex 249e358297..a4d5b04af9 100644--- a/src/public/app/services/frontend_script_api.js+++ b/src/public/app/services/frontend_script_api.js@@ -396,6 +396,15 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain*/this.getDateNote = dateNotesService.getDateNote;+ /**+ * Returns date-note for the first date of the week of the given date. If it doesn't exist, it is automatically created.+ *+ * @method+ * @param {string} date - e.g. "2019-04-29"+ * @return {Promise<NoteShort>}+ */+ this.getWeekNote = dateNotesService.getWeekNote;+/*** Returns month-note. If it doesn't exist, it is automatically created.*diff --git a/src/routes/api/special_notes.js b/src/routes/api/special_notes.jsindex 5e62f07277..1814cf8494 100644--- a/src/routes/api/special_notes.js+++ b/src/routes/api/special_notes.js@@ -14,6 +14,10 @@ function getDateNote(req) {return dateNoteService.getDateNote(req.params.date);}+function getWeekNote(req) {+ return dateNoteService.getWeekNote(req.params.date);+}+function getMonthNote(req) {return dateNoteService.getMonthNote(req.params.month);}@@ -65,6 +69,7 @@ function getHoistedNote() {module.exports = {getInboxNote,getDateNote,+ getWeekNote,getMonthNote,getYearNote,getDateNotesForMonth,diff --git a/src/routes/routes.js b/src/routes/routes.jsindex 1d71ca8f62..5785e0c606 100644--- a/src/routes/routes.js+++ b/src/routes/routes.js@@ -262,6 +262,7 @@ function register(app) {apiRoute(GET, '/api/special-notes/inbox/:date', specialNotesRoute.getInboxNote);apiRoute(GET, '/api/special-notes/date/:date', specialNotesRoute.getDateNote);+ apiRoute(GET, '/api/special-notes/week/:date', specialNotesRoute.getWeekNote);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);