cleanup for build

This commit is contained in:
karamvir
2023-08-10 22:46:00 -07:00
parent df302015a3
commit bec8b3ce0f
8 changed files with 16 additions and 21 deletions

View File

@@ -1,6 +1,6 @@
import { ConfirmUpdate } from "@components/config/confirm-update";
import { Button } from "@ui/button";
import { Settings, Save, History } from "lucide-react";
import { Settings, History } from "lucide-react";
import { ReactNode } from "react";
interface PageProps {

View File

@@ -6,10 +6,12 @@ import { ServerStatus } from "@monitor/client/dist/types";
export const ServersChart = () => {
const { data } = useRead("ListServers", {});
const running = data?.filter((d) => d.status === ServerStatus.Ok).length;
const stopped = data?.filter((d) => d.status === ServerStatus.NotOk).length;
const running = data?.filter((d) => d.info.status === ServerStatus.Ok).length;
const stopped = data?.filter(
(d) => d.info.status === ServerStatus.NotOk
).length;
const not_deployed = data?.filter(
(d) => d.status === ServerStatus.Disabled
(d) => d.info.status === ServerStatus.Disabled
).length;
return (

View File

@@ -32,7 +32,7 @@ export const AlerterCard = ({ id }: { id: string }) => {
<Link to={`/alerters/${id}`}>
<ResourceCard
title={alerter.name}
description={`${alerter.alerter_type} alerter`}
description={`${alerter.info.alerter_type} alerter`}
statusIcon={<AlarmClock className="w-4 h-4" />}
>
<div></div>

View File

@@ -41,7 +41,7 @@ export const BuildCard = ({ id }: { id: string }) => {
<Link to={`/builds/${build.id}`} key={build.id}>
<ResourceCard
title={build.name}
description={version_to_string(build.version) ?? "not built"}
description={version_to_string(build.info.version) ?? "not built"}
statusIcon={<Hammer className="w-4 h-4" />}
>
<BuildInfo id={id} />

View File

@@ -11,7 +11,7 @@ export const BuildName = ({ id }: { id: string | undefined }) => {
export const BuildVersion = ({ id }: { id: string }) => {
const builds = useRead("ListBuilds", {}).data;
const build = builds?.find((b) => b.id === id);
return <>{version_to_string(build?.version) ?? "..."}</>;
return <>{version_to_string(build?.info.version) ?? "..."}</>;
};
export const BuildBuilder = ({ id }: { id: string }) => {
@@ -23,7 +23,7 @@ export const BuildBuilder = ({ id }: { id: string }) => {
export const BuildLastBuilt = ({ id }: { id: string }) => {
const builds = useRead("ListBuilds", {}).data;
const build = builds?.find((b) => b.id === id);
const last = build?.last_built_at;
const last = build?.info.last_built_at;
return <>{last ? new Date(last).toLocaleString() : "not yet built"}</>;
};

View File

@@ -14,7 +14,7 @@ export const RedeployContainer = ({ deployment_id }: DeploymentId) => {
const deployment = deployments?.find((d) => d.id === deployment_id);
return (
<ConfirmButton
title={deployment?.status ? "Redeploy" : "Deploy"}
title={deployment?.info.status ? "Redeploy" : "Deploy"}
intent="success"
icon={<Rocket className="h-4 w-4" />}
onClick={() => mutate({ deployment_id })}
@@ -61,9 +61,9 @@ export const StartOrStopContainer = ({ deployment_id }: DeploymentId) => {
const deployments = useRead("ListDeployments", {}).data;
const deployment = deployments?.find((d) => d.id === deployment_id);
if (deployment?.state === DockerContainerState.NotDeployed) return null;
if (deployment?.info.state === DockerContainerState.NotDeployed) return null;
if (deployment?.state === DockerContainerState.Running)
if (deployment?.info.state === DockerContainerState.Running)
return <StopContainer deployment_id={deployment_id} />;
return <StartContainer deployment_id={deployment_id} />;
};
@@ -74,7 +74,7 @@ export const RemoveContainer = ({ deployment_id }: DeploymentId) => {
const deployments = useRead("ListDeployments", {}).data;
const deployment = deployments?.find((d) => d.id === deployment_id);
if (deployment?.state === DockerContainerState.NotDeployed) return null;
if (deployment?.info.state === DockerContainerState.NotDeployed) return null;
if (!d) return null;
return (

View File

@@ -23,7 +23,7 @@ export const DeploymentLogs = ({
const deployments = useRead("ListDeployments", {}).data;
const deployment = deployments?.find((d) => d.id === deployment_id);
if (deployment?.state === DockerContainerState.NotDeployed) return null;
if (deployment?.info.state === DockerContainerState.NotDeployed) return null;
return (
<Tabs defaultValue="stdout">

View File

@@ -5,13 +5,6 @@ import { useRead, useWrite } from "@hooks";
import { Section } from "@layouts/page";
import { Types } from "@monitor/client";
import { Button } from "@ui/button";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@ui/card";
import { Input } from "@ui/input";
import { Settings, Save, History } from "lucide-react";
import { useState } from "react";
@@ -21,7 +14,7 @@ type ServerUpdate = Partial<Types.ServerConfig>;
export const SerCon = ({ id }: { id: string }) => {
const config = useRead("GetServer", { id }).data?.config;
const { mutate, isLoading } = useWrite("UpdateServer");
const { mutate } = useWrite("UpdateServer");
const [update, set] = useState<ServerUpdate>({});
const up = <K extends keyof Types.ServerConfig, V = Types.ServerConfig[K]>(
k: K,