|
2 | 2 | convertBinarySizeUnit, |
3 | 3 | toFixedFloorWithoutTrailingZeros, |
4 | 4 | } from '../helper'; |
| 5 | +import { useResourceSlotsDetails } from '../hooks/backendai'; |
5 | 6 | import BAICard from './BAICard'; |
6 | 7 | import { |
7 | 8 | SessionMetricGraphQuery, |
@@ -68,6 +69,7 @@ const SessionMetricGraph: React.FC<PrometheusMetricGraphProps> = ({ |
68 | 69 | }) => { |
69 | 70 | const { token } = theme.useToken(); |
70 | 71 | const { styles } = useStyle(); |
| 72 | + const { mergedResourceSlots } = useResourceSlotsDetails(); |
71 | 73 |
|
72 | 74 | const { capacity_metric, current_metric } = |
73 | 75 | useLazyLoadQuery<SessionMetricGraphQuery>( |
@@ -142,9 +144,22 @@ const SessionMetricGraph: React.FC<PrometheusMetricGraphProps> = ({ |
142 | 144 | dayDiff < 7 ? '5m' : dayDiff < 30 ? '1h' : '1d', |
143 | 145 | ); |
144 | 146 |
|
| 147 | + const getMetricTitle = () => { |
| 148 | + const [key, ...rest] = _.split(metricName, '_'); |
| 149 | + const restLabel = _.startCase(rest.join(' ')); |
| 150 | + |
| 151 | + if (_.has(mergedResourceSlots, key)) { |
| 152 | + return `${mergedResourceSlots[key]?.human_readable_name} ${restLabel}`; |
| 153 | + } |
| 154 | + if (_.includes(metricName, 'io')) { |
| 155 | + return `${_.upperCase(key)} ${restLabel}`; |
| 156 | + } |
| 157 | + return `${_.startCase(metricName.replaceAll('_', ' '))}`; |
| 158 | + }; |
| 159 | + |
145 | 160 | return ( |
146 | 161 | <BAICard |
147 | | - title={_.startCase(metricName.replaceAll('_', ' '))} |
| 162 | + title={getMetricTitle()} |
148 | 163 | type="inner" |
149 | 164 | styles={{ |
150 | 165 | body: { |
|
0 commit comments