From 5330acf621a0f1d345652c92bf3e5afe9d44dbae Mon Sep 17 00:00:00 2001 From: Jigar Patel Date: Wed, 29 Jan 2025 16:31:58 -0500 Subject: [PATCH] fix(provider): fixed persistent storage ui issue --- .../src/pages/persistent-storage/index.tsx | 112 ++++++++++++++++-- apps/provider-console/src/types/provider.ts | 12 ++ 2 files changed, 113 insertions(+), 11 deletions(-) diff --git a/apps/provider-console/src/pages/persistent-storage/index.tsx b/apps/provider-console/src/pages/persistent-storage/index.tsx index 0f843a5c9..6783c62ed 100644 --- a/apps/provider-console/src/pages/persistent-storage/index.tsx +++ b/apps/provider-console/src/pages/persistent-storage/index.tsx @@ -1,6 +1,5 @@ import { useState } from "react"; import { Button, Checkbox, Spinner, Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@akashnetwork/ui/components"; -import { WarningCircle } from "iconoir-react"; import { useRouter } from "next/router"; import { Layout } from "@src/components/layout/Layout"; @@ -16,10 +15,12 @@ import { sanitizeMachineAccess } from "@src/utils/sanityUtils"; const PersistentStoragePage: React.FC = () => { const router = useRouter(); const { activeControlMachine } = useControlMachine(); - const { data: persistentDrives } = usePersistentStorage(activeControlMachine); const { address } = useSelectedChain(); const { data: providerDetails } = useProviderDetails(address); + const isPersistentStorageEnabled = providerDetails?.stats?.storage?.persistent?.available !== 0; + const { data: persistentDrives, refetch } = usePersistentStorage(isPersistentStorageEnabled ? null : activeControlMachine); + const [selectedDrives, setSelectedDrives] = useState<{ [key: string]: string[] }>({}); const [selectedType, setSelectedType] = useState(null); @@ -104,17 +105,106 @@ const PersistentStoragePage: React.FC = () => {
Persistent Storage - {providerDetails && !providerDetails.featPersistentStorage && ( -
-
-
- -
-
-

Persistent Storage is not enabled

+

Enable persistent storage to start accepting deployments with persistent storage.

+ {providerDetails && providerDetails?.stats?.storage?.persistent?.available !== 0 && ( + <> +
+
+
+
+
+
+

Available Storage

+
{formatBytes(providerDetails?.stats?.storage?.persistent?.available ?? 0)}
+
+
+ + + + +
+
+
+
+ +
+
+
+
+

Active Storage

+
{formatBytes(providerDetails.stats.storage.persistent.active)}
+
+
+ + + + +
+
+
+
+ + {providerDetails.stats.storage.persistent.pending > 0 && ( +
+
+
+
+

Pending Storage

+
{formatBytes(providerDetails.stats.storage.persistent.pending)}
+
+
+ + + + +
+
+
+
+ )}
-
+ + + )}
diff --git a/apps/provider-console/src/types/provider.ts b/apps/provider-console/src/types/provider.ts index 6c9a723a9..d774b1d87 100644 --- a/apps/provider-console/src/types/provider.ts +++ b/apps/provider-console/src/types/provider.ts @@ -54,6 +54,18 @@ export interface ProviderDetails { workloadSupportChiaCapabilities: string[]; featEndpointIp: boolean; uptime: Uptime[]; + stats: { + storage: { + ephemeral: StatStatus; + persistent: StatStatus; + }; + }; +} + +interface StatStatus { + available: number; + active: number; + pending: number; } interface Stats {