diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index 61a0824363..ed89d4316d 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -62,13 +62,13 @@ {/each} {:else if value.customType === 'password'} - + {:else if value.customType === 'email'} + {bindings} /> {:else if value.customType === 'table'} {:else if value.customType === 'row'} @@ -82,7 +82,7 @@ type={value.customType} extraThin bind:value={block.inputs[key]} - {bindings} /> + {bindings} /> {/if} {/each} diff --git a/packages/builder/src/components/backend/DataTable/popovers/ExportPopover.svelte b/packages/builder/src/components/backend/DataTable/popovers/ExportPopover.svelte index 3e7642982a..af561668ec 100644 --- a/packages/builder/src/components/backend/DataTable/popovers/ExportPopover.svelte +++ b/packages/builder/src/components/backend/DataTable/popovers/ExportPopover.svelte @@ -20,13 +20,12 @@ let exportFormat = FORMATS[0].key async function exportView() { - const response = await api.post( - `/api/views/export?format=${exportFormat}`, - view + download( + `/api/views/export?view=${encodeURIComponent( + view.name + )}&format=${exportFormat}` ) - const downloadInfo = await response.json() onClosed() - window.location = downloadInfo.url } diff --git a/packages/builder/src/components/start/AppCard.svelte b/packages/builder/src/components/start/AppCard.svelte index aaee055c5e..f4dac1dc6c 100644 --- a/packages/builder/src/components/start/AppCard.svelte +++ b/packages/builder/src/components/start/AppCard.svelte @@ -30,13 +30,13 @@ diff --git a/packages/server/src/api/controllers/view/index.js b/packages/server/src/api/controllers/view/index.js index c4e8c1e372..05dc299754 100644 --- a/packages/server/src/api/controllers/view/index.js +++ b/packages/server/src/api/controllers/view/index.js @@ -83,23 +83,42 @@ const controller = { ctx.message = `View ${ctx.params.viewName} saved successfully.` }, exportView: async ctx => { - const view = ctx.query.view + const db = new CouchDB(ctx.user.appId) + const designDoc = await db.get("_design/database") + + const viewName = decodeURI(ctx.query.view) + + const view = designDoc.views[viewName] const format = ctx.query.format - // Fetch view rows - ctx.params.viewName = view.name - ctx.query.group = view.groupBy - if (view.field) { - ctx.query.stats = true - ctx.query.field = view.field + if (view) { + ctx.params.viewName = viewName + // Fetch view rows + ctx.query = { + group: view.meta.groupBy, + calculation: view.meta.calculation, + stats: !!view.meta.field, + field: view.meta.field, + } + } else { + // table all_ view + ctx.params.viewName = viewName } + await fetchView(ctx) + let schema = view && view.meta && view.meta.schema + if (!schema) { + const tableId = ctx.params.tableId || view.meta.tableId + const table = await db.get(tableId) + schema = table.schema + } + // Export part - let headers = Object.keys(view.schema) + let headers = Object.keys(schema) const exporter = exporters[format] const exportedFile = exporter(headers, ctx.body) - const filename = `${view.name}.${format}` + const filename = `${viewName}.${format}` fs.writeFileSync(join(os.tmpdir(), filename), exportedFile) ctx.attachment(filename) diff --git a/packages/server/src/api/routes/view.js b/packages/server/src/api/routes/view.js index 4a32b4c592..0ae12f687c 100644 --- a/packages/server/src/api/routes/view.js +++ b/packages/server/src/api/routes/view.js @@ -12,6 +12,7 @@ const usage = require("../../middleware/usageQuota") const router = Router() router + .get("/api/views/export", authorized(BUILDER), viewController.exportView) .get( "/api/views/:viewName", authorized(PermissionTypes.VIEW, PermissionLevels.READ), @@ -25,6 +26,5 @@ router viewController.destroy ) .post("/api/views", authorized(BUILDER), usage, viewController.save) - .post("/api/views/export", authorized(BUILDER), viewController.exportView) module.exports = router diff --git a/packages/standard-components/src/Navigation.svelte b/packages/standard-components/src/Navigation.svelte index 4a4ec8dccc..192beaf74e 100644 --- a/packages/standard-components/src/Navigation.svelte +++ b/packages/standard-components/src/Navigation.svelte @@ -60,13 +60,18 @@ .nav__menu { display: flex; margin-top: 40px; - gap: 16px; flex-direction: row; justify-content: flex-start; align-items: center; } - .nav__menu > a { + + .nav__menu > * { + margin-right: 16px; + } + + :global(.nav__menu > a) { font-size: 1.5em; text-decoration: none; + margin-right: 16px; } diff --git a/packages/standard-components/src/Search.svelte b/packages/standard-components/src/Search.svelte new file mode 100644 index 0000000000..2896861289 --- /dev/null +++ b/packages/standard-components/src/Search.svelte @@ -0,0 +1,103 @@ + + +
+
+ {#each searchableFields as field} +
+ + {#if schema[field].type === 'options'} + + {:else if schema[field].type === 'boolean'} + + {:else if schema[field].type === 'number'} + + {:else if schema[field].type === 'string'} + + {/if} +
+ {/each} + + +
+ {#if rows.length > 0} + {#if $component.children === 0 && $builderStore.inBuilder} +

Add some components too

+ {:else} + {#each rows as row} + + + + {/each} + {/if} + {:else if loaded && $builderStore.inBuilder} +

Feed me some data

+ {/if} +
+ +