From 35b9ab353ea4677326032400231bc4a9e530829a Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 7 May 2021 13:13:51 +0100 Subject: [PATCH] Add table app list view --- .../src/components/start/AppCard.svelte | 29 ++--- .../src/components/start/AppGridView.svelte | 6 +- .../src/components/start/AppTableView.svelte | 100 ++++++++++++++++-- .../components/start/CreateAppModal.svelte | 3 +- .../pages/builder/portal/apps/index.svelte | 24 ++++- 5 files changed, 123 insertions(+), 39 deletions(-) diff --git a/packages/builder/src/components/start/AppCard.svelte b/packages/builder/src/components/start/AppCard.svelte index 9a14efd81b..de01c125d6 100644 --- a/packages/builder/src/components/start/AppCard.svelte +++ b/packages/builder/src/components/start/AppCard.svelte @@ -7,43 +7,28 @@ ActionMenu, MenuItem, Link, - notifications, } from "@budibase/bbui" - import download from "downloadjs" import { gradient } from "actions" + import { url } from "@roxi/routify" - export let name - export let _id + export let app + export let exportApp let appExportLoading = false - - async function exportApp() { - appExportLoading = true - try { - download( - `/api/backups/export?appId=${_id}&appname=${encodeURIComponent(name)}` - ) - notifications.success("App export complete") - } catch (err) { - console.error(err) - notifications.error("App export failed") - } finally { - appExportLoading = false - } - }
- + - {name} + {app.name} - Export + exportApp(app)} icon="Download">Export
diff --git a/packages/builder/src/components/start/AppGridView.svelte b/packages/builder/src/components/start/AppGridView.svelte index 947477b03e..c6267e4369 100644 --- a/packages/builder/src/components/start/AppGridView.svelte +++ b/packages/builder/src/components/start/AppGridView.svelte @@ -1,16 +1,16 @@ {#if $apps.length}
{#each $apps as app} - + {/each}
-{:else} -
No apps found.
{/if} diff --git a/packages/builder/src/components/start/CreateAppModal.svelte b/packages/builder/src/components/start/CreateAppModal.svelte index fcfea2d8cf..32774ff33c 100644 --- a/packages/builder/src/components/start/CreateAppModal.svelte +++ b/packages/builder/src/components/start/CreateAppModal.svelte @@ -13,6 +13,7 @@ import { onMount } from "svelte" import Logo from "/assets/bb-logo.svg" import { capitalise } from "../../helpers" + import { goto } from "@roxi/routify" export let template @@ -111,7 +112,7 @@ } const userResp = await api.post(`/api/users/metadata/self`, user) await userResp.json() - window.location = `/builder/app/${appJson._id}` + $goto(`/builder/app/${appJson._id}`) } catch (error) { console.error(error) notifications.error(error) diff --git a/packages/builder/src/pages/builder/portal/apps/index.svelte b/packages/builder/src/pages/builder/portal/apps/index.svelte index 09b179bdf1..b95e8bf5d2 100644 --- a/packages/builder/src/pages/builder/portal/apps/index.svelte +++ b/packages/builder/src/pages/builder/portal/apps/index.svelte @@ -9,6 +9,7 @@ Select, Modal, Page, + notifications, } from "@budibase/bbui" import AppGridView from "components/start/AppGridView.svelte" import AppTableView from "components/start/AppTableView.svelte" @@ -17,12 +18,13 @@ import analytics from "analytics" import { onMount } from "svelte" import { apps } from "stores/portal" + import download from "downloadjs" let layout = "grid" let modal let template - async function checkKeys() { + const checkKeys = async () => { const response = await api.get(`/api/keys/`) const keys = await response.json() if (keys.userId) { @@ -30,11 +32,25 @@ } } - function initiateAppImport() { + const initiateAppImport = () => { template = { fromFile: true } modal.show() } + const exportApp = app => { + try { + download( + `/api/backups/export?appId=${app._id}&appname=${encodeURIComponent( + app.name + )}` + ) + notifications.success("App export complete") + } catch (err) { + console.error(err) + notifications.error("App export failed") + } + } + onMount(() => { checkKeys() apps.load() @@ -70,9 +86,9 @@
{#if layout === "grid"} - + {:else} - + {/if}