mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
ui fixes
This commit is contained in:
@@ -25,8 +25,6 @@ export default async function RoutePage(props: PageParams<{}>) {
|
||||
orderBy: (fields) => desc(fields.createdAt),
|
||||
});
|
||||
|
||||
console.log(agents);
|
||||
|
||||
|
||||
if (!agents) {
|
||||
notFound();
|
||||
|
||||
@@ -24,7 +24,6 @@ export async function POST(
|
||||
const agentId = (await params).agentId
|
||||
const body: BodyResultRestore = await request.json();
|
||||
|
||||
console.log(body)
|
||||
|
||||
if (!isUuidv4(body.generatedId)) {
|
||||
return NextResponse.json(
|
||||
|
||||
@@ -41,7 +41,6 @@ export async function POST(
|
||||
|
||||
if (!isUuidv4(agentId)) {
|
||||
message = "agentId is not a valid uuid"
|
||||
console.log(message)
|
||||
return NextResponse.json(
|
||||
{error: "agentId is not a valid uuid"},
|
||||
{status: 500}
|
||||
@@ -54,7 +53,6 @@ export async function POST(
|
||||
|
||||
if (!agent) {
|
||||
message = "Agent not found"
|
||||
console.log(message)
|
||||
return NextResponse.json({error: message}, {status: 404})
|
||||
}
|
||||
const databasesResponse = await handleDatabases(body, agent, lastContact)
|
||||
@@ -77,7 +75,6 @@ export async function POST(
|
||||
},
|
||||
databases: databasesResponse
|
||||
}
|
||||
console.log(response)
|
||||
|
||||
return Response.json(response)
|
||||
} catch (error) {
|
||||
|
||||
+1
-13
@@ -19,7 +19,6 @@ export async function GET(request: Request) {
|
||||
new ReadableStream({
|
||||
start(controller) {
|
||||
console.log('Stream started');
|
||||
|
||||
const handleModification = (data: any) => {
|
||||
console.log('Modification event triggered:', data);
|
||||
controller.enqueue(`event: modification\n`);
|
||||
@@ -45,15 +44,4 @@ export async function GET(request: Request) {
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// export async function POST(request: Request) {
|
||||
// console.log('POST request received');
|
||||
// const data = await request.json();
|
||||
// console.log('Data received:', data);
|
||||
//
|
||||
// // Emit the event to all connected clients
|
||||
// eventEmitter.emit('modification', data);
|
||||
//
|
||||
// return new Response('Event sent', {status: 200});
|
||||
// }
|
||||
}
|
||||
@@ -63,7 +63,6 @@ export const LoginForm = (props: loginFormProps) => {
|
||||
toast.success("Login success");
|
||||
},
|
||||
onError: (error) => {
|
||||
console.log(error);
|
||||
toast.error(error.error.message);
|
||||
},
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ export const resetPasswordAction = action
|
||||
}
|
||||
|
||||
const user = await (await auth.$context).internalAdapter.findUserById(verification.value);
|
||||
console.log(user)
|
||||
if (!user) {
|
||||
return {
|
||||
success: false,
|
||||
@@ -39,28 +38,6 @@ export const resetPasswordAction = action
|
||||
};
|
||||
}
|
||||
|
||||
const hashedPassword = await (await auth.$context).password.hash(parsedInput.schema.password);
|
||||
console.log(hashedPassword)
|
||||
console.log("ok")
|
||||
// await (await auth.$context).internalAdapter.updatePassword(user.id, hashedPassword);
|
||||
console.log("ici")
|
||||
// await (await auth.$context).internalAdapter.deleteSessions(user.id);
|
||||
// console.log("ici2")
|
||||
// await (await auth.$context).internalAdapter.deleteVerificationValue(verification.id);
|
||||
// console.log("ici3");
|
||||
//
|
||||
// (await auth.$context).internalAdapter.updateUser(user.id, {
|
||||
// lastChangedPasswordAt: new Date(),
|
||||
// });
|
||||
|
||||
// await auth.api.resetPassword({
|
||||
// headers: await headers(),
|
||||
// body: {
|
||||
// newPassword: parsedInput.schema.password,
|
||||
// token: parsedInput.token,
|
||||
// },
|
||||
// });
|
||||
|
||||
await (
|
||||
await auth.$context
|
||||
).internalAdapter.updateUser(user.id, {
|
||||
|
||||
@@ -44,7 +44,6 @@ export const ResetPasswordForm = (props: ResetPasswordFormProps) => {
|
||||
setTimeout(() => router.push("/"), 1400);
|
||||
},
|
||||
onError: (error: BetterAuthError) => {
|
||||
console.log(error)
|
||||
toast.error("An error occurred while resetting password");
|
||||
},
|
||||
});
|
||||
|
||||
@@ -36,7 +36,6 @@ export const RegisterForm = (props: registerFormProps) => {
|
||||
router.push(`/login`);
|
||||
},
|
||||
onError: (error) => {
|
||||
console.log(error);
|
||||
toast.error(error.error.message);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@ import {Form, FormControl, FormField, FormItem, FormLabel, useZodForm} from "@/c
|
||||
import {PasswordStrengthInput} from "@/components/ui/password-input-indicator";
|
||||
import {ResetPasswordSchema, ResetPasswordType} from "@/components/wrappers/auth/reset-password/reset-password-schema";
|
||||
import {PasswordInput} from "@/components/ui/password-input";
|
||||
import {Card, CardContent, CardHeader} from "@/components/ui/card";
|
||||
import {CardContent, CardHeader} from "@/components/ui/card";
|
||||
import {ButtonWithLoading} from "@/components/wrappers/common/button/button-with-loading";
|
||||
import {authClient} from "@/lib/auth/auth-client";
|
||||
import {toast} from "sonner";
|
||||
@@ -31,7 +31,6 @@ export const ResetPasswordForm = ({token}: ResetPasswordFormProps) => {
|
||||
token,
|
||||
}, {
|
||||
onSuccess: (response) => {
|
||||
console.log(response);
|
||||
toast.success("Password changed successfully.");
|
||||
setTimeout(() => router.push("/"), 1000);
|
||||
},
|
||||
|
||||
@@ -12,8 +12,6 @@ export const ConnectionCircle = ({date}: ConnectionCircleProps) => {
|
||||
const timestamp = date.getTime();
|
||||
const interval_seconds = (now - timestamp) / 1000;
|
||||
|
||||
console.log({now, timestamp, interval_seconds});
|
||||
|
||||
if (interval_seconds < 55) {
|
||||
style = "bg-green-400 border-green-600";
|
||||
} else if (interval_seconds <= 60) {
|
||||
@@ -25,7 +23,5 @@ export const ConnectionCircle = ({date}: ConnectionCircleProps) => {
|
||||
console.warn("Invalid date passed to ConnectionCircle:", date);
|
||||
}
|
||||
|
||||
console.log(style);
|
||||
|
||||
return <div className={cn("w-5 h-5 rounded-full border-4", style)}/>;
|
||||
};
|
||||
|
||||
-4
@@ -29,10 +29,6 @@ export const NotifierChannelOrganisationForm = ({
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
|
||||
console.log("defaultValues", defaultValues);
|
||||
console.log("organizations", organizations);
|
||||
|
||||
const defaultOrganizationIds = defaultValues?.organizations?.map(organization => organization.organizationId) ?? []
|
||||
|
||||
|
||||
|
||||
-3
@@ -34,13 +34,11 @@ export const OrganizationAddMemberForm = ({onSuccessAction, users, organization}
|
||||
|
||||
const mutationAddMemberOrganisation = useMutation({
|
||||
mutationFn: async (data: AddMemberSchemaType) => {
|
||||
console.log(data);
|
||||
const result = await addMemberOrganizationAction({
|
||||
userId: data.userId,
|
||||
organizationId: organization.id,
|
||||
role: "member",
|
||||
});
|
||||
console.log(result);
|
||||
toast.success("Member successfully added!");
|
||||
router.refresh();
|
||||
onSuccessAction?.();
|
||||
@@ -71,7 +69,6 @@ export const OrganizationAddMemberForm = ({onSuccessAction, users, organization}
|
||||
placeholder="Enter a user email"
|
||||
entries={filteredUsers}
|
||||
onSelect={(entySelected: any) => {
|
||||
console.log("Form selection:", entySelected);
|
||||
field.onChange(entySelected.value);
|
||||
}}
|
||||
/>
|
||||
|
||||
-2
@@ -35,13 +35,11 @@ export const OrganizationDeleteMemberModal = ({ member, open, onOpenChangeAction
|
||||
},
|
||||
{
|
||||
onSuccess: async (response) => {
|
||||
console.log(response);
|
||||
toast.success("Member successfully deleted!");
|
||||
onOpenChangeAction(false);
|
||||
router.refresh();
|
||||
},
|
||||
onError: async (error) => {
|
||||
console.log(error);
|
||||
toast.error("An error occurred while deleting member!");
|
||||
onOpenChangeAction(false);
|
||||
},
|
||||
|
||||
-1
@@ -49,7 +49,6 @@ export const OrganizationMemberChangeRoleModal = (props: OrganizationMemberChang
|
||||
router.refresh();
|
||||
},
|
||||
onError: (error) => {
|
||||
console.log(error);
|
||||
toast.error("An error occurred while updating member");
|
||||
onOpenChangeAction(false);
|
||||
},
|
||||
|
||||
-2
@@ -28,11 +28,9 @@ export const StorageS3Form = (props: S3FormProps) => {
|
||||
|
||||
const mutation = useMutation({
|
||||
mutationFn: async (values: S3FormType) => {
|
||||
console.log(values);
|
||||
const updateS3Settings = await updateS3SettingsAction({ name: "system", data: values });
|
||||
const data = updateS3Settings?.data?.data;
|
||||
if (updateS3Settings?.serverError || !data) {
|
||||
console.log(updateS3Settings?.serverError);
|
||||
toast.error(updateS3Settings?.serverError);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ export const AdminUserEditForm = ({ onSuccess, defaultValues }: AdminUserEditFor
|
||||
...data,
|
||||
id: defaultValues?.id || "",
|
||||
});
|
||||
console.log(result)
|
||||
const inner = result?.data;
|
||||
if (inner?.success) {
|
||||
toast.success("User Successfully updated");
|
||||
|
||||
@@ -5,7 +5,7 @@ import {Server} from "lucide-react";
|
||||
import {formatDateLastContact} from "@/utils/date-formatting";
|
||||
import {AgentCardKey} from "@/components/wrappers/dashboard/agent/agent-card-key/agent-card-key";
|
||||
import {CardsWithPagination} from "@/components/wrappers/common/cards-with-pagination";
|
||||
import {DatabaseCard} from "@/components/wrappers/dashboard/projects/project-card/project-database-card";
|
||||
import {AgentDatabaseCard} from "@/components/wrappers/dashboard/agent/agent-database-card";
|
||||
import {AgentWithDatabases} from "@/db/schema/08_agent";
|
||||
import {eventUpdate} from "@/types/events";
|
||||
import {useAutoRefresh} from "@/hooks/use-auto-refresh";
|
||||
@@ -72,7 +72,7 @@ export const AgentContentPage = ({edgeKey, agent}: AgentContentPageProps) => {
|
||||
</CardContent>
|
||||
</Card>
|
||||
<CardsWithPagination cardsPerPage={4} numberOfColumns={2} data={agent.databases}
|
||||
cardItem={DatabaseCard}/>
|
||||
cardItem={AgentDatabaseCard}/>
|
||||
|
||||
</>
|
||||
)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
"use client";
|
||||
|
||||
import {Database} from "@/db/schema/07_database";
|
||||
import {DatabaseCard} from "@/components/wrappers/dashboard/projects/project-card/project-database-card";
|
||||
|
||||
export type agentDatabaseCardProps = {
|
||||
data: Database;
|
||||
};
|
||||
|
||||
export const AgentDatabaseCard = (props: agentDatabaseCardProps) => {
|
||||
const {data: database} = props;
|
||||
|
||||
return <DatabaseCard data={database}/>;
|
||||
|
||||
//todo: à remettre quand on aura fait l'impersonation des admins
|
||||
/* if (!database.projectId) {
|
||||
return <DatabaseCard data={database}/>;
|
||||
}
|
||||
|
||||
return (
|
||||
<Link className="group block transition-all duration-200 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 rounded-xl"
|
||||
href={`/dashboard/projects/${database.projectId}/database/${database.id}`}>
|
||||
<DatabaseCard data={database}/>
|
||||
</Link>
|
||||
);*/
|
||||
};
|
||||
@@ -47,7 +47,6 @@ export const AgentForm = (props: agentFormProps) => {
|
||||
|
||||
const data = createAgent?.data?.data;
|
||||
if (createAgent?.serverError || !data) {
|
||||
console.log(createAgent?.serverError);
|
||||
toast.error(createAgent?.serverError);
|
||||
return;
|
||||
}
|
||||
|
||||
-9
@@ -20,15 +20,6 @@ export const NotifierTestChannelButton = ({notificationChannel, organizationId}:
|
||||
const mutation = useMutation({
|
||||
mutationFn: async () => {
|
||||
|
||||
// const payload: EventPayload = {
|
||||
// title: 'Database Down',
|
||||
// message: 'Primary DB instance is unreachable',
|
||||
// level: 'critical',
|
||||
// data: {host: 'db-prod-01', error: 'connection timeout'},
|
||||
// };
|
||||
|
||||
console.log("organizationId ici", organizationId);
|
||||
|
||||
const payload: EventPayload = {
|
||||
title: 'Test Channel',
|
||||
message: `We are testing channel ${notificationChannel.name}`,
|
||||
|
||||
@@ -296,9 +296,7 @@ export const AlertPolicyForm = ({database, notificationChannels, organizationId,
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-1.5">
|
||||
<Label className="text-[10px] font-bold text-transparent uppercase tracking-widest select-none">
|
||||
Actions
|
||||
</Label>
|
||||
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
|
||||
@@ -38,7 +38,6 @@ export function CreateOrganizationModal({
|
||||
|
||||
const mutation = useMutation({
|
||||
mutationFn: async (values: OrganizationSchema) => {
|
||||
console.log(values);
|
||||
|
||||
const result = await createOrganizationAction(values);
|
||||
|
||||
@@ -73,7 +72,6 @@ export function CreateOrganizationModal({
|
||||
form={form}
|
||||
className="flex flex-col gap-4"
|
||||
onSubmit={async (values) => {
|
||||
console.log(values);
|
||||
await mutation.mutateAsync(values);
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -25,7 +25,6 @@ export const AvatarWithUpload = (props: AvatarWithUploadProps) => {
|
||||
const data = uploadImage?.data?.data;
|
||||
|
||||
if (uploadImage?.serverError || !data) {
|
||||
console.log(uploadImage?.serverError);
|
||||
toast.error(uploadImage?.serverError);
|
||||
return;
|
||||
}
|
||||
@@ -34,7 +33,6 @@ export const AvatarWithUpload = (props: AvatarWithUploadProps) => {
|
||||
const dataUser = updateUser?.data?.data;
|
||||
|
||||
if (updateUser?.serverError || !dataUser) {
|
||||
console.log(updateUser?.serverError);
|
||||
toast.error(updateUser?.serverError);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,6 @@ export function ProfileAccount({user}: ProfileAccountProps) {
|
||||
router.refresh();
|
||||
},
|
||||
onError: (error: BetterAuthError) => {
|
||||
console.log(error)
|
||||
if (error.code === "USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL") {
|
||||
toast.error("User already exists, use another email address!");
|
||||
emailForm.reset({email: user.email});
|
||||
|
||||
-2
@@ -21,8 +21,6 @@ export const deleteProjectAction = userAction.schema(z.string()).action(async ({
|
||||
|
||||
|
||||
const databasesToRemove = databasesUpdated.map((db) => db.id);
|
||||
console.log(databasesUpdated);
|
||||
console.log(databasesToRemove);
|
||||
|
||||
await db.delete(drizzleDb.schemas.retentionPolicy)
|
||||
.where(inArray(drizzleDb.schemas.retentionPolicy.databaseId, databasesToRemove)).execute();
|
||||
|
||||
@@ -125,7 +125,6 @@ export const DatabaseBackupList = (props: DatabaseBackupListProps) => {
|
||||
<DropdownMenuContent align="start">
|
||||
<DropdownMenuItem
|
||||
onClick={async () => {
|
||||
console.log("Deleting rows:", rows)
|
||||
await mutationDeleteBackups.mutateAsync(rows)
|
||||
}}
|
||||
className="text-red-600 focus:text-red-700"
|
||||
|
||||
@@ -20,18 +20,18 @@ export const ProjectCard = (props: projectCardProps) => {
|
||||
href={`/dashboard/projects/${project.id}`}
|
||||
className="group block transition-all duration-200 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 rounded-xl"
|
||||
>
|
||||
<Card className="relative h-full flex flex-col p-5 transition-all border-border/50 bg-card hover:bg-accent/50 hover:border-primary/50 group-hover:shadow-lg overflow-hidden">
|
||||
<div className="flex items-start justify-between mb-4">
|
||||
<div className="flex items-center justify-center w-12 h-12 rounded-2xl bg-primary/10 text-primary group-hover:bg-primary group-hover:text-primary-foreground transition-all duration-300 shadow-inner">
|
||||
<Folder className="w-6 h-6" />
|
||||
<Card className="relative h-full flex flex-col p-4 transition-all border-border/50 bg-card hover:bg-accent/50 hover:border-primary/50 group-hover:shadow-lg overflow-hidden gap-0">
|
||||
<div className="flex items-start justify-between mb-2">
|
||||
<div className="flex items-center justify-center w-12 h-12 rounded-xl bg-primary/10 text-primary group-hover:bg-primary group-hover:text-primary-foreground transition-all duration-300 shadow-inner">
|
||||
<Folder className="w-8 h-8" />
|
||||
</div>
|
||||
<Badge className="text-xs font-medium px-2 py-1 rounded-lg bg-secondary/50 text-foreground">{dbCount} {dbCount === 1 ? "Database" : "Databases"}
|
||||
<Badge className="text-[10px] font-medium px-2 py-1 rounded-lg bg-secondary/50 text-foreground">{dbCount} {dbCount === 1 ? "Database" : "Databases"}
|
||||
</Badge>
|
||||
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-1.5 flex-1">
|
||||
<h3 className="text-xl font-black text-foreground group-hover:text-primary transition-colors line-clamp-1">
|
||||
<div className="flex flex-col gap-2 flex-1">
|
||||
<h3 className="text-lg font-black text-foreground group-hover:text-primary transition-colors line-clamp-1 tracking-tight">
|
||||
{project.name}
|
||||
</h3>
|
||||
<p className="text-xs text-muted-foreground line-clamp-2 leading-relaxed">
|
||||
@@ -39,11 +39,11 @@ export const ProjectCard = (props: projectCardProps) => {
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="mt-6 flex items-center justify-between pt-4 border-t border-border/50">
|
||||
<div className="mt-4 flex items-center justify-between pt-3 border-t border-border/50">
|
||||
<span className="text-[10px] font-bold uppercase tracking-widest text-primary opacity-0 group-hover:opacity-100 transition-all duration-300 transform translate-x-[-10px] group-hover:translate-x-0">View Project</span>
|
||||
<div className="flex items-center gap-1 text-muted-foreground group-hover:text-primary transition-colors">
|
||||
<span className="text-[10px] font-bold uppercase tracking-widest group-hover:hidden">Details</span>
|
||||
<ChevronRight className="w-4 h-4 group-hover:translate-x-1 transition-transform" />
|
||||
<ChevronRight className="w-3.5 h-3.5 group-hover:translate-x-1 transition-transform" />
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
@@ -43,61 +43,61 @@ export const DatabaseCard = (props: databaseCardProps) => {
|
||||
};
|
||||
|
||||
return (
|
||||
<Card className="relative h-full flex flex-col p-6 transition-all border-border/50 bg-card hover:bg-accent/50 hover:border-primary/50 group-hover:shadow-lg overflow-hidden">
|
||||
<div className="flex items-start justify-between mb-6">
|
||||
<div className="relative w-16 h-16 p-3 bg-background rounded-2xl border border-border/50 shadow-sm flex items-center justify-center group-hover:border-primary/30 transition-all duration-300 group-hover:scale-105">
|
||||
<Card className="relative h-full flex flex-col p-4 transition-all border-border/50 bg-card hover:bg-accent/50 hover:border-primary/50 group-hover:shadow-lg overflow-hidden gap-0">
|
||||
<div className="flex items-start justify-between mb-2">
|
||||
<div className="relative w-12 h-12 p-2 bg-background rounded-xl border border-border/50 shadow-sm flex items-center justify-center group-hover:border-primary/30 transition-all duration-300 group-hover:scale-105">
|
||||
<Image
|
||||
src={`/images/${database.dbms}.png`}
|
||||
alt={`${database.dbms} icon`}
|
||||
width={48}
|
||||
height={48}
|
||||
width={32}
|
||||
height={32}
|
||||
className="object-contain w-full h-full"
|
||||
/>
|
||||
</div>
|
||||
<div className="flex flex-col items-end gap-3">
|
||||
<div className="scale-125 origin-right">
|
||||
<div className="scale-100 origin-right">
|
||||
<ConnectionCircle date={database.lastContact}/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-4 flex-1">
|
||||
<h3 className="text-xl font-black text-foreground group-hover:text-primary transition-colors truncate tracking-tight">
|
||||
<div className="flex flex-col gap-2 flex-1">
|
||||
<h3 className="text-lg font-black text-foreground group-hover:text-primary transition-colors truncate tracking-tight">
|
||||
{database.name}
|
||||
</h3>
|
||||
|
||||
<div className="flex flex-col gap-3">
|
||||
<div className="flex items-center gap-2.5 text-muted-foreground group-hover:text-foreground transition-colors">
|
||||
<div className="p-1.5 bg-muted/50 rounded-lg">
|
||||
<Fingerprint className="w-4 h-4" />
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="flex items-center gap-2 text-muted-foreground group-hover:text-foreground transition-colors">
|
||||
<div className="p-1 bg-muted/50 rounded-lg">
|
||||
<Fingerprint className="w-3.5 h-3.5" />
|
||||
</div>
|
||||
<span className="font-mono text-xs font-bold truncate">
|
||||
<span className="font-mono text-[10px] font-bold truncate">
|
||||
{database.agentDatabaseId}
|
||||
</span>
|
||||
<button
|
||||
onClick={handleCopy}
|
||||
className="ml-1 p-1 hover:bg-muted rounded-md transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 z-10"
|
||||
className="ml-1 p-0.5 hover:bg-muted rounded-md transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 z-10"
|
||||
title="Copy ID"
|
||||
>
|
||||
{isCopied ? <Check className="w-3 h-3 text-green-500" /> : <Copy className="w-3 h-3" />}
|
||||
{isCopied ? <Check className="w-2.5 h-2.5 text-green-500" /> : <Copy className="w-2.5 h-2.5" />}
|
||||
</button>
|
||||
</div>
|
||||
<div className="flex items-center gap-2.5 text-muted-foreground group-hover:text-foreground transition-colors">
|
||||
<div className="p-1.5 bg-muted/50 rounded-lg">
|
||||
<Activity className="w-4 h-4" />
|
||||
<div className="flex items-center gap-2 text-muted-foreground group-hover:text-foreground transition-colors">
|
||||
<div className="p-1 bg-muted/50 rounded-lg">
|
||||
<Activity className="w-3.5 h-3.5" />
|
||||
</div>
|
||||
<span className="text-xs font-bold uppercase tracking-tight">
|
||||
<span className="text-[10px] font-bold uppercase tracking-tight">
|
||||
{formatDateLastContact(database.lastContact)}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-8 flex items-center justify-between pt-4 border-t border-border/50">
|
||||
<span className="text-[10px] font-black uppercase tracking-widest text-primary opacity-0 group-hover:opacity-100 transition-all duration-300 transform translate-x-[-10px] group-hover:translate-x-0">Open Explorer</span>
|
||||
<div className="mt-4 flex items-center justify-between pt-3 border-t border-border/50">
|
||||
<span className="text-[10px] font-black uppercase tracking-widest text-primary opacity-0 group-hover:opacity-100 transition-all duration-300 transform translate-x-[-10px] group-hover:translate-x-0">Open</span>
|
||||
<div className="flex items-center gap-1 text-muted-foreground group-hover:text-primary transition-colors">
|
||||
<span className="text-[10px] font-bold uppercase tracking-widest group-hover:hidden">Details</span>
|
||||
<ChevronRight className="w-4 h-4 group-hover:translate-x-1 transition-transform" />
|
||||
<ChevronRight className="w-3.5 h-3.5 group-hover:translate-x-1 transition-transform" />
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
@@ -62,7 +62,6 @@ export const createProjectAction = userAction
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return {
|
||||
success: false,
|
||||
actionError: {
|
||||
|
||||
@@ -66,10 +66,8 @@ export function backupColumns(
|
||||
header: "Reference",
|
||||
cell: ({row}) => {
|
||||
const fileName = row.original.file
|
||||
console.log(row.original)
|
||||
const reference = row.original.id
|
||||
const isImported = isImportedFilename(`${fileName}`)
|
||||
console.log(isImported)
|
||||
return isImported ? `${reference} (imported)` : `${reference}`
|
||||
},
|
||||
},
|
||||
@@ -77,7 +75,6 @@ export function backupColumns(
|
||||
accessorKey: "fileSize",
|
||||
header: "Size",
|
||||
cell: ({row}) => {
|
||||
console.log(row.original.fileSize)
|
||||
return formatBytes(row.getValue("fileSize"))
|
||||
},
|
||||
},
|
||||
@@ -163,7 +160,6 @@ export function backupColumns(
|
||||
} else if (settings.storage == "s3") {
|
||||
data = await getFileUrlPreSignedS3Action(`backups/${database.project?.slug}/${fileName}`);
|
||||
}
|
||||
console.log(data)
|
||||
if (data?.data?.success) {
|
||||
url = data.data.value ?? "";
|
||||
} else {
|
||||
|
||||
@@ -84,7 +84,7 @@ export async function dispatchNotification(
|
||||
success: false,
|
||||
channelId: channelId || "",
|
||||
provider: null,
|
||||
error: "Channel not active¬",
|
||||
error: "Channel not active",
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,67 +1,64 @@
|
||||
import {DatabaseWith} from "@/db/schema/07_database";
|
||||
import {EventKind, EventPayload} from "@/features/notifications/types";
|
||||
import {dispatchNotification} from "@/features/notifications/dispatch";
|
||||
|
||||
import { DatabaseWith } from "@/db/schema/07_database";
|
||||
import { EventKind, EventPayload } from "@/features/notifications/types";
|
||||
import { dispatchNotification } from "@/features/notifications/dispatch";
|
||||
|
||||
export async function sendNotificationsBackupRestore(database: DatabaseWith, event: EventKind) {
|
||||
|
||||
if (database.alertPolicies && database.alertPolicies.length > 0) {
|
||||
for (const alertPolicy of database.alertPolicies) {
|
||||
if (alertPolicy.enabled) {
|
||||
|
||||
const eventKinds = alertPolicy.eventKinds
|
||||
|
||||
if (eventKinds.includes(event)) {
|
||||
|
||||
const date = new Date()
|
||||
|
||||
let level: "info" | "critical" = "info";
|
||||
let message = "";
|
||||
let error: string | null = null;
|
||||
|
||||
switch (event) {
|
||||
case "error_backup":
|
||||
case "error_restore":
|
||||
level = "critical";
|
||||
message = `An error occurred during ${event.includes("backup") ? "backup" : "restore"} on ${date.toISOString()}.`;
|
||||
error = "Check database connection or agent";
|
||||
break;
|
||||
case "success_backup":
|
||||
case "success_restore":
|
||||
level = "info";
|
||||
message = `${event.includes("backup") ? "Backup" : "Restore"} completed successfully at ${date.toISOString()}.`;
|
||||
break;
|
||||
case "weekly_report":
|
||||
level = "info";
|
||||
message = `Weekly report generated at ${date.toISOString()}.`;
|
||||
break;
|
||||
}
|
||||
|
||||
const titleMap: Record<EventKind, string> = {
|
||||
error_backup: `Backup Notification`,
|
||||
error_restore: `Restore Notification`,
|
||||
success_backup: `Backup Notification`,
|
||||
success_restore: `Restore Notification`,
|
||||
weekly_report: `Weekly Report Notification`,
|
||||
};
|
||||
|
||||
|
||||
const payload: EventPayload = {
|
||||
title: titleMap[event],
|
||||
message,
|
||||
level: level,
|
||||
event: event,
|
||||
data: {
|
||||
host: database.name,
|
||||
id: database.id,
|
||||
agentDatabaseId: database.agentDatabaseId,
|
||||
error,
|
||||
},
|
||||
};
|
||||
return await dispatchNotification(payload, alertPolicy.id, undefined, undefined);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!database.alertPolicies || database.alertPolicies.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const activePolicies = database.alertPolicies.filter(policy =>
|
||||
policy.enabled && policy.eventKinds.includes(event)
|
||||
);
|
||||
|
||||
const promises = activePolicies.map(alertPolicy => {
|
||||
const date = new Date();
|
||||
let level: "info" | "critical" = "info";
|
||||
let message = "";
|
||||
let error: string | null = null;
|
||||
|
||||
switch (event) {
|
||||
case "error_backup":
|
||||
case "error_restore":
|
||||
level = "critical";
|
||||
message = `An error occurred during ${event.includes("backup") ? "backup" : "restore"} on ${date.toISOString()}.`;
|
||||
error = "Check database connection or agent";
|
||||
break;
|
||||
case "success_backup":
|
||||
case "success_restore":
|
||||
level = "info";
|
||||
message = `${event.includes("backup") ? "Backup" : "Restore"} completed successfully at ${date.toISOString()}.`;
|
||||
break;
|
||||
case "weekly_report":
|
||||
level = "info";
|
||||
message = `Weekly report generated at ${date.toISOString()}.`;
|
||||
break;
|
||||
}
|
||||
|
||||
const titleMap: Record<EventKind, string> = {
|
||||
error_backup: `Backup Notification`,
|
||||
error_restore: `Restore Notification`,
|
||||
success_backup: `Backup Notification`,
|
||||
success_restore: `Restore Notification`,
|
||||
weekly_report: `Weekly Report Notification`,
|
||||
};
|
||||
|
||||
const payload: EventPayload = {
|
||||
title: titleMap[event],
|
||||
message,
|
||||
level: level,
|
||||
event: event,
|
||||
data: {
|
||||
host: database.name,
|
||||
id: database.id,
|
||||
agentDatabaseId: database.agentDatabaseId,
|
||||
error,
|
||||
},
|
||||
};
|
||||
|
||||
return dispatchNotification(payload, alertPolicy.id, undefined, undefined);
|
||||
});
|
||||
|
||||
|
||||
return Promise.all(promises);
|
||||
}
|
||||
@@ -59,7 +59,6 @@ async function uploadLocal(fileName: string, buffer: any) {
|
||||
await mkdir(path.join(process.cwd(), localDir), {recursive: true});
|
||||
return await writeFile(path.join(process.cwd(), localDir + fileName), buffer);
|
||||
} catch (error) {
|
||||
console.log("Error occured ", error);
|
||||
throw new Error("An error occured while importing image");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,15 +45,12 @@ export function useAutoRefresh(options: UseAutoRefreshOptions) {
|
||||
|
||||
try {
|
||||
payload = JSON.parse(event.data);
|
||||
} catch {
|
||||
// keep raw payload
|
||||
}
|
||||
} catch {}
|
||||
|
||||
const shouldRefresh =
|
||||
options.sse?.shouldRefresh?.(payload) ?? true;
|
||||
|
||||
if (shouldRefresh) {
|
||||
console.log("Received event source", eventSource);
|
||||
router.refresh();
|
||||
}
|
||||
});
|
||||
|
||||
+4
-15
@@ -46,11 +46,7 @@ export const auth = betterAuth({
|
||||
{}
|
||||
),
|
||||
});
|
||||
|
||||
},
|
||||
onPasswordReset: async ({user}, request) => {
|
||||
console.log(`Password for user ${user.email} has been reset.`);
|
||||
},
|
||||
}
|
||||
},
|
||||
emailVerification: {
|
||||
async sendVerificationEmail({user, token, url}) {
|
||||
@@ -176,13 +172,12 @@ export const auth = betterAuth({
|
||||
const role = userCount === 0 ? "owner" : "admin";
|
||||
|
||||
|
||||
const defaultOrgSlug = "default"; // change this if your default org has a different slug
|
||||
const defaultOrgSlug = "default";
|
||||
const defaultOrg = await db.query.organization.findFirst({
|
||||
where: eq(drizzleDb.schemas.organization.slug, defaultOrgSlug),
|
||||
});
|
||||
|
||||
if (defaultOrg) {
|
||||
console.log(user)
|
||||
await db.insert(drizzleDb.schemas.member).values({
|
||||
userId: user.id,
|
||||
organizationId: defaultOrg.id,
|
||||
@@ -295,7 +290,6 @@ export const auth = betterAuth({
|
||||
};
|
||||
}
|
||||
|
||||
console.log("sessionId", session.id);
|
||||
|
||||
const [aa] = await db
|
||||
.update(drizzleUser.session)
|
||||
@@ -303,7 +297,6 @@ export const auth = betterAuth({
|
||||
.where(eq(drizzleUser.session.id, session.id))
|
||||
.returning();
|
||||
|
||||
console.log("aaaaa", aa);
|
||||
|
||||
return {
|
||||
...session,
|
||||
@@ -516,9 +509,7 @@ export const checkSlugOrganization = async (slug: string) => {
|
||||
});
|
||||
|
||||
return status;
|
||||
} catch (e) {
|
||||
console.log("err", e);
|
||||
}
|
||||
} catch {}
|
||||
};
|
||||
|
||||
export const getActiveMember = async () => {
|
||||
@@ -542,7 +533,5 @@ export const setActiveOrganization = async (slug: string) => {
|
||||
organizationSlug: slug,
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
console.log("error", e);
|
||||
}
|
||||
} catch {}
|
||||
};
|
||||
|
||||
@@ -18,7 +18,6 @@ export const retentionCleanTask = async () => {
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(databases);
|
||||
|
||||
for (const db of databases) {
|
||||
if (!db.retentionPolicy) continue; // no policy = skip
|
||||
@@ -34,7 +33,6 @@ export async function enforceRetention(
|
||||
databaseId: string,
|
||||
policy: typeof retentionPolicy.$inferSelect
|
||||
) {
|
||||
console.log(`EnforceRetention: ${policy}`);
|
||||
|
||||
switch (policy.type) {
|
||||
case "count":
|
||||
|
||||
@@ -8,7 +8,6 @@ export async function generateEdgeKey(serverUrl: string, agentId: string): Promi
|
||||
agentId,
|
||||
publicKey
|
||||
};
|
||||
console.log(edgeKeyData);
|
||||
const edgeKeyJson = JSON.stringify(edgeKeyData);
|
||||
const edgeKeyBuffer = Buffer.from(edgeKeyJson, 'utf-8');
|
||||
return edgeKeyBuffer.toString('base64').replace(/=+$/, '').replace(/\+/g, '-').replace(/\//g, '_');
|
||||
|
||||
@@ -171,22 +171,18 @@ export async function createPresignedUrlToUpload({
|
||||
return await s3Client.presignedPutObject(bucketName, fileName, expiry);
|
||||
}
|
||||
|
||||
// Function to create a bucket and make it public
|
||||
export async function createPublicBucket({bucketName}: { bucketName: string }) {
|
||||
const s3Client = await getS3Client();
|
||||
|
||||
try {
|
||||
// Check if the bucket already exists
|
||||
const exists = await s3Client.bucketExists(bucketName);
|
||||
if (!exists) {
|
||||
// Create the bucket
|
||||
await s3Client.makeBucket(bucketName); // Change region if needed
|
||||
await s3Client.makeBucket(bucketName);
|
||||
console.log(`Bucket ${bucketName} created successfully.`);
|
||||
} else {
|
||||
console.log(`Bucket ${bucketName} already exists.`);
|
||||
}
|
||||
|
||||
// Define a bucket policy for public access
|
||||
const policy = {
|
||||
Version: "2012-10-17",
|
||||
Statement: [
|
||||
@@ -199,7 +195,6 @@ export async function createPublicBucket({bucketName}: { bucketName: string }) {
|
||||
],
|
||||
};
|
||||
|
||||
// Set the policy to the bucket
|
||||
await s3Client.setBucketPolicy(bucketName, JSON.stringify(policy));
|
||||
console.log(`Bucket ${bucketName} is now public.`);
|
||||
} catch (error) {
|
||||
@@ -242,7 +237,6 @@ export async function createPresignedUrlToDownload({
|
||||
bucketName,
|
||||
fileName,
|
||||
errorMessage: err?.message,
|
||||
// stack: err?.stack,
|
||||
});
|
||||
throw {error: err.message ?? "Unknown error"};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user