Service card

This commit is contained in:
Eden Kirin
2024-01-24 22:43:12 +01:00
parent 490f2bdde6
commit d5374545f7
6 changed files with 57 additions and 12 deletions

View File

@ -11,8 +11,11 @@ interface EnvironmentListProps {
export default function EnvironmentList({ environments }: EnvironmentListProps) { export default function EnvironmentList({ environments }: EnvironmentListProps) {
const envItems = environments.map((env) => { const envItems = environments.map((env) => {
return ( return (
<Box className="environment"> <Box className="environment" sx={{ marginBottom: "2rem" }}>
<Typography component={"h1"} key={env.name} className="title"> <Typography variant={"h2"} key={env.name} className="title">
<Typography component="span" variant={"h5"} key={env.name} sx={{ marginRight: "1rem" }}>
environment:
</Typography>
{env.name} {env.name}
</Typography> </Typography>
<TenantList tenants={env.tenants} /> <TenantList tenants={env.tenants} />

View File

@ -0,0 +1,39 @@
import React from "react";
import { Service, Node } from "../../types";
import Typography from "@mui/material/Typography";
import Card from "@mui/material/Card";
import CardContent from "@mui/material/CardContent";
import Grid from "@mui/material/Unstable_Grid2";
interface ServiceCardProps {
service: Service;
}
function normalizeServiceName(name: string): string {
// convert ugly CLOUD_INTEGRATION_SERVICE to Cloud Integration Service
return name
.replaceAll("_", " ")
.toLowerCase()
.replace(/\b\w/g, (s) => s.toUpperCase());
}
function ServiceNode(node: Node) {
return <Typography variant="h6">{node.name}</Typography>;
}
export default function ServiceCard({ service }: ServiceCardProps) {
const nodes = service.nodes.map((node) => {
return ServiceNode(node);
});
return (
<Card className="service-card" sx={{ width: "400px" }}>
<CardContent>
<Typography variant="h5" component="div">
{normalizeServiceName(service.name)}
</Typography>
{nodes}
</CardContent>
</Card>
);
}

View File

@ -1,7 +1,7 @@
import React from "react"; import React from "react";
import { Service } from "../../types"; import { Service } from "../../types";
import Box from "@mui/material/Box"; import Grid from "@mui/material/Unstable_Grid2";
import Typography from "@mui/material/Typography"; import ServiceCard from "./ServiceCard";
interface ServiceListProps { interface ServiceListProps {
services: Service[]; services: Service[];
@ -10,13 +10,15 @@ interface ServiceListProps {
export default function ServiceList({ services }: ServiceListProps) { export default function ServiceList({ services }: ServiceListProps) {
const serviceItems = services.map((service) => { const serviceItems = services.map((service) => {
return ( return (
<Box className="service-card"> <Grid key={service.name} sx={{ display: "flex" }}>
<Typography component={"h1"} key={service.name} className="service-name"> <ServiceCard service={service} />
{service.name} </Grid>
</Typography>
</Box>
); );
}); });
return <Box className="service-list">{serviceItems}</Box>; return (
<Grid container rowSpacing={2} columnSpacing={2} className="service-list" sx={{ marginBottom: "1rem" }}>
{serviceItems}
</Grid>
);
} }

View File

@ -13,7 +13,7 @@ export default function TenantList({ tenants: tenants }: TenantListProps) {
const tenantName = tenant.name !== "default" ? `Tenant: ${tenant.name}` : "Multitenant"; const tenantName = tenant.name !== "default" ? `Tenant: ${tenant.name}` : "Multitenant";
return ( return (
<Box className="tenant"> <Box className="tenant">
<Typography component={"h1"} key={tenant.name} className="tenant-name"> <Typography variant={"h3"} key={tenant.name} className="tenant-name" sx={{ marginBottom: "1rem" }}>
{tenantName} {tenantName}
</Typography> </Typography>
<ServiceList services={tenant.services} /> <ServiceList services={tenant.services} />

View File

@ -1,3 +1,4 @@
body { body {
margin: 0; margin: 0;
background-color: whitesmoke;
} }

View File

@ -19,7 +19,7 @@ type AppDetails = {
template_version: string | null; template_version: string | null;
}; };
type Node = { export type Node = {
name: string; name: string;
url: string; url: string;
app_details: AppDetails | null; app_details: AppDetails | null;