From 2f039e195cef06ebff6d33ecefaf0c4c75ecfcfc Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 17 Feb 2022 00:30:12 +0100 Subject: [PATCH] fix: add platform and modal --- src/lib/components/modal.svelte | 9 +++- .../console/[project]/_createPlatform.svelte | 45 +++++++++++++++++++ src/routes/console/[project]/index.svelte | 34 ++++++++++++-- svelte.config.js | 2 +- 4 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 src/routes/console/[project]/_createPlatform.svelte diff --git a/src/lib/components/modal.svelte b/src/lib/components/modal.svelte index a3a239f0e..9836dfbce 100644 --- a/src/lib/components/modal.svelte +++ b/src/lib/components/modal.svelte @@ -7,12 +7,19 @@ show = false; } }; + + const handleBLur = (event: MouseEvent) => { + const target: Partial = event.target; + if (target.tagName === 'DIALOG') { + show = false; + } + }; {#if show} - +
(show = false)} aria-label="Close" title="Close" class="close" /> diff --git a/src/routes/console/[project]/_createPlatform.svelte b/src/routes/console/[project]/_createPlatform.svelte new file mode 100644 index 000000000..4bab6e9e7 --- /dev/null +++ b/src/routes/console/[project]/_createPlatform.svelte @@ -0,0 +1,45 @@ + + +
+ + Add Platform + + +
+ + +
+
+
diff --git a/src/routes/console/[project]/index.svelte b/src/routes/console/[project]/index.svelte index f500407fb..c3179d66c 100644 --- a/src/routes/console/[project]/index.svelte +++ b/src/routes/console/[project]/index.svelte @@ -2,14 +2,33 @@ import { page } from '$app/stores'; import { Button } from '$lib/elements/forms'; import { sdkForConsole } from '$lib/stores/sdk'; - import type { Models } from 'src/sdk'; import { project } from './store'; + import type { Models } from 'src/sdk'; + import CreatePlatform from './_createPlatform.svelte'; + import { addNotification } from '$lib/stores/notifications'; let range: '24h' | '30d' | '90d' = '30d'; let requestUsage = sdkForConsole.projects.getUsage($page.params.project, range); + let addPlatform = false; const getLast = (list: Models.MetricList[]) => list[list.length - 1]; - // const getTotal = (list: Models.MetricList[]) => list.reduce((prev, curr) => curr.value + prev, 0); + const deletePlatform = async (id: string) => { + if (confirm('You sure you wanna delete this?')) { + try { + await sdkForConsole.projects.deletePlatform($project.$id, id); + await project.load($project.$id); + addNotification({ + message: 'Platform was deleted.', + type: 'success' + }); + } catch (error) { + addNotification({ + message: error.message, + type: 'error' + }); + } + } + };
@@ -57,11 +76,20 @@
- + +
+ + {:else} +
+
+

No Platforms Added to Your Project

+

Add your first platform and build your new application.

{/each}
+ + {/if}