basic support for custom widgets

This commit is contained in:
zadam
2020-03-16 21:16:09 +01:00
parent 8ae78a9e23
commit 173030e02e
14 changed files with 99 additions and 22 deletions

View File

@@ -29,8 +29,8 @@ async function run(req) {
return { executionResult: result };
}
async function getStartupBundles() {
const notes = await attributeService.getNotesWithLabel("run", "frontendStartup");
async function getBundlesWithLabel(label, value) {
const notes = await attributeService.getNotesWithLabel(label, value);
const bundles = [];
@@ -45,6 +45,14 @@ async function getStartupBundles() {
return bundles;
}
async function getStartupBundles() {
return await getBundlesWithLabel("run", "frontendStartup");
}
async function getWidgetBundles() {
return await getBundlesWithLabel("widget");
}
async function getRelationBundles(req) {
const noteId = req.params.noteId;
const note = await repository.getNote(noteId);
@@ -84,6 +92,7 @@ module.exports = {
exec,
run,
getStartupBundles,
getWidgetBundles,
getRelationBundles,
getBundle
};

View File

@@ -225,6 +225,7 @@ function register(app) {
apiRoute(POST, '/api/script/exec', scriptRoute.exec);
apiRoute(POST, '/api/script/run/:noteId', scriptRoute.run);
apiRoute(GET, '/api/script/startup', scriptRoute.getStartupBundles);
apiRoute(GET, '/api/script/widgets', scriptRoute.getWidgetBundles);
apiRoute(GET, '/api/script/bundle/:noteId', scriptRoute.getBundle);
apiRoute(GET, '/api/script/relation/:noteId/:relationName', scriptRoute.getRelationBundles);