-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jeroen Nijhuis
committed
Dec 27, 2023
1 parent
d040b32
commit 7123015
Showing
7 changed files
with
143 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { V1PersistentVolumeClaim } from "@kubernetes/client-node"; | ||
import { ColumnDef } from "@tanstack/vue-table"; | ||
import { formatDateTimeDifference } from "@/lib/utils"; | ||
|
||
export const columns: ColumnDef<V1PersistentVolumeClaim>[] = [ | ||
{ | ||
accessorKey: "metadata.name", | ||
header: "Name", | ||
}, | ||
{ | ||
header: "Storage Class", | ||
accessorKey: "spec.storageClassName", | ||
}, | ||
{ | ||
header: "Size", | ||
accessorKey: "status.capacity.storage", | ||
}, | ||
{ | ||
header: "Status", | ||
accessorKey: "status.phase", | ||
}, | ||
{ | ||
header: "Age", | ||
accessorFn: (row) => | ||
formatDateTimeDifference( | ||
row.metadata?.creationTimestamp || new Date(), | ||
new Date() | ||
), | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<script setup lang="ts"> | ||
import { injectStrict } from "@/lib/utils"; | ||
import { V1PersistentVolumeClaim } from "@kubernetes/client-node"; | ||
import { Kubernetes } from "@/services/Kubernetes"; | ||
import { ref, h } from "vue"; | ||
import { useToast, ToastAction } from "@/components/ui/toast"; | ||
import { KubeContextStateKey } from "@/providers/KubeContextProvider"; | ||
const { context, namespace } = injectStrict(KubeContextStateKey); | ||
import DataTable from "@/components/ui/DataTable.vue"; | ||
import { columns } from "@/components/tables/persistentvolumeclaims/columns"; | ||
import { useDataRefresher } from "@/composables/refresher"; | ||
const { toast } = useToast(); | ||
const pvcs = ref<V1PersistentVolumeClaim[]>([]); | ||
async function getPersistentVolumeClaims(refresh: boolean = false) { | ||
if (!refresh) { | ||
pvcs.value = []; | ||
} | ||
Kubernetes.getPersistentVolumeClaims( | ||
context.value, | ||
namespace.value === "all" ? "" : namespace.value | ||
) | ||
.then((results: V1PersistentVolumeClaim[]) => { | ||
pvcs.value = results; | ||
}) | ||
.catch((error) => { | ||
toast({ | ||
title: "An error occured", | ||
description: error.message, | ||
variant: "destructive", | ||
action: h( | ||
ToastAction, | ||
{ altText: "Retry", onClick: () => startRefreshing() }, | ||
{ default: () => "Retry" } | ||
), | ||
}); | ||
stopRefreshing(); | ||
}); | ||
} | ||
const { startRefreshing, stopRefreshing } = useDataRefresher( | ||
getPersistentVolumeClaims, | ||
1000, | ||
[context, namespace] | ||
); | ||
</script> | ||
x | ||
<template> | ||
<DataTable :data="pvcs" :columns="columns" /> | ||
</template> |