Skip to content

Commit

Permalink
feat(kong): add loading symbol to data store delete button
Browse files Browse the repository at this point in the history
  • Loading branch information
brucetony committed Aug 13, 2024
1 parent fd12132 commit 6241955
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
1 change: 0 additions & 1 deletion components/KeycloakAuth.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
const { loggedIn, user, login, logout } = useOidcAuth();
console.log(user.value);
async function customLogout() {
await logout();
Expand Down
14 changes: 12 additions & 2 deletions components/data-stores/ResourceManagerTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
getDataStores,
getProjects,
} from "~/composables/useAPIFetch";
import type { DetailedAnalysis, Project, Route } from "~/services/Api";
import type { DetailedAnalysis, Project, Route, Service } from "~/services/Api";
const availableDataStores = ref();
const availableProjects = ref();
Expand Down Expand Up @@ -42,13 +42,23 @@ watch(analyses, (parsedAnalyses) => {
return { name: analysis.name, id: analysis.id };
});
});
function updateDataStores(newDataStoreCreation: Service) {
const newDataStoreEntry = {
name: newDataStoreCreation.name,
id: newDataStoreCreation.id,
};
availableDataStores.value = availableDataStores.value.push(newDataStoreEntry);
console.log(availableDataStores.value);
return;
}
</script>

<template>
<div class="card tabCard">
<TabView>
<TabPanel header="Create a Data Store">
<DataStoreCreator />
<DataStoreCreator @updatedRow="updateDataStores" />
</TabPanel>
<TabPanel
header="Bind a Project to a Data Store"
Expand Down
5 changes: 4 additions & 1 deletion components/data-stores/managers/DataStoreCreator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const protocol = ref("http");
const loading = ref(false);
const emit = defineEmits(["newDataStore"]);
const acceptedProtocols = ref([
"grpc",
"grpcs",
Expand Down Expand Up @@ -47,8 +49,9 @@ async function onSubmitCreateDataStore() {
}
}
loading.value = true;
const { status } = await createDataStore(dataStoreProps);
const { data: newDataStore, status } = await createDataStore(dataStoreProps);
created.value = status.value;
emit("newDataStore", newDataStore.value);
loading.value = false;
}
</script>
Expand Down
24 changes: 22 additions & 2 deletions components/data-stores/tables/DetailedDataStoreTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,33 @@ import { useConfirm } from "primevue/useconfirm";
import type { DetailedService } from "~/services/Api";
const confirm = useConfirm();
const toast = useToast();
const deleteLoading = ref(false);
const props = defineProps({
stores: Array<DetailedService>,
loading: Boolean,
});
function onConfirmDeleteDataStore(dsName: string) {
deleteDataStore(dsName);
async function onConfirmDeleteDataStore(dsName: string) {
deleteLoading.value = true;
const { status } = await deleteDataStore(dsName);
if (status.value === "success") {
toast.add({
severity: "info",
summary: "Delete success",
detail: "The data store was successfully deleted",
life: 3000,
});
} else {
toast.add({
severity: "error",
summary: "Delete failure",
detail: "An error occurred while trying to delete the data store",
life: 3000,
});
}
deleteLoading.value = false;
}
const confirmDelete = (event, dsName: string) => {
Expand Down Expand Up @@ -73,6 +92,7 @@ const confirmDelete = (event, dsName: string) => {
icon="pi pi-trash"
aria-label="Delete"
severity="danger"
:loading="deleteLoading"
@click="confirmDelete($event, slotProps.data.name)"
/>
</template>
Expand Down

0 comments on commit 6241955

Please sign in to comment.