default cluster select

This commit is contained in:
silenceqi 2021-03-07 13:58:27 +08:00
parent 1dc2d95ca7
commit 6ddc5c025c
3 changed files with 26 additions and 4 deletions

View File

@ -21,7 +21,7 @@ export default {
}, },
"created": "2021-02-20T16:03:30.867084+08:00", "created": "2021-02-20T16:03:30.867084+08:00",
"description": "xx业务集群1", "description": "xx业务集群1",
"enabled": false, "enabled": true,
"endpoint": "http://localhost:9200", "endpoint": "http://localhost:9200",
"name": "cluster1", "name": "cluster1",
"updated": "2021-02-20T16:03:30.867084+08:00" "updated": "2021-02-20T16:03:30.867084+08:00"
@ -38,7 +38,7 @@ export default {
}, },
"created": "2021-02-20T16:03:30.867084+08:00", "created": "2021-02-20T16:03:30.867084+08:00",
"description": "xx业务集群2", "description": "xx业务集群2",
"enabled": false, "enabled": true,
"endpoint": "http://localhost:9201", "endpoint": "http://localhost:9201",
"name": "cluster2", "name": "cluster2",
"updated": "2021-02-20T16:03:30.867084+08:00" "updated": "2021-02-20T16:03:30.867084+08:00"

View File

@ -44,7 +44,7 @@ class DropdownSelect extends React.Component{
} }
handleInfiniteOnLoad = (page) => { handleInfiniteOnLoad = (page) => {
let { data } = this.state; let { data } = this.props;
this.setState({ this.setState({
loading: true, loading: true,
}) })

View File

@ -2,6 +2,8 @@ import { queryNotices } from '@/services/api';
import {message} from "antd"; import {message} from "antd";
import {searchClusterConfig} from "@/services/cluster"; import {searchClusterConfig} from "@/services/cluster";
import {formatESSearchResult} from '@/lib/elasticsearch/util'; import {formatESSearchResult} from '@/lib/elasticsearch/util';
import {Modal} from 'antd';
import router from "umi/router";
export default { export default {
@ -47,13 +49,33 @@ export default {
} }
res = formatESSearchResult(res) res = formatESSearchResult(res)
let clusterList = yield select(state => state.global.clusterList); let clusterList = yield select(state => state.global.clusterList);
let data = res.data.map((item)=>{ let data = res.data.filter(item=>item.enabled).map((item)=>{
return { return {
name: item.name, name: item.name,
id: item.id, id: item.id,
}; };
}) })
if(clusterList.length === 0){
if(data.length === 0 ){
Modal.info({
title: '系统提示',
content: '当前没有可用集群,点击确定将自动跳转到 系统设置=>集群设置',
okText: '确定',
onOk() {
router.push('/system/cluster')
},
});
}else{
yield put({
type: 'saveData',
payload:{
selectedCluster: data[0],
}
});
}
}
yield put({ yield put({
type: 'saveData', type: 'saveData',
payload: { payload: {