Skip to content

Commit

Permalink
chore: the first metric is selected by default in TopN
Browse files Browse the repository at this point in the history
  • Loading branch information
yaojiping committed Jan 12, 2025
1 parent 7cb3852 commit 9d8400f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions web/src/pages/Platform/Overview/components/TopN/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ export default (props) => {
return true;
}).map((item) => ({ ...item._source }))
setMetrics(newMetrics)
if (newMetrics.length > 0 && (!formData.sourceArea && !formData.sourceColor)) {
const newFormData = {
...cloneDeep(formData),
sourceArea: newMetrics[0],
statisticArea: newMetrics[0]?.items[0]?.statistic,
sourceColor: newMetrics[0],
statisticColor: newMetrics[0].items[0]?.statistic
}
setFormData(newFormData)
fetchData(type, clusterID, timeRange, newFormData)
}
}
setLoading(false)
}
Expand Down Expand Up @@ -283,6 +294,7 @@ export default (props) => {
<Select
style={{ width: "150px", marginBottom: 12 }}
value={formData.sourceArea?.key}
dropdownMatchSelectWidth={false}
onChange={(value, option) => {

if (value) {
Expand Down Expand Up @@ -312,6 +324,7 @@ export default (props) => {
style={{ width: "88px", marginBottom: 12, marginRight: 6 }}
className={styles.borderRadiusRight}
value={formData.statisticArea}
dropdownMatchSelectWidth={false}
onChange={(value) => onFormDataChange({ statisticArea: value })}
>
{
Expand All @@ -333,6 +346,7 @@ export default (props) => {
<Select
style={{ width: "150px", marginBottom: 12 }}
value={formData.sourceColor?.key}
dropdownMatchSelectWidth={false}
onChange={(value, option) => {
if (value) {
const { items = [] } = option?.props?.metric || {}
Expand Down Expand Up @@ -361,6 +375,7 @@ export default (props) => {
<Select
style={{ width: "88px", marginBottom: 12 }}
value={formData.statisticColor}
dropdownMatchSelectWidth={false}
onChange={(value) => onFormDataChange({ statisticColor: value })}
>
{
Expand Down

0 comments on commit 9d8400f

Please sign in to comment.