Notes/src/public/app/services/date_notes.js

71 lines
1.7 KiB
JavaScript
Raw Normal View History

2021-04-16 23:01:56 +02:00
import froca from "./froca.js";
import server from "./server.js";
2020-12-05 23:00:28 +01:00
import ws from "./ws.js";
2020-11-27 22:21:13 +01:00
/** @return {NoteShort} */
async function getInboxNote() {
const note = await server.get('special-notes/inbox/' + dayjs().format("YYYY-MM-DD"), "date-note");
2020-11-27 22:21:13 +01:00
2021-04-16 22:57:37 +02:00
return await froca.getNote(note.noteId);
2020-11-27 22:21:13 +01:00
}
/** @return {NoteShort} */
async function getTodayNote() {
return await getDateNote(dayjs().format("YYYY-MM-DD"));
}
/** @return {NoteShort} */
async function getDateNote(date) {
const note = await server.get('special-notes/date/' + date, "date-note");
await ws.waitForMaxKnownEntityChangeId();
2021-04-16 22:57:37 +02:00
return await froca.getNote(note.noteId);
}
/** @return {NoteShort} */
async function getMonthNote(month) {
const note = await server.get('special-notes/month/' + month, "date-note");
await ws.waitForMaxKnownEntityChangeId();
2021-04-16 22:57:37 +02:00
return await froca.getNote(note.noteId);
}
/** @return {NoteShort} */
async function getYearNote(year) {
const note = await server.get('special-notes/year/' + year, "date-note");
await ws.waitForMaxKnownEntityChangeId();
2021-04-16 22:57:37 +02:00
return await froca.getNote(note.noteId);
}
/** @return {NoteShort} */
async function createSqlConsole() {
const note = await server.post('special-notes/sql-console');
await ws.waitForMaxKnownEntityChangeId();
2021-04-16 22:57:37 +02:00
return await froca.getNote(note.noteId);
}
/** @return {NoteShort} */
async function createSearchNote(opts = {}) {
const note = await server.post('special-notes/search-note', opts);
2020-12-05 23:00:28 +01:00
await ws.waitForMaxKnownEntityChangeId();
2021-04-16 22:57:37 +02:00
return await froca.getNote(note.noteId);
}
export default {
2020-11-27 22:21:13 +01:00
getInboxNote,
getTodayNote,
getDateNote,
getMonthNote,
getYearNote,
createSqlConsole,
createSearchNote
}