-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use different modules for Trial and Cluster topology (#9917)
- Loading branch information
1 parent
0928958
commit 062cb52
Showing
6 changed files
with
137 additions
and
3 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
webui/react/src/pages/ResourcePool/ClusterTopology.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
.mainContainer { | ||
background-color: var(--theme-surface); | ||
border-radius: var(--theme-border-radius-weak); | ||
box-shadow: 0 1.6px 3.6px 1.6px rgb(0 0 0 / 13%); | ||
color: var(--theme-surface-on); | ||
padding: 30px; | ||
width: 100%; | ||
} | ||
.nodesContainer { | ||
display: flex; | ||
flex-flow: row wrap; | ||
justify-content: flex-start; | ||
|
||
.node { | ||
align-items: flex-start; | ||
color: var(--theme-status-active-strong); | ||
display: flex; | ||
flex-direction: column; | ||
margin-bottom: 20px; | ||
margin-right: 30px; | ||
|
||
.nodeName { | ||
display: inline-block; | ||
font-size: var(--single-line-size-l); | ||
margin-bottom: 6px; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
text-transform: uppercase; | ||
vertical-align: bottom; | ||
white-space: nowrap; | ||
} | ||
.nodeCluster { | ||
align-items: center; | ||
border: 2px solid var(--theme-status-active-strong); | ||
box-sizing: border-box; | ||
display: flex; | ||
justify-content: space-around; | ||
padding: 6px; | ||
|
||
.nodeSlot { | ||
background-color: var(--theme-status-inactive-weak); | ||
height: 20px; | ||
margin-right: 6px; | ||
width: 6px; | ||
|
||
&:last-of-type { | ||
margin-right: 0; | ||
} | ||
} | ||
.singleSlot { | ||
width: 90px; | ||
} | ||
.coupleSlot { | ||
width: 42px; | ||
} | ||
.active { | ||
background-color: var(--theme-status-active-strong); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import Tooltip from 'hew/Tooltip'; | ||
import React, { PropsWithChildren, useEffect, useMemo, useRef, useState } from 'react'; | ||
|
||
import Section from 'components/Section'; | ||
import { Agent, Resource, SlotsRecord } from 'types'; | ||
|
||
import css from './ClusterTopology.module.scss'; | ||
|
||
interface NodeElementProps { | ||
name: string; | ||
resources: Resource[]; | ||
slots?: SlotsRecord; | ||
} | ||
|
||
interface Props { | ||
nodes: Agent[]; | ||
} | ||
|
||
const NodeElement: React.FC<PropsWithChildren<NodeElementProps>> = ({ name, slots, resources }) => { | ||
const [containerWidth, setContainerWidth] = useState(0); | ||
const shouldTruncate = useMemo(() => name.length > 5, [name]); | ||
const slotsContainer = useRef<HTMLSpanElement>(null); | ||
const slotsData = useMemo( | ||
() => (slots !== undefined ? Object.values(slots) : resources), | ||
[slots, resources], | ||
); | ||
const singleSlot = slotsData.length === 1; | ||
const coupleSlot = slotsData.length === 2; | ||
const styles = [css.nodeSlot]; | ||
|
||
if (singleSlot) styles.push(css.singleSlot); | ||
if (coupleSlot) styles.push(css.coupleSlot); | ||
|
||
useEffect(() => { | ||
setContainerWidth(slotsContainer.current?.getBoundingClientRect().width || 0); | ||
}, []); | ||
|
||
return ( | ||
<div className={css.node}> | ||
{shouldTruncate ? ( | ||
<Tooltip content={name}> | ||
<span className={css.nodeName} style={{ maxWidth: containerWidth }}> | ||
{name} | ||
</span> | ||
</Tooltip> | ||
) : ( | ||
<span className={css.nodeName}>{name}</span> | ||
)} | ||
<span className={css.nodeCluster} ref={slotsContainer}> | ||
{slotsData.map(({ container }, idx) => ( | ||
<span | ||
className={`${styles.join(' ')} ${container ? css.active : ''}`} | ||
key={`slot${idx}`} | ||
/> | ||
))} | ||
</span> | ||
</div> | ||
); | ||
}; | ||
|
||
const Topology: React.FC<PropsWithChildren<Props>> = ({ nodes }) => { | ||
return ( | ||
<Section title="Topology"> | ||
<div className={`${css.mainContainer} ${css.nodesContainer}`}> | ||
{nodes.map(({ id, resources, slots }) => { | ||
return <NodeElement key={id} name={id} resources={resources} slots={slots} />; | ||
})} | ||
</div> | ||
</Section> | ||
); | ||
}; | ||
|
||
export default Topology; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters