From 2e3c815e53a4b6dff8f422c0a0c62d84c4f5dad4 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 7 Dec 2022 15:27:26 +0100 Subject: [PATCH] fix: delete resource on dashboard --- .../src/routes/applications/[id]/index.svelte | 16 ++--- apps/ui/src/routes/index.svelte | 66 ++++++++++++++++++- apps/ui/tailwind.config.cjs | 1 + 3 files changed, 74 insertions(+), 9 deletions(-) diff --git a/apps/ui/src/routes/applications/[id]/index.svelte b/apps/ui/src/routes/applications/[id]/index.svelte index 9c1c5b86e..0cd8e145f 100644 --- a/apps/ui/src/routes/applications/[id]/index.svelte +++ b/apps/ui/src/routes/applications/[id]/index.svelte @@ -495,9 +495,9 @@ {#if !isSimpleDockerfile}
- {#if isDisabled || application.settings.isPublicRepository} + {#if isDisabled || application.settings?.isPublicRepository} @@ -526,7 +526,7 @@ /> Commits
- {#if isDisabled || application.settings.isPublicRepository} + {#if isDisabled || application.settings?.isPublicRepository} {:else} @@ -633,7 +633,7 @@
- Connected to {application.connectedDatabase.databaseId} + Connected to {application.connectedDatabase?.databaseId}
{/if} {/if} @@ -1230,7 +1230,7 @@ readonly={!$appSession.isAdmin} name="port" id="port" - required={!!dockerComposeConfiguration[service.name].fqdn} + required={!!dockerComposeConfiguration[service.name]?.fqdn} bind:value={dockerComposeConfiguration[service.name].port} />
diff --git a/apps/ui/src/routes/index.svelte b/apps/ui/src/routes/index.svelte index 2c49b7639..a26878720 100644 --- a/apps/ui/src/routes/index.svelte +++ b/apps/ui/src/routes/index.svelte @@ -31,7 +31,7 @@ export let destinations: any; let filtered: any = setInitials(); - import { get, post } from '$lib/api'; + import { del, get, post } from '$lib/api'; import { t } from '$lib/translations'; import { asyncSleep, errorNotification, getRndInteger } from '$lib/common'; import { appSession, search } from '$lib/store'; @@ -42,6 +42,7 @@ import { dev } from '$app/env'; import NewResource from './_NewResource.svelte'; import { onMount } from 'svelte'; + import DeleteIcon from '$lib/components/DeleteIcon.svelte'; let numberOfGetStatus = 0; let status: any = {}; @@ -432,6 +433,39 @@ return errorNotification(error); } } + async function deleteApplication(id: string) { + try { + const sure = confirm('Are you sure? This will delete this application!'); + if (sure) { + await del(`/applications/${id}`, { force: true }); + return window.location.reload(); + } + } catch (error) { + return errorNotification(error); + } + } + async function deleteService(id: string) { + try { + const sure = confirm('Are you sure? This will delete this service!'); + if (sure) { + await del(`/services/${id}`, {}); + return window.location.reload(); + } + } catch (error) { + return errorNotification(error); + } + } + async function deleteDatabase(id: string) { + try { + const sure = confirm('Are you sure? This will delete this database!'); + if (sure) { + await del(`/databases/${id}`, { force: true }); + return window.location.reload(); + } + } catch (error) { + return errorNotification(error); + } + }
@@ -857,6 +896,11 @@ {/if} + @@ -947,6 +991,11 @@ {/if} + @@ -1028,6 +1077,11 @@ {/if} + @@ -1119,6 +1173,11 @@ {/if} + @@ -1200,6 +1259,11 @@ {/if} + diff --git a/apps/ui/tailwind.config.cjs b/apps/ui/tailwind.config.cjs index 6fdba38f5..f1fa9734d 100644 --- a/apps/ui/tailwind.config.cjs +++ b/apps/ui/tailwind.config.cjs @@ -42,6 +42,7 @@ module.exports = { colors: { "applications": "#16A34A", "databases": "#9333EA", + "databases-100": "#9b46ea", "destinations": "#0284C7", "sources": "#EA580C", "services": "#DB2777",