diff --git a/web/src/pages/Overview/components/Activities/GenerateDesc.jsx b/web/src/pages/Overview/components/Activities/GenerateDesc.jsx index 8542e95d..96b35dfa 100644 --- a/web/src/pages/Overview/components/Activities/GenerateDesc.jsx +++ b/web/src/pages/Overview/components/Activities/GenerateDesc.jsx @@ -1,5 +1,7 @@ import moment from "moment"; import { Link } from "umi"; +import { Icon } from "antd"; +import { useMemo, useState } from "react"; export default (props) => { const { hit, opers } = props; @@ -90,18 +92,7 @@ export default (props) => { > ); case "cluster_health_change": - return ( - <> - health status of cluster{" "} - - {hit._source.metadata.labels.cluster_name} - {" "} - {opers[type]} from {hit._source.metadata.labels.from} to{" "} - {hit._source.metadata.labels.to} - > - ); + return case "node_health_change": return ( <> @@ -222,3 +213,60 @@ export default (props) => { } return <>>; }; + +const ClusterHealthChange = (props) => { + const { hit, type, timeRangeStr } = props; + const status = hit._source.metadata.labels.to + const hasAllocationExplain = status === 'red' + + const [active, setActive] = useState(false) + + const content = ( + { + if (hasAllocationExplain) { + setActive(!active) + } + }} + > + health status of cluster{" "} + + {hit._source.metadata.labels.cluster_name} + {" "} + {type} from {hit._source.metadata.labels.from} to{" "} + {status}{hasAllocationExplain ? ( + { + if (hasAllocationExplain) { + setActive(!active) + } + }} + /> + ) : null} + + ) + + const allocationExplain = useMemo(() => { + if (!hit._source.payload?.cluster_health?.allocation_explain) return {} + try { + const object = JSON.parse(hit._source.payload?.cluster_health?.allocation_explain) + return object + } catch (error) { + return {} + } + }, [hit._source.payload?.cluster_health?.allocation_explain]) + + return active ? ( + + {content} + + {JSON.stringify(allocationExplain, null, 4)} + + + ) : content +}
+ {JSON.stringify(allocationExplain, null, 4)} +