feat: cleanup unconfigured services and databases

This commit is contained in:
Andras Bacsai
2022-09-28 15:41:20 +02:00
parent 28377a156d
commit 683b8c966f
10 changed files with 130 additions and 15 deletions

View File

@@ -55,7 +55,6 @@
export let database: any;
import { del, get, post } from '$lib/api';
import { t } from '$lib/translations';
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import { errorNotification, handlerNotFoundLoad } from '$lib/common';
import { appSession, status, isDeploymentEnabled } from '$lib/store';

View File

@@ -22,6 +22,8 @@
<script lang="ts">
export let applications: any;
export let foundUnconfiguredApplication: boolean;
export let foundUnconfiguredService: boolean;
export let foundUnconfiguredDatabase: boolean;
export let databases: any;
export let services: any;
export let settings: any;
@@ -328,7 +330,9 @@
}
async function cleanupApplications() {
try {
const sure = confirm('Are you sure? This will delete all UNCONFIGURED applications and their data.');
const sure = confirm(
'Are you sure? This will delete all UNCONFIGURED applications and their data.'
);
if (sure) {
await post(`/applications/cleanup/unconfigured`, {});
return window.location.reload();
@@ -337,6 +341,32 @@
return errorNotification(error);
}
}
async function cleanupServices() {
try {
const sure = confirm(
'Are you sure? This will delete all UNCONFIGURED services and their data.'
);
if (sure) {
await post(`/services/cleanup/unconfigured`, {});
return window.location.reload();
}
} catch (error) {
return errorNotification(error);
}
}
async function cleanupDatabases() {
try {
const sure = confirm(
'Are you sure? This will delete all UNCONFIGURED databases and their data.'
);
if (sure) {
await post(`/databases/cleanup/unconfigured`, {});
return window.location.reload();
}
} catch (error) {
return errorNotification(error);
}
}
</script>
<nav class="header">
@@ -534,7 +564,7 @@
{/if}
{#if (filtered.applications.length > 0 && applications.length > 0) || filtered.otherApplications.length > 0}
<div class="flex items-center mt-10 space-x-2">
<h1 class="title lg:text-3xl pr-4">Applications</h1>
<h1 class="title lg:text-3xl">Applications</h1>
<button
class="btn btn-sm btn-primary"
class:loading={loading.applications}
@@ -760,8 +790,8 @@
</div>
{/if}
{#if (filtered.services.length > 0 && services.length > 0) || filtered.otherServices.length > 0}
<div class="flex items-center mt-10">
<h1 class="title lg:text-3xl pr-4">Services</h1>
<div class="flex items-center mt-10 space-x-2">
<h1 class="title lg:text-3xl">Services</h1>
<button
class="btn btn-sm btn-primary"
class:loading={loading.services}
@@ -769,6 +799,14 @@
on:click={refreshStatusServices}
>{noInitialStatus.services ? 'Load Status' : 'Refresh Status'}</button
>
{#if foundUnconfiguredService}
<button
class="btn btn-sm"
class:loading={loading.services}
disabled={loading.services}
on:click={cleanupServices}>Cleanup Unconfigured Resources</button
>
{/if}
</div>
{/if}
{#if filtered.services.length > 0 && services.length > 0}
@@ -914,8 +952,8 @@
</div>
{/if}
{#if (filtered.databases.length > 0 && databases.length > 0) || filtered.otherDatabases.length > 0}
<div class="flex items-center mt-10">
<h1 class="title lg:text-3xl pr-4">Databases</h1>
<div class="flex items-center mt-10 space-x-2">
<h1 class="title lg:text-3xl">Databases</h1>
<button
class="btn btn-sm btn-primary"
on:click={refreshStatusDatabases}
@@ -923,6 +961,14 @@
disabled={loading.databases}
>{noInitialStatus.databases ? 'Load Status' : 'Refresh Status'}</button
>
{#if foundUnconfiguredDatabase}
<button
class="btn btn-sm"
class:loading={loading.databases}
disabled={loading.databases}
on:click={cleanupDatabases}>Cleanup Unconfigured Resources</button
>
{/if}
</div>
{/if}
{#if filtered.databases.length > 0 && databases.length > 0}