);
-}
\ No newline at end of file
+};
diff --git a/src/components/wrappers/dashboard/database/retention-policy/backup-retention-settings.action.tsx b/src/components/wrappers/dashboard/database/retention-policy/backup-retention-settings.action.tsx
index e0212d5f..cdb37139 100644
--- a/src/components/wrappers/dashboard/database/retention-policy/backup-retention-settings.action.tsx
+++ b/src/components/wrappers/dashboard/database/retention-policy/backup-retention-settings.action.tsx
@@ -4,15 +4,17 @@ import {userAction} from "@/safe-actions"
import {z} from "zod"
import {db} from "@/db"
import {eq} from "drizzle-orm"
-import {retentionSettingsSchema} from "@/components/wrappers/dashboard/database/retention-policy/schema";
import * as drizzleDb from "@/db";
+import {
+ RetentionSettingsSchema
+} from "@/components/wrappers/dashboard/database/retention-policy/backup-retention-settings.schema";
export const updateOrCreateBackupRetentionPolicyAction = userAction
.schema(
z.object({
databaseId: z.string(),
- settings: retentionSettingsSchema,
+ settings: RetentionSettingsSchema,
})
)
.action(async ({parsedInput}) => {
@@ -44,11 +46,12 @@ export const updateOrCreateBackupRetentionPolicyAction = userAction
.returning()
} else {
// Insert new policy
+
updated = await db
.insert(drizzleDb.schemas.retentionPolicy)
.values({
databaseId,
- type: settings.type,
+ type: settings.type ?? "gfs",
count: settings.count,
days: settings.days,
gfsDaily: settings.gfs.daily,
@@ -58,7 +61,6 @@ export const updateOrCreateBackupRetentionPolicyAction = userAction
})
.returning()
}
-
return {
data: updated[0],
}
diff --git a/src/components/wrappers/dashboard/database/retention-policy/backup-retention-settings.schema.ts b/src/components/wrappers/dashboard/database/retention-policy/backup-retention-settings.schema.ts
index 150eeeb1..b394d049 100644
--- a/src/components/wrappers/dashboard/database/retention-policy/backup-retention-settings.schema.ts
+++ b/src/components/wrappers/dashboard/database/retention-policy/backup-retention-settings.schema.ts
@@ -8,7 +8,7 @@ const GFSSettingsSchema = z.object({
});
export const RetentionSettingsSchema = z.object({
- type: z.enum(["count", "days", "gfs"]),
+ type: z.enum(["count", "days", "gfs"]).optional(),
count: z.number().min(1).max(100),
days: z.number().min(1).max(3650),
gfs: GFSSettingsSchema,
diff --git a/src/components/wrappers/dashboard/database/retention-policy/retention-policy-sheet.tsx b/src/components/wrappers/dashboard/database/retention-policy/retention-policy-sheet.tsx
index 2f534657..1d050eb7 100644
--- a/src/components/wrappers/dashboard/database/retention-policy/retention-policy-sheet.tsx
+++ b/src/components/wrappers/dashboard/database/retention-policy/retention-policy-sheet.tsx
@@ -1,9 +1,6 @@
import {Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger} from "@/components/ui/sheet";
import {Button} from "@/components/ui/button";
import {Database, DatabaseZap} from "lucide-react";
-import {
- BackupRetentionSettings
-} from "@/components/wrappers/dashboard/database/retention-policy/backup-retention-settings";
import {DatabaseWith as DbSchema, RetentionPolicy} from "@/db/schema/07_database";
import {
BackupRetentionSettingsForm
@@ -13,7 +10,7 @@ type RetentionPolicySheetProps = {
database: DbSchema
}
-export const RetentionPolicySheet = (props: RetentionPolicySheetProps) => {
+export const RetentionPolicySheet = ({database}: RetentionPolicySheetProps) => {
return (
@@ -35,10 +32,17 @@ export const RetentionPolicySheet = (props: RetentionPolicySheetProps) => {
enterprise GFS rotation strategies.
-
-
-
- {/**/}
+ {database.backupPolicy !== null ?
+
+ :
+
+
+ No backup policy configured yet. Please configure one !
+
+
+ }
)
diff --git a/src/components/wrappers/dashboard/database/retention-policy/schema.ts b/src/components/wrappers/dashboard/database/retention-policy/schema.ts
deleted file mode 100644
index 032bf973..00000000
--- a/src/components/wrappers/dashboard/database/retention-policy/schema.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-// --- Zod Schema ---
-import {z} from "zod";
-
-export const gfsSettingsSchema = z.object({
- daily: z.number().min(1).max(31),
- weekly: z.number().min(0).max(52),
- monthly: z.number().min(0).max(120),
- yearly: z.number().min(0).max(50),
-})
-
-export const retentionSettingsSchema = z.object({
- type: z.enum(["count", "days", "gfs"]),
- count: z.number().min(1).max(100),
- days: z.number().min(1).max(3650),
- gfs: gfsSettingsSchema,
-})
-
-export type RetentionSettings = z.infer
diff --git a/src/components/wrappers/dashboard/projects/database/database-kpi.tsx b/src/components/wrappers/dashboard/projects/database/database-kpi.tsx
index a0f0236f..2a3c4ab9 100644
--- a/src/components/wrappers/dashboard/projects/database/database-kpi.tsx
+++ b/src/components/wrappers/dashboard/projects/database/database-kpi.tsx
@@ -1,29 +1,63 @@
"use client";
-import {Card, CardContent, CardHeader} from "@/components/ui/card";
+import {Card, CardContent, CardHeader, CardTitle} from "@/components/ui/card";
import {formatDateLastContact} from "@/utils/date-formatting";
import {Database} from "@/db/schema/07_database";
+import {DatabaseBackup, Server, CheckCircle, Clock} from "lucide-react";
export type DatabaseKpiPro = {
successRate: any;
database: Database;
totalBackups: number;
+ availableBackups: number;
};
export const DatabaseKpi = (props: DatabaseKpiPro) => {
return (
- Backups
- {props.totalBackups}
+
+ Available Backups
+
+
+
+ {props.availableBackups}
+ Backups currently available
+
- Success rate
- {props.successRate ? `${props.successRate} %` : "Unavailable for now."}
+
+ Total Backups
+
+
+
+ {props.totalBackups}
+ Total backups recorded
+
- Last contact
- {formatDateLastContact(props.database.lastContact)}
+
+ Success Rate
+
+
+
+
+ {props.successRate ? `${props.successRate.toFixed(0)} %` : "Unavailable"}
+
+ Backup success rate
+
+
+
+
+ Last Contact
+
+
+
+
+ {formatDateLastContact(props.database.lastContact)}
+
+ Time of last backup contact
+
);