Service card
This commit is contained in:
@ -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} />
|
||||||
|
|||||||
39
src/components/dashboard/ServiceCard.tsx
Normal file
39
src/components/dashboard/ServiceCard.tsx
Normal 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>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -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>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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} />
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
background-color: whitesmoke;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user