From 006c965b70b8863fbdd3dd7c1c869b21e255e026 Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Thu, 9 Jul 2020 14:47:54 +0100 Subject: [PATCH] Default app template - added screens --- .../server/src/api/controllers/application.js | 20 +++- .../appDirectoryTemplate/pages/main/page.json | 97 +++++++++++++------ .../d834fea2-1b3e-4320-ab34-f9009f5ecc59.json | 61 ++++++++++++ .../f684460e-1f79-42b4-8ffd-1f708bca93ed.json | 41 ++++++++ 4 files changed, 190 insertions(+), 29 deletions(-) create mode 100644 packages/server/src/utilities/appDirectoryTemplate/pages/main/screens/d834fea2-1b3e-4320-ab34-f9009f5ecc59.json create mode 100644 packages/server/src/utilities/appDirectoryTemplate/pages/main/screens/f684460e-1f79-42b4-8ffd-1f708bca93ed.json diff --git a/packages/server/src/api/controllers/application.js b/packages/server/src/api/controllers/application.js index e1b850a31f..a737572c62 100644 --- a/packages/server/src/api/controllers/application.js +++ b/packages/server/src/api/controllers/application.js @@ -147,7 +147,10 @@ const createEmptyAppPackage = async (ctx, app) => { app ) - await buildPage(ctx.config, app._id, "main", { page: mainJson }) + await buildPage(ctx.config, app._id, "main", { + page: mainJson, + screens: await loadScreens(newAppFolder, "main"), + }) const unauthenticatedJson = await updateJsonFile( join(appsFolder, app._id, "pages", "unauthenticated", "page.json"), @@ -156,11 +159,26 @@ const createEmptyAppPackage = async (ctx, app) => { await buildPage(ctx.config, app._id, "unauthenticated", { page: unauthenticatedJson, + screens: await loadScreens(newAppFolder, "unauthenticated"), }) return newAppFolder } +const loadScreens = async (appFolder, page) => { + const screensFolder = join(appFolder, "pages", page, "screens") + + const screenFiles = (await fs.readdir(screensFolder)).filter(s => + s.endsWith(".json") + ) + + let screens = [] + for (let file of screenFiles) { + screens.push(await fs.readJSON(join(screensFolder, file))) + } + return screens +} + const lookupClientId = async appId => { const masterDb = new CouchDB("client_app_lookup") const { clientId } = await masterDb.get(appId) diff --git a/packages/server/src/utilities/appDirectoryTemplate/pages/main/page.json b/packages/server/src/utilities/appDirectoryTemplate/pages/main/page.json index 032848e68e..7f301e8e5f 100644 --- a/packages/server/src/utilities/appDirectoryTemplate/pages/main/page.json +++ b/packages/server/src/utilities/appDirectoryTemplate/pages/main/page.json @@ -3,47 +3,84 @@ "favicon": "./_shared/favicon.png", "stylesheets": [], "componentLibraries": ["@budibase/standard-components", "@budibase/materialdesign-components"], - "props" : { - "_id": "private-master-root", + "props": { + "_id": "private-master-root", "_component": "@budibase/standard-components/container", "_children": [ { - "_id": "c32dd256-a61c-4c41-876e-95e91c5e3a43", - "_component": "@budibase/standard-components/container", + "_id": "49e0e519-9e5e-4127-885a-ee6a0a49e2c1", + "_component": "@budibase/standard-components/Navigation", "_styles": { - "normal": { - "background": "#e8e8ef", - "padding": "8px", - "color": "#393C44", - "display": "N/A", - "flex-direction": "column" - }, + "normal": {}, "hover": {}, "active": {}, "selected": {} }, "_code": "", - "className": "", - "onLoad": [], - "type": "div", - "_instanceId": "inst_1808f0d_e1277174d255421784ef2467d470abc8", - "_instanceName": "Container", + "logoUrl": "http://acmelogos.com/images/logo-8.svg", + "title": "", + "backgroundColor": "", + "color": "", + "borderWidth": "", + "borderColor": "", + "borderStyle": "", + "_instanceId": "inst_cf8ace4_69efc0d72e6f443db2d4c902c14d9394", + "_instanceName": "Navigation", "_children": [ { - "_id": "fbd9520f-6b34-4e3e-828d-0197144568a1", - "_component": "@budibase/standard-components/heading", + "_id": "48b35328-4c91-4343-a6a3-1a1fd77b3386", + "_component": "@budibase/standard-components/link", "_styles": { - "normal": {}, + "normal": { + "font-family": "Inter", + "font-weight": "400", + "color": "#000000", + "text-decoration-line": "none", + "font-size": "16px" + }, "hover": {}, "active": {}, "selected": {} }, "_code": "", - "className": "", - "text": "{{ name }}", - "type": "h1", - "_instanceId": "inst_1808f0d_e1277174d255421784ef2467d470abc8", - "_instanceName": "Heading", + "url": "/", + "openInNewTab": false, + "text": "Home", + "color": "", + "hoverColor": "", + "underline": false, + "fontSize": "", + "fontFamily": "initial", + "_instanceId": "inst_cf8ace4_69efc0d72e6f443db2d4c902c14d9394", + "_instanceName": "Home Link", + "_children": [] + }, + { + "_id": "d3325634-0945-4387-8bb3-d9d9be186c1c", + "_component": "@budibase/standard-components/link", + "_styles": { + "normal": { + "font-family": "Inter", + "font-weight": "400", + "color": "#000000", + "text-decoration-line": "none", + "font-size": "16px" + }, + "hover": {}, + "active": {}, + "selected": {} + }, + "_code": "", + "url": "/screen1", + "openInNewTab": false, + "text": "Screen 1", + "color": "", + "hoverColor": "", + "underline": false, + "fontSize": "", + "fontFamily": "initial", + "_instanceId": "inst_cf8ace4_69efc0d72e6f443db2d4c902c14d9394", + "_instanceName": "Screen 1 Link", "_children": [] } ] @@ -53,9 +90,10 @@ "_component": "##builtin/screenslot", "_styles": { "normal": { - "padding": "8px", + "padding": "0px", "align-items": "flex-start", - "height": "100vh" + "height": "100vh", + "background-image": "None" }, "hover": {}, "active": {}, @@ -74,14 +112,17 @@ "flex-direction": "column", "align-items": "stretch", "justify-content": "flex-start", - "height": "100vh" + "height": "", + "max-width": "", + "margin-right": "auto", + "margin-left": "auto" }, "selected": {} }, "_code": "", "className": "", "onLoad": [] - }, + }, "_css": "", "uiFunctions": "" } diff --git a/packages/server/src/utilities/appDirectoryTemplate/pages/main/screens/d834fea2-1b3e-4320-ab34-f9009f5ecc59.json b/packages/server/src/utilities/appDirectoryTemplate/pages/main/screens/d834fea2-1b3e-4320-ab34-f9009f5ecc59.json new file mode 100644 index 0000000000..35c4656a3d --- /dev/null +++ b/packages/server/src/utilities/appDirectoryTemplate/pages/main/screens/d834fea2-1b3e-4320-ab34-f9009f5ecc59.json @@ -0,0 +1,61 @@ +{ + "description": "", + "url": "", + "props": { + "_id": "d834fea2-1b3e-4320-ab34-f9009f5ecc59", + "_component": "@budibase/standard-components/container", + "_styles": { + "normal": {}, + "hover": {}, + "active": {}, + "selected": {} + }, + "_code": "", + "className": "", + "onLoad": [], + "type": "div", + "_children": [ + { + "_id": "ef60083f-4a02-4df3-80f3-a0d3d16847e7", + "_component": "@budibase/standard-components/heading", + "_styles": { + "normal": {}, + "hover": {}, + "active": {}, + "selected": {} + }, + "_code": "", + "className": "", + "text": "Home", + "type": "h1", + "_instanceId": "inst_cf8ace4_69efc0d72e6f443db2d4c902c14d9394", + "_instanceName": "Heading", + "_children": [] + }, + { + "_id": "6c256e06-784c-4ac0-a644-ed2f9b91d459", + "_component": "@budibase/standard-components/image", + "_styles": { + "normal": { + "width": "100%" + }, + "hover": {}, + "active": {}, + "selected": {} + }, + "_code": "", + "url": "https://source.unsplash.com/Vun-71Vy2hc", + "className": "", + "description": "", + "height": "", + "width": "", + "_instanceId": "inst_cf8ace4_69efc0d72e6f443db2d4c902c14d9394", + "_instanceName": "Image", + "_children": [] + } + ], + "_instanceName": "Home" + }, + "route": "/*", + "name": "d834fea2-1b3e-4320-ab34-f9009f5ecc59" +} diff --git a/packages/server/src/utilities/appDirectoryTemplate/pages/main/screens/f684460e-1f79-42b4-8ffd-1f708bca93ed.json b/packages/server/src/utilities/appDirectoryTemplate/pages/main/screens/f684460e-1f79-42b4-8ffd-1f708bca93ed.json new file mode 100644 index 0000000000..ae054f8245 --- /dev/null +++ b/packages/server/src/utilities/appDirectoryTemplate/pages/main/screens/f684460e-1f79-42b4-8ffd-1f708bca93ed.json @@ -0,0 +1,41 @@ +{ + "description": "", + "url": "", + "_css": "", + "props": { + "_id": "f684460e-1f79-42b4-8ffd-1f708bca93ed", + "_component": "@budibase/standard-components/container", + "_styles": { + "normal": {}, + "hover": {}, + "active": {}, + "selected": {} + }, + "_code": "", + "className": "", + "onLoad": [], + "type": "div", + "_children": [ + { + "_id": "7d1d6b43-b444-46a5-a75c-267fd6b5baf6", + "_component": "@budibase/standard-components/heading", + "_styles": { + "normal": {}, + "hover": {}, + "active": {}, + "selected": {} + }, + "_code": "", + "className": "", + "text": "Screen1", + "type": "h1", + "_instanceId": "inst_cf8ace4_69efc0d72e6f443db2d4c902c14d9394", + "_instanceName": "Heading", + "_children": [] + } + ], + "_instanceName": "Screen 1" + }, + "route": "/screen1", + "name": "f684460e-1f79-42b4-8ffd-1f708bca93ed" +}