add the configs

This commit is contained in:
mbecker20
2023-07-30 15:51:59 -04:00
parent 750f1fc379
commit b8ad77085c
10 changed files with 102 additions and 11 deletions

View File

@@ -21,7 +21,7 @@ export const DesktopUpdates = () => {
</DropdownMenuTrigger>
<DropdownMenuContent className="w-[500px]">
<DropdownMenuGroup>
{updates?.map((update) => (
{updates?.updates.map((update) => (
<SingleUpdate update={update} />
))}
</DropdownMenuGroup>

View File

@@ -29,7 +29,7 @@ export const ResourceUpdates = ({ id }: { id: string }) => {
</Link>
</div>
<div className="grid md:grid-cols-3 mt-2 gap-4">
{updates?.slice(0, 3).map((update) => (
{updates?.updates.slice(0, 3).map((update) => (
<UpdateDetails update={update} key={update._id?.$oid}>
<Card hoverable>
<CardHeader>

View File

@@ -17,7 +17,7 @@ import {
export const useRead = <
T extends Types.ReadRequest["type"],
P = Extract<Types.WriteRequest, { type: T }>["params"]
P = Extract<Types.ReadRequest, { type: T }>["params"]
>(
type: T,
params: P,

View File

@@ -0,0 +1,23 @@
import { Config } from "@components/config/Config";
import { useRead } from "@hooks";
import { Types } from "@monitor/client";
import { useState } from "react";
import { useParams } from "react-router-dom";
export const BuildConfig = () => {
const id = useParams().buildId;
const build = useRead("GetBuild", { id });
const [update, set] = useState<Partial<Types.BuildConfig>>({});
if (build.data?.config) {
return (
<Config
config={build.data?.config as any}
update={update}
set={set}
/>
);
} else {
// loading
return null;
}
};

View File

@@ -1,8 +1,10 @@
import { useSetRecentlyViewed } from "@hooks";
import { Resource } from "@layouts/resource";
import { BuildName, BuildVersion } from "./util";
import { useParams } from "react-router-dom";
import { Link, useParams } from "react-router-dom";
import { RebuildBuild } from "./components/actions";
import { Button } from "@ui/button";
import { Settings } from "lucide-react";
export const Build = () => {
const { buildId } = useParams();
@@ -19,7 +21,16 @@ export const Build = () => {
<BuildVersion id={buildId} />
</div>
}
actions={<RebuildBuild buildId={buildId} />}
actions={
<div className="flex gap-4">
<RebuildBuild buildId={buildId} />
<Link to={`/builds/${buildId}/config`}>
<Button variant="outline">
<Settings className="w-4 h-4" />
</Button>
</Link>
</div>
}
/>
);
};

View File

@@ -0,0 +1,17 @@
import { Config } from "@components/config/Config"
import { useRead } from "@hooks";
import { Types } from "@monitor/client";
import { useState } from "react"
import { useParams } from "react-router-dom";
export const DeploymentConfig = () => {
const id = useParams().deploymentId;
const deployment = useRead("GetDeployment", { id });
const [update, set] = useState<Partial<Types.DeploymentConfig>>({});
if (deployment.data?.config) {
return <Config config={deployment.data?.config as any} update={update} set={set} />;
} else {
// loading
return null
}
}

View File

@@ -19,7 +19,7 @@ export const DeploymentUpdates = () => {
<TableHead>Success</TableHead>
</TableRow>
</TableHeader>
{updates?.map((update) => (
{updates?.updates.map((update) => (
<TableRow>
<TableCell>{fmt_update_date(new Date(update.start_ts))}</TableCell>
<TableCell>

View File

@@ -0,0 +1,19 @@
import { Config } from "@components/config/Config";
import { useRead } from "@hooks";
import { Types } from "@monitor/client";
import { useState } from "react";
import { useParams } from "react-router-dom";
export const ServerConfig = () => {
const id = useParams().serverId;
const server = useRead("GetServer", { id });
const [update, set] = useState<Partial<Types.ServerConfig>>({});
if (server.data?.config) {
return (
<Config config={server.data?.config as any} update={update} set={set} />
);
} else {
// loading
return null;
}
};

View File

@@ -1,9 +1,11 @@
import { useSetRecentlyViewed } from "@hooks";
import { Resource } from "@layouts/resource";
import { useParams } from "react-router-dom";
import { Link, useParams } from "react-router-dom";
import { ServerName, ServerStats } from "./util";
import { ServerStatusIcon } from "./util";
import { CardDescription } from "@ui/card";
import { Button } from "@ui/button";
import { Settings } from "lucide-react";
export const Server = () => {
const { serverId } = useParams();
@@ -24,7 +26,15 @@ export const Server = () => {
<ServerStats server_id={serverId} />
</div>
}
actions=""
actions={
<div className="flex gap-4">
<Link to={`/servers/${serverId}/config`}>
<Button variant="outline">
<Settings className="w-4 h-4" />
</Button>
</Link>
</div>
}
/>
);
};

View File

@@ -9,6 +9,9 @@ import { Deployments, Builds, Servers, Builders } from "@resources/pages";
import { DeploymentUpdates } from "@resources/deployment/updates";
import { DeploymentLayout } from "@resources/deployment/layout";
import { DeploymentPage } from "@resources/deployment/page";
import { DeploymentConfig } from "@resources/deployment/config";
import { ServerConfig } from "@resources/server/config";
import { BuildConfig } from "@resources/build/config";
const router = createBrowserRouter([
{
@@ -30,7 +33,7 @@ const router = createBrowserRouter([
children: [
{ path: "", element: <DeploymentPage /> },
{ path: "updates", element: <DeploymentUpdates /> },
{ path: "config", element: <>deployment config!</> },
{ path: "config", element: <DeploymentConfig /> },
],
},
],
@@ -41,7 +44,11 @@ const router = createBrowserRouter([
path: "servers",
children: [
{ path: "", element: <Servers /> },
{ path: ":serverId", element: <Server /> },
{
path: ":serverId",
element: <Server />,
children: [{ path: "config", element: <ServerConfig /> }],
},
],
},
@@ -50,7 +57,11 @@ const router = createBrowserRouter([
path: "builds",
children: [
{ path: "", element: <Builds /> },
{ path: ":buildId", element: <Build /> },
{
path: ":buildId",
element: <Build />,
children: [{ path: "config", element: <BuildConfig /> }],
},
],
},