chore: the first metric is selected by default in TopN (#81)
Co-authored-by: yaojiping <yaojiping@infini.ltd>
This commit is contained in:
parent
7cb3852b27
commit
fb4dafecb3
|
@ -52,6 +52,17 @@ export default (props) => {
|
||||||
return true;
|
return true;
|
||||||
}).map((item) => ({ ...item._source }))
|
}).map((item) => ({ ...item._source }))
|
||||||
setMetrics(newMetrics)
|
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)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
@ -283,6 +294,7 @@ export default (props) => {
|
||||||
<Select
|
<Select
|
||||||
style={{ width: "150px", marginBottom: 12 }}
|
style={{ width: "150px", marginBottom: 12 }}
|
||||||
value={formData.sourceArea?.key}
|
value={formData.sourceArea?.key}
|
||||||
|
dropdownMatchSelectWidth={false}
|
||||||
onChange={(value, option) => {
|
onChange={(value, option) => {
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
|
@ -312,6 +324,7 @@ export default (props) => {
|
||||||
style={{ width: "88px", marginBottom: 12, marginRight: 6 }}
|
style={{ width: "88px", marginBottom: 12, marginRight: 6 }}
|
||||||
className={styles.borderRadiusRight}
|
className={styles.borderRadiusRight}
|
||||||
value={formData.statisticArea}
|
value={formData.statisticArea}
|
||||||
|
dropdownMatchSelectWidth={false}
|
||||||
onChange={(value) => onFormDataChange({ statisticArea: value })}
|
onChange={(value) => onFormDataChange({ statisticArea: value })}
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
|
@ -333,6 +346,7 @@ export default (props) => {
|
||||||
<Select
|
<Select
|
||||||
style={{ width: "150px", marginBottom: 12 }}
|
style={{ width: "150px", marginBottom: 12 }}
|
||||||
value={formData.sourceColor?.key}
|
value={formData.sourceColor?.key}
|
||||||
|
dropdownMatchSelectWidth={false}
|
||||||
onChange={(value, option) => {
|
onChange={(value, option) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
const { items = [] } = option?.props?.metric || {}
|
const { items = [] } = option?.props?.metric || {}
|
||||||
|
@ -361,6 +375,7 @@ export default (props) => {
|
||||||
<Select
|
<Select
|
||||||
style={{ width: "88px", marginBottom: 12 }}
|
style={{ width: "88px", marginBottom: 12 }}
|
||||||
value={formData.statisticColor}
|
value={formData.statisticColor}
|
||||||
|
dropdownMatchSelectWidth={false}
|
||||||
onChange={(value) => onFormDataChange({ statisticColor: value })}
|
onChange={(value) => onFormDataChange({ statisticColor: value })}
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue