mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
This commit focuses on removing unused variables, adding placeholder error handling, and generally tidying up various files across the Dokploy application. Changes include: - Removing unused imports and variables - Adding placeholder error handling in catch blocks - Cleaning up commented-out code - Removing deprecated utility files - Improving type safety and code consistency
81 lines
1.7 KiB
TypeScript
81 lines
1.7 KiB
TypeScript
import SwarmMonitorCard from "@/components/dashboard/swarm/monitoring-card";
|
|
import { DashboardLayout } from "@/components/layouts/dashboard-layout";
|
|
import { appRouter } from "@/server/api/root";
|
|
import { IS_CLOUD } from "@dokploy/server/constants";
|
|
import { validateRequest } from "@dokploy/server/lib/auth";
|
|
import { createServerSideHelpers } from "@trpc/react-query/server";
|
|
import type { GetServerSidePropsContext } from "next";
|
|
import type { ReactElement } from "react";
|
|
import superjson from "superjson";
|
|
|
|
const Dashboard = () => {
|
|
return <SwarmMonitorCard />;
|
|
};
|
|
|
|
export default Dashboard;
|
|
|
|
Dashboard.getLayout = (page: ReactElement) => {
|
|
return <DashboardLayout>{page}</DashboardLayout>;
|
|
};
|
|
export async function getServerSideProps(
|
|
ctx: GetServerSidePropsContext<{ serviceId: string }>,
|
|
) {
|
|
if (IS_CLOUD) {
|
|
return {
|
|
redirect: {
|
|
permanent: true,
|
|
destination: "/dashboard/projects",
|
|
},
|
|
};
|
|
}
|
|
const { user, session } = await validateRequest(ctx.req);
|
|
if (!user) {
|
|
return {
|
|
redirect: {
|
|
permanent: true,
|
|
destination: "/",
|
|
},
|
|
};
|
|
}
|
|
const { req, res } = ctx;
|
|
|
|
const helpers = createServerSideHelpers({
|
|
router: appRouter,
|
|
ctx: {
|
|
req: req as any,
|
|
res: res as any,
|
|
db: null as any,
|
|
session: session as any,
|
|
user: user as any,
|
|
},
|
|
transformer: superjson,
|
|
});
|
|
try {
|
|
await helpers.project.all.prefetch();
|
|
|
|
if (user.role === "member") {
|
|
const userR = await helpers.user.one.fetch({
|
|
userId: user.id,
|
|
});
|
|
|
|
if (!userR?.canAccessToDocker) {
|
|
return {
|
|
redirect: {
|
|
permanent: true,
|
|
destination: "/",
|
|
},
|
|
};
|
|
}
|
|
}
|
|
return {
|
|
props: {
|
|
trpcState: helpers.dehydrate(),
|
|
},
|
|
};
|
|
} catch (_error) {
|
|
return {
|
|
props: {},
|
|
};
|
|
}
|
|
}
|