|
| 1 | +import React from 'react'; |
| 2 | +import { Card, CardTitle, CardBody, CardFooter, CardHeader, CardExpandableContent } from '@patternfly/react-core'; |
| 3 | +import { Grid, GridItem } from '@patternfly/react-core'; |
| 4 | +import { Spinner } from '@patternfly/react-core'; |
| 5 | +import { formatTime } from '../../helpers/Formatters' |
| 6 | +import { FaCheck, FaExclamationCircle, FaExclamationTriangle } from "react-icons/fa"; |
| 7 | +import { DisplaySplunk } from '../commons/DisplaySplunk'; |
| 8 | + |
| 9 | + |
| 10 | +export default function InstallCard(props) { |
| 11 | + let config = props.data |
| 12 | + const [isExpanded, setExpanded] = React.useState([true, null]) |
| 13 | + |
| 14 | + |
| 15 | + const onExpand = () => { |
| 16 | + setExpanded(!isExpanded) |
| 17 | + }; |
| 18 | + |
| 19 | + const icons = { |
| 20 | + "failed": <><FaExclamationCircle color="red"/></>, |
| 21 | + "success": <><FaCheck color="green"/></>, |
| 22 | + "upstream_failed": <><FaExclamationTriangle color="yellow"/></>, |
| 23 | + |
| 24 | + } |
| 25 | + |
| 26 | + if (config) { |
| 27 | + return ( |
| 28 | + <Card isExpanded={isExpanded}> |
| 29 | + <CardHeader |
| 30 | + onExpand={onExpand} |
| 31 | + toggleButtonProps={{ |
| 32 | + id: 'toggle-button', |
| 33 | + 'aria-label': 'Details', |
| 34 | + 'aria-labelledby': 'titleId toggle-button', |
| 35 | + 'aria-expanded': isExpanded |
| 36 | + }} |
| 37 | + > |
| 38 | + <CardTitle>Configs</CardTitle> |
| 39 | + |
| 40 | + </CardHeader> |
| 41 | + <CardExpandableContent> |
| 42 | + <CardBody> |
| 43 | + <Grid> |
| 44 | + <GridItem rowSpan="1"> |
| 45 | + <Card><CardHeader><CardTitle>Cluster Metadata</CardTitle></CardHeader> |
| 46 | + <CardBody> |
| 47 | + <ul> |
| 48 | + <li><span class="list-item-key">Release Binary</span>: {config.cluster_version && config.cluster_version || config.ocpVersion}</li> |
| 49 | + <li><span class="list-item-key">Cluster Name</span>: {config.cluster_name && config.cluster_name || config.nodeName}</li> |
| 50 | + <li><span class="list-item-key">Cluster Type</span>: {config.cluster_type && config.cluster_type || "SNO spoke"}</li> |
| 51 | + <li><span class="list-item-key">Network Type</span>: {config.network_type && config.network_type || "OVNKubernetes"}</li> |
| 52 | + <li><span class="list-item-key">CPU</span>: {config.cpu_version && config.cpu_version || config.cpu}</li> |
| 53 | + <li><span class="list-item-key">Kernel</span>: {config.kernel_version && config.kernel_version || config.kernel}</li> |
| 54 | + <li><span class="list-item-key">IsFormal</span>: {config.is_formal && config.is_formal || config.formal}</li> |
| 55 | + <li><span class="list-item-key">Benchmark Status</span>: {icons[config.job_status && config.job_status || config.jobStatus] || config.job_status && config.job_status || config.jobStatus}</li> |
| 56 | + <li><span class="list-item-key">Duration</span>: {formatTime(config.job_duration && config.job_duration || config.jobDuration)}</li> |
| 57 | + </ul> |
| 58 | + </CardBody> |
| 59 | + </Card> |
| 60 | + </GridItem> |
| 61 | + <DisplaySplunk benchmarkConfigs={ config } /> |
| 62 | + <GridItem span="6"> |
| 63 | + <Card><CardHeader><CardTitle>Node Types</CardTitle></CardHeader> |
| 64 | + <CardBody> |
| 65 | + <ul> |
| 66 | + <li><span class="list-item-key">Master</span>: {config.master_type && config.master_type || "Baremetal"}</li> |
| 67 | + <li><span class="list-item-key">Workload</span>: {config.workload_type && config.workload_type || config.benchmark}</li> |
| 68 | + </ul> |
| 69 | + </CardBody> |
| 70 | + </Card> |
| 71 | + </GridItem> |
| 72 | + <GridItem span="6"> |
| 73 | + <Card><CardHeader><CardTitle>Node Counts</CardTitle></CardHeader> |
| 74 | + <CardBody> |
| 75 | + <ul> |
| 76 | + <li><span class="list-item-key">Master</span>: {config.master_count && config.master_count || "1"}</li> |
| 77 | + <li><span class="list-item-key">Total Nodes</span>: {config.workload_count && config.workload_count || "1"}</li> |
| 78 | + </ul> |
| 79 | + </CardBody> |
| 80 | + </Card> |
| 81 | + </GridItem> |
| 82 | + </Grid> |
| 83 | + </CardBody></CardExpandableContent> |
| 84 | + |
| 85 | + |
| 86 | + </Card>) |
| 87 | + } else { |
| 88 | + return ( |
| 89 | + <Card> |
| 90 | + <CardTitle>Install Configuration</CardTitle> |
| 91 | + <CardBody><Spinner isSVG /><br />Awaiting Results</CardBody> |
| 92 | + <CardFooter></CardFooter> |
| 93 | + </Card> |
| 94 | + ) |
| 95 | + } |
| 96 | + |
| 97 | +} |
0 commit comments