diff --git a/api/index_management/document.go b/api/index_management/document.go index 8cbd7e1e..9d938a5c 100644 --- a/api/index_management/document.go +++ b/api/index_management/document.go @@ -21,92 +21,91 @@ type docReqBody struct { } func (handler APIHandler) HandleAddDocumentAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { - client := elastic.GetClient(handler.Config.Elasticsearch) + targetClusterID := ps.ByName("id") + client := elastic.GetClient(targetClusterID) reqBody := map[string]interface{}{} - resResult := newResponseBody() + resBody := newResponseBody() err := handler.DecodeJSON(req, &reqBody) if err != nil { - resResult["status"] = false - resResult["error"] = err.Error() - handler.WriteJSON(w, resResult, http.StatusOK) + resBody["error"] = err.Error() + handler.WriteJSON(w, resBody, http.StatusOK) return } indexName := ps.ByName("index") - id := ps.ByName("id") - if strings.Trim(id, "/") == "" { - id = util.GetUUID() + docID := ps.ByName("docId") + if strings.Trim(docID, "/") == "" { + docID = util.GetUUID() } docType := handler.GetParameter(req, "_type") - _, err = client.Index(indexName, docType, id, reqBody) + insertRes, err := client.Index(indexName, docType, docID, reqBody) if err != nil { - resResult["status"] = false - resResult["error"] = err - handler.WriteJSON(w, resResult, http.StatusOK) + resBody["error"] = err + handler.WriteJSON(w, resBody, http.StatusOK) return } - reqBody["id"] = id - resResult["payload"] = reqBody - handler.WriteJSON(w, resResult, http.StatusOK) + reqBody["_id"] = docID + resBody["result"] = insertRes.Result + handler.WriteJSON(w, resBody, http.StatusOK) } func (handler APIHandler) HandleUpdateDocumentAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { - client := elastic.GetClient(handler.Config.Elasticsearch) + targetClusterID := ps.ByName("id") + client := elastic.GetClient(targetClusterID) + resBody := newResponseBody() + if client == nil { + resBody["error"] = "can not found target cluster" + handler.WriteJSON(w, resBody, http.StatusOK) + return + } reqBody := map[string]interface{}{} - resResult := newResponseBody() + err := handler.DecodeJSON(req, &reqBody) if err != nil { - resResult["status"] = false - resResult["error"] = err - handler.WriteJSON(w, resResult, http.StatusOK) + resBody["error"] = err + handler.WriteJSON(w, resBody, http.StatusOK) return } indexName := ps.ByName("index") - id := ps.ByName("id") + docID := ps.ByName("docId") typ := handler.GetParameter(req, "_type") - resp, err := client.Get(indexName,typ, id) + insertRes, err := client.Index(indexName, typ, docID, reqBody) if err != nil { - resResult["status"] = false - resResult["error"] = err.Error() - handler.WriteJSON(w, resResult, http.StatusOK) + resBody["error"] = err.Error() + handler.WriteJSON(w, resBody, http.StatusOK) return } - source := resp.Source - for k, v := range reqBody { - if k == "id" { - continue - } - source[k] = v - } - _, err = client.Index(indexName, typ, id, source) - if err != nil { - resResult["status"] = false - resResult["error"] = err.Error() - handler.WriteJSON(w, resResult, http.StatusOK) - return - } - resResult["payload"] = reqBody - handler.WriteJSON(w, resResult, http.StatusOK) + resBody["_source"] = reqBody + resBody["_id"] = docID + resBody["result"] = insertRes.Result + handler.WriteJSON(w, resBody, http.StatusOK) } func (handler APIHandler) HandleDeleteDocumentAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { - client := elastic.GetClient(handler.Config.Elasticsearch) - resResult := newResponseBody() - indexName := ps.ByName("index") - id := ps.ByName("id") - typ := handler.GetParameter(req, "_type") - _, err := client.Delete(indexName, typ, id) - if err != nil { - resResult["error"] = err.Error() - resResult["status"] = false - handler.WriteJSON(w, resResult, http.StatusOK) + targetClusterID := ps.ByName("id") + client := elastic.GetClient(targetClusterID) + resBody := newResponseBody() + if client == nil { + resBody["error"] = "can not found target cluster" + handler.WriteJSON(w, resBody, http.StatusOK) return } - resResult["payload"] = true - handler.WriteJSON(w, resResult, http.StatusOK) + + indexName := ps.ByName("index") + docID := ps.ByName("docId") + typ := handler.GetParameter(req, "_type") + delRes, err := client.Delete(indexName, typ, docID, "wait_for") + if err != nil { + resBody["error"] = err.Error() + handler.WriteJSON(w, resBody, http.StatusOK) + return + } + resBody["result"] = delRes.Result + handler.WriteJSON(w, resBody, http.StatusOK) } func (handler APIHandler) HandleSearchDocumentAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { - client := elastic.GetClient(handler.Config.Elasticsearch) + targetClusterID := ps.ByName("id") + client := elastic.GetClient(targetClusterID) reqBody := docReqBody{} resResult := newResponseBody() err := handler.DecodeJSON(req, &reqBody) diff --git a/api/index_management/elasticsearch.go b/api/index_management/elasticsearch.go index ece9809e..ac98907d 100644 --- a/api/index_management/elasticsearch.go +++ b/api/index_management/elasticsearch.go @@ -2,13 +2,13 @@ package index_management import ( "fmt" + log "github.com/cihub/seelog" httprouter "infini.sh/framework/core/api/router" "infini.sh/framework/core/elastic" "infini.sh/framework/core/orm" "infini.sh/framework/core/util" "infini.sh/framework/modules/elastic/common" "net/http" - log "github.com/cihub/seelog" ) func (handler APIHandler) ElasticsearchOverviewAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { @@ -49,6 +49,7 @@ func (handler APIHandler) ElasticsearchOverviewAction(w http.ResponseWriter, req } return true }) + resBody := util.MapStr{ "total_node": totalNode, "total_store_size_in_bytes": totalStoreSize, diff --git a/api/index_management/indices.go b/api/index_management/indices.go index a0f44ae0..8b21459c 100644 --- a/api/index_management/indices.go +++ b/api/index_management/indices.go @@ -1,15 +1,15 @@ package index_management import ( - "net/http" - "strings" - httprouter "infini.sh/framework/core/api/router" "infini.sh/framework/core/elastic" + "infini.sh/framework/core/util" + "net/http" ) func (handler APIHandler) HandleGetMappingsAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { - client := elastic.GetClient(handler.Config.Elasticsearch) + targetClusterID := ps.ByName("id") + client := elastic.GetClient(targetClusterID) indexName := ps.ByName("index") resBody := newResponseBody() var copyAll = false @@ -20,114 +20,102 @@ func (handler APIHandler) HandleGetMappingsAction(w http.ResponseWriter, req *ht _, _, idxs, err := client.GetMapping(copyAll, indexName) if err != nil { resBody["error"] = err - resBody["status"] = false handler.WriteJSON(w, resBody, http.StatusOK) return } - if copyAll { - for key, _ := range *idxs { - if strings.HasPrefix(key, ".") || strings.HasPrefix(key, "infini-") { - delete(*idxs, key) - } - } - } + //if copyAll { + // for key, _ := range *idxs { + // if strings.HasPrefix(key, ".") || strings.HasPrefix(key, "infini-") { + // delete(*idxs, key) + // } + // } + //} - resBody["payload"] = idxs - - handler.WriteJSON(w, resBody, http.StatusOK) + handler.WriteJSON(w, idxs, http.StatusOK) } func (handler APIHandler) HandleGetIndicesAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { - client := elastic.GetClient(handler.Config.Elasticsearch) + targetClusterID := ps.ByName("id") + client := elastic.GetClient(targetClusterID) catIndices, err := client.GetIndices("") - for key, _ := range *catIndices { - if strings.HasPrefix(key,".") || strings.HasPrefix(key, "infini-"){ - delete(*catIndices, key) - } - } - resBody := newResponseBody() + resBody := util.MapStr{} if err != nil { - resBody["status"] = false resBody["error"] = err handler.WriteJSON(w, resBody, http.StatusOK) return } - resBody["payload"] = catIndices - handler.WriteJSON(w, resBody, http.StatusOK) + handler.WriteJSON(w, catIndices, http.StatusOK) } func (handler APIHandler) HandleGetSettingsAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { - client := elastic.GetClient(handler.Config.Elasticsearch) + targetClusterID := ps.ByName("id") + client := elastic.GetClient(targetClusterID) indexName := ps.ByName("index") resBody := newResponseBody() indexes, err := client.GetIndexSettings(indexName) if err != nil { - resBody["status"] = false resBody["error"] = err handler.WriteJSON(w, resBody, http.StatusOK) return } - resBody["payload"] = indexes - handler.WriteJSON(w, resBody, http.StatusOK) + handler.WriteJSON(w, indexes, http.StatusOK) } func (handler APIHandler) HandleUpdateSettingsAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { - client := elastic.GetClient(handler.Config.Elasticsearch) + targetClusterID := ps.ByName("id") + client := elastic.GetClient(targetClusterID) indexName := ps.ByName("index") settings := map[string]interface{}{} resBody := newResponseBody() err := handler.DecodeJSON(req, &settings) if err != nil { - resBody["status"] = false resBody["error"] = err handler.WriteJSON(w, resBody, http.StatusOK) return } err = client.UpdateIndexSettings(indexName, settings) if err != nil { - resBody["status"] = false resBody["error"] = err handler.WriteJSON(w, resBody, http.StatusOK) return } - resBody["payload"] = true + resBody["result"] = "updated" handler.WriteJSON(w, resBody, http.StatusOK) } func (handler APIHandler) HandleDeleteIndexAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { - client := elastic.GetClient(handler.Config.Elasticsearch) + targetClusterID := ps.ByName("id") + client := elastic.GetClient(targetClusterID) indexName := ps.ByName("index") resBody := newResponseBody() err := client.DeleteIndex(indexName) if err != nil { - resBody["status"] = false resBody["error"] = err handler.WriteJSON(w, resBody, http.StatusOK) return } - resBody["payload"] = true + resBody["result"] = "deleted" handler.WriteJSON(w, resBody, http.StatusOK) } func (handler APIHandler) HandleCreateIndexAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { - client := elastic.GetClient(handler.Config.Elasticsearch) + targetClusterID := ps.ByName("id") + client := elastic.GetClient(targetClusterID) indexName := ps.ByName("index") resBody := newResponseBody() config := map[string]interface{}{} err := handler.DecodeJSON(req, &config) if err != nil { - resBody["status"] = false resBody["error"] = err handler.WriteJSON(w, resBody, http.StatusOK) return } err = client.CreateIndex(indexName, config) if err != nil { - resBody["status"] = false resBody["error"] = err handler.WriteJSON(w, resBody, http.StatusOK) return } - resBody["payload"] = true + resBody["result"] = "created" handler.WriteJSON(w, resBody, http.StatusOK) } diff --git a/api/init.go b/api/init.go index 8183eeb7..47b38f57 100644 --- a/api/init.go +++ b/api/init.go @@ -16,6 +16,7 @@ func Init(cfg *config.AppConfig) { Config: cfg, } var pathPrefix = "/_search-center/" + var esPrefix = "/elasticsearch/:id/" //ui.HandleUIMethod(api.POST, "/api/get_indices",index_management.API1) ui.HandleUIMethod(api.GET, path.Join(pathPrefix, "elasticsearch/overview"), handler.ElasticsearchOverviewAction) @@ -24,20 +25,21 @@ func Init(cfg *config.AppConfig) { //ui.HandleUIMethod(api.GET, "/api/dict/:id",handler.GetDictItemAction) ui.HandleUIMethod(api.DELETE, path.Join(pathPrefix, "dict/:id"), handler.DeleteDictItemAction) ui.HandleUIMethod(api.PUT, path.Join(pathPrefix, "dict/:id"), handler.UpdateDictItemAction) - ui.HandleUIMethod(api.POST, path.Join(pathPrefix, "doc/:index/_search"), handler.HandleSearchDocumentAction) - ui.HandleUIMethod(api.POST, path.Join(pathPrefix, "doc/:index/_create"), handler.HandleAddDocumentAction) - ui.HandleUIMethod(api.PUT, path.Join(pathPrefix, "doc/:index/:id"), handler.HandleUpdateDocumentAction) - ui.HandleUIMethod(api.DELETE, path.Join(pathPrefix, "doc/:index/:id"), handler.HandleDeleteDocumentAction) + ui.HandleUIMethod(api.POST, path.Join(esPrefix, "doc/:index/_search"), handler.HandleSearchDocumentAction) + ui.HandleUIMethod(api.POST, path.Join(esPrefix, "doc/:index"), handler.HandleAddDocumentAction) + ui.HandleUIMethod(api.PUT, path.Join(esPrefix, "doc/:index/:docId"), handler.HandleUpdateDocumentAction) + ui.HandleUIMethod(api.DELETE, path.Join(esPrefix, "doc/:index/:docId"), handler.HandleDeleteDocumentAction) ui.HandleUIMethod(api.POST, path.Join(pathPrefix, "rebuild/*id"), handler.HandleReindexAction) ui.HandleUIMethod(api.GET, path.Join(pathPrefix, "rebuild/_search"), handler.HandleGetRebuildListAction) ui.HandleUIMethod(api.DELETE, path.Join(pathPrefix, "rebuild/:id"), handler.HandleDeleteRebuildAction) - ui.HandleUIMethod(api.GET, path.Join(pathPrefix, "_cat/indices"), handler.HandleGetIndicesAction) - ui.HandleUIMethod(api.GET, path.Join(pathPrefix, "index/:index/_mappings"), handler.HandleGetMappingsAction) - ui.HandleUIMethod(api.GET, path.Join(pathPrefix, "index/:index/_settings"), handler.HandleGetSettingsAction) - ui.HandleUIMethod(api.PUT, path.Join(pathPrefix, "index/:index/_settings"), handler.HandleUpdateSettingsAction) - ui.HandleUIMethod(api.DELETE, path.Join(pathPrefix, "index/:index"), handler.HandleDeleteIndexAction) - ui.HandleUIMethod(api.POST, path.Join(pathPrefix, "index/:index"), handler.HandleCreateIndexAction) + + ui.HandleUIMethod(api.GET, path.Join(esPrefix, "_cat/indices"), handler.HandleGetIndicesAction) + ui.HandleUIMethod(api.GET, path.Join(esPrefix, "index/:index/_mappings"), handler.HandleGetMappingsAction) + ui.HandleUIMethod(api.GET, path.Join(esPrefix, "index/:index/_settings"), handler.HandleGetSettingsAction) + ui.HandleUIMethod(api.PUT, path.Join(esPrefix, "index/:index/_settings"), handler.HandleUpdateSettingsAction) + ui.HandleUIMethod(api.DELETE, path.Join(esPrefix, "index/:index"), handler.HandleDeleteIndexAction) + ui.HandleUIMethod(api.POST, path.Join(esPrefix, "index/:index"), handler.HandleCreateIndexAction) //new api ui.HandleUIMethod(api.GET, path.Join(pathPrefix, "alerting/overview"), alerting.GetAlertOverview) diff --git a/web/config/router.config.js b/web/config/router.config.js index 0a975c31..2f5afcd2 100644 --- a/web/config/router.config.js +++ b/web/config/router.config.js @@ -139,25 +139,6 @@ export default [ name: 'data', icon: 'database', routes: [ - // { - // path: '/data/pipes', - // name: 'pipes', - // component: './DataManagement/Pipes', - // routes: [ - // { - // path: '/data/pipes', - // redirect: '/data/pipes/logstash', - // }, - // { - // path: '/data/pipes/logstash', - // component: './DataManagement/LogstashConfig', - // }, - // { - // path: '/data/pipes/ingestpipeline', - // component: './DataManagement/IngestPipeline', - // }, - // ] - // }, // { // path: '/data/overview', // name: 'overview', @@ -165,14 +146,16 @@ export default [ // routes:[ // { path: '/', redirect: '/' }, // ], - // }, { - // path: '/data/index', - // name: 'index', - // component: './DataManagement/Index', - // routes:[ - // { path: '/', redirect: '/' }, - // ], - // },{ + // }, + { + path: '/data/index', + name: 'index', + component: './DataManagement/Index', + routes:[ + { path: '/', redirect: '/' }, + ], + }, + // { // path: '/data/document', // name: 'document', // component: './DataManagement/Document', @@ -269,9 +252,9 @@ export default [ // { // path: '/search/alias', // redirect: '/search/alias/index', - // routes:[ - // { path: '/', redirect: '/' }, - // ], + // // routes:[ + // // { path: '/', redirect: '/' }, + // // ], // }, // { // path: '/search/alias/index', @@ -296,9 +279,9 @@ export default [ // { // path: '/search/dict', // redirect: '/search/dict/professional', - // routes:[ - // { path: '/', redirect: '/' }, - // ], + // // routes:[ + // // { path: '/', redirect: '/' }, + // // ], // }, // { // path: '/search/dict/professional', diff --git a/web/package.json b/web/package.json index 50df795a..b5d1086f 100644 --- a/web/package.json +++ b/web/package.json @@ -10,10 +10,10 @@ "@babel/runtime": "^7.1.2", "@elastic/charts": "^25.0.1", "@elastic/datemath": "^5.0.3", - "@elastic/eui": "^34.4.0", + "@elastic/eui": "34.4.0", "@elastic/numeral": "^2.5.1", "@hapi/boom": "^9.1.3", - "@monaco-editor/react": "^3.7.4", + "@monaco-editor/react": "^4.2.2", "@svgdotjs/svg.js": "^3.0.16", "antd": "^3.26.18", "antd-table-infinity": "^1.1.6", diff --git a/web/src/components/kibana/data/common/index_patterns/index_patterns/index_pattern.ts b/web/src/components/kibana/data/common/index_patterns/index_patterns/index_pattern.ts index 3c5954cc..c332fe94 100644 --- a/web/src/components/kibana/data/common/index_patterns/index_patterns/index_pattern.ts +++ b/web/src/components/kibana/data/common/index_patterns/index_patterns/index_pattern.ts @@ -57,7 +57,7 @@ interface SavedObjectBody { type FormatFieldFn = (hit: Record, fieldName: string) => any; export class IndexPattern implements IIndexPattern { - public id?: string; + public id: string; public title: string = ''; public viewName: string = ''; public fieldFormatMap: Record; diff --git a/web/src/components/kibana/data/common/index_patterns/types.ts b/web/src/components/kibana/data/common/index_patterns/types.ts index 8a38b7ba..46deca56 100644 --- a/web/src/components/kibana/data/common/index_patterns/types.ts +++ b/web/src/components/kibana/data/common/index_patterns/types.ts @@ -174,7 +174,7 @@ export interface FieldSpec { export type IndexPatternFieldMap = Record; export interface IndexPatternSpec { - id?: string; + id: string; version?: string; title?: string; intervalName?: string; diff --git a/web/src/components/kibana/discover/public/application/components/discover_table/table.tsx b/web/src/components/kibana/discover/public/application/components/discover_table/table.tsx index 01b519d6..a39598c7 100644 --- a/web/src/components/kibana/discover/public/application/components/discover_table/table.tsx +++ b/web/src/components/kibana/discover/public/application/components/discover_table/table.tsx @@ -15,12 +15,14 @@ interface TableProps { onChangeSortOrder?: (sortOrder: SortOrder[]) => void; onMoveColumn?: (name: string, index: number) => void; onRemoveColumn?: (name: string) => void; + onAddColumn?: (name: string) => void; + document: any; } const pageCount = 50; -const Table: React.FC = ({ columns, hits, sortOrder, indexPattern, onFilter, onMoveColumn, - onRemoveColumn, onChangeSortOrder }) => { +const Table: React.FC = ({ columns, hits, sortOrder, indexPattern, onFilter, onMoveColumn, onAddColumn, + onRemoveColumn, onChangeSortOrder, document }) => { const [scrollState, setScrollState] = useState({limit: pageCount, hasMore: true}); useEffect(()=>{ setScrollState({ @@ -46,7 +48,7 @@ const Table: React.FC = ({ columns, hits, sortOrder, indexPattern, o
{hits.length ? (
- +
= ({ columns, hits, sortOrder, indexPattern, o hideTimeColumn={false} indexPattern={indexPattern} isShortDots={false} - onAddColumn={()=>{}} - onRemoveColumn={()=>{}} + onAddColumn={onAddColumn} + onRemoveColumn={onRemoveColumn} row={row} + document={document} /> })} diff --git a/web/src/components/kibana/discover/public/application/components/discover_table/table_row/detail.tsx b/web/src/components/kibana/discover/public/application/components/discover_table/table_row/detail.tsx index eeb599b1..d0bac24f 100644 --- a/web/src/components/kibana/discover/public/application/components/discover_table/table_row/detail.tsx +++ b/web/src/components/kibana/discover/public/application/components/discover_table/table_row/detail.tsx @@ -1,5 +1,14 @@ import {EuiIcon} from '@elastic/eui'; import { DocViewer } from '../../doc_viewer/doc_viewer'; +import {Drawer, Button, Menu,Dropdown, Icon, Popconfirm, message,Descriptions, Popover, Input} from 'antd'; +import Editor from "@monaco-editor/react"; +import {useState, useRef} from 'react'; + +function generateNewID(id: string) { + return id.slice(0, 14) + Math.random().toString(36).substr(2, 6) +} + + interface Props { columns: string[]; @@ -8,6 +17,7 @@ interface Props { onFilter: (field: any, values: any, operation: any) => void; onAddColumn?: (name: string) => void; onRemoveColumn?: (name: string) => void; + document: any; } export function Detail({ @@ -17,7 +27,59 @@ export function Detail({ onFilter, onAddColumn, onRemoveColumn, + document, }:Props){ + const [editorVisible, setEditorVisble] = useState(false); + const editorRef = useRef(null); + + function handleEditorDidMount(editor, monaco) { + editorRef.current = editor; + } + + const editDocumentClick = ()=>{ + setEditorVisble(true) + } + const editCancelClick = ()=>{ + setEditorVisble(false) + } + const saveDocumentClick = async (docID?: string)=>{ + const value = editorRef.current?.getValue(); + let source = {} + try { + source = JSON.parse(value) + } catch (error) { + message.error('wrong json format') + return + } + const res = await document.saveDocument({ + _index: row._index, + _id: docID || row._id, + _type: row._type, + _source: source + }) + if(!res.error) setEditorVisble(false) + } + const deleteDocumentClick = ()=>{ + document.deleteDocument({ + _index: row._index, + _id: row._id, + _type: row._type, + }) + } + + const menu = ( + + + Edit + + + { + deleteDocumentClick(); + }}> Delete + + + ); + return ( - - {this.hashChanged=true;}} defaultValue={index} ref={el=>{this.indexEl=el}} placeholder="input index or index pattern" style={{width: '25%'}}/> + {this.hashChanged=true;}} defaultValue={index} ref={el=>{this.indexEl=el}} placeholder="input index or index pattern" style={{width: '40%'}}/> this.keywordEl=el} diff --git a/web/src/pages/DataManagement/Index.js b/web/src/pages/DataManagement/Index.js index 397df0da..872ab80e 100644 --- a/web/src/pages/DataManagement/Index.js +++ b/web/src/pages/DataManagement/Index.js @@ -17,12 +17,14 @@ import { Menu, Table, Dropdown, - Icon, Popconfirm + Icon, Popconfirm, + Switch, } from 'antd'; import Editor from '@monaco-editor/react'; import styles from '../List/TableList.less'; import {transformSettingsForApi} from '@/lib/elasticsearch/edit_settings'; +import PageHeaderWrapper from '@/components/PageHeaderWrapper'; const FormItem = Form.Item; const { TextArea } = Input; @@ -107,8 +109,9 @@ class CreateForm extends React.Component { /* eslint react/no-multi-comp:0 */ -@connect(({ index }) => ({ - index +@connect(({ index,global }) => ({ + index, + clusterID: global.selectedClusterID, })) @Form.create() class Index extends PureComponent { @@ -120,6 +123,7 @@ class Index extends PureComponent { drawerVisible: false, editingIndex:{}, indexActiveKey: '1', + showSystemIndices: false, }; columns = [ { @@ -137,6 +141,9 @@ class Index extends PureComponent { { title: '文档数', dataIndex: 'docs_count', + render: (val)=>{ + return val || 0; + } }, { title: '主分片数', @@ -165,13 +172,18 @@ class Index extends PureComponent { componentDidMount() { this.fetchData() } + componentDidUpdate(oldProps,newState,snapshot){ + if(oldProps.clusterID != this.props.clusterID){ + this.fetchData() + } + } fetchData = ()=>{ - const { dispatch } = this.props; + const { dispatch, clusterID } = this.props; dispatch({ type: 'index/fetchIndices', payload: { - cluster: 'single-es' + clusterID: clusterID, } }); } @@ -185,11 +197,12 @@ class Index extends PureComponent { }; handleDeleteClick = (indexName) => { - const { dispatch } = this.props; + const { dispatch,clusterID } = this.props; dispatch({ type: 'index/removeIndex', payload: { - index: indexName + index: indexName, + clusterID, } }); }; @@ -214,12 +227,13 @@ class Index extends PureComponent { }; handleAdd = fields => { - const { dispatch } = this.props; + const { dispatch, clusterID} = this.props; dispatch({ type: 'index/addIndex', payload: { index: fields.index, - config: JSON.parse(fields.config) + config: JSON.parse(fields.config || '{}'), + clusterID }, }); this.handleModalVisible(); @@ -229,7 +243,7 @@ class Index extends PureComponent { this.setState({ indexActiveKey: activeKey, }) - const {dispatch} = this.props; + const {dispatch, clusterID} = this.props; if(activeKey == '2'){ if(this.props.index.mappings[indexName]){ return @@ -238,6 +252,7 @@ class Index extends PureComponent { type: 'index/fetchMappings', payload: { index: indexName, + clusterID, } }) }else if(activeKey == '4'){ @@ -248,6 +263,7 @@ class Index extends PureComponent { type: 'index/fetchSettings', payload: { index: indexName, + clusterID, } }) } @@ -259,12 +275,13 @@ class Index extends PureComponent { handleIndexSettingsSaveClick = (indexName)=>{ let settings = this.indexSettingsGetter(); settings = JSON.parse(settings); - const {dispatch} = this.props; + const {dispatch,clusterID} = this.props; dispatch({ type: 'index/saveSettings', payload: { index: indexName, settings: settings, + clusterID, } }) } @@ -281,6 +298,9 @@ class Index extends PureComponent { } indices.push(clusterIndices[key]); } + if(!this.state.showSystemIndices){ + indices = indices.filter(item=>!item.index.startsWith('.')); + } const { modalVisible, updateModalVisible, updateFormValues,editingIndex, drawerVisible } = this.state; const parentMethods = { handleAdd: this.handleAdd, @@ -301,7 +321,7 @@ class Index extends PureComponent { const {form: { getFieldDecorator }} = this.props; return ( - +
@@ -332,7 +352,9 @@ class Index extends PureComponent {
- +
显示系统索引{this.setState({showSystemIndices:checked})}} + defaultChecked={this.state.showSystemIndices}/>
@@ -34,9 +96,49 @@ export function Detail({
- {/*
+
+ {setEditorVisble(false)}}> + + {row._index} + {row._id} + + +
+
+ + {/* */} + + +
+
+
+ {/*
View surrounding documents @@ -45,9 +147,9 @@ export function Detail({ View single document -
+
*/}
-
*/} +
+ ) +} + +const SaveAsNewButton = ({docID, saveDocumentClick}:any)=>{ + const newID = generateNewID(docID); + const [newDocID, setNewDocID] = useState(newID) + const content = (
+
{ + setNewDocID(e.target.value) + }} />
+
+
) + return ( + + + ) } \ No newline at end of file diff --git a/web/src/components/kibana/discover/public/application/components/discover_table/table_row/table_row.tsx b/web/src/components/kibana/discover/public/application/components/discover_table/table_row/table_row.tsx index 23f9095e..8f6971b7 100644 --- a/web/src/components/kibana/discover/public/application/components/discover_table/table_row/table_row.tsx +++ b/web/src/components/kibana/discover/public/application/components/discover_table/table_row/table_row.tsx @@ -13,6 +13,7 @@ interface Props { onAddColumn?: (name: string) => void; onRemoveColumn?: (name: string) => void; row: any; + document: any; } export function TableRow({ @@ -24,6 +25,7 @@ export function TableRow({ onAddColumn, onRemoveColumn, row, + document }:Props){ const mapping = indexPattern.fields.getByName; const [open,setOpen] = useState(false); @@ -60,6 +62,7 @@ export function TableRow({ diff --git a/web/src/components/kibana/discover/public/application/components/doc_viewer/doc_viewer.scss b/web/src/components/kibana/discover/public/application/components/doc_viewer/doc_viewer.scss index 877c45dc..113e037a 100644 --- a/web/src/components/kibana/discover/public/application/components/doc_viewer/doc_viewer.scss +++ b/web/src/components/kibana/discover/public/application/components/doc_viewer/doc_viewer.scss @@ -1,6 +1,10 @@ @import '../../../../../core/public/variables.scss'; .kbnDocViewerTable { margin-top: $euiSizeS; + font-size: 12px; + .kbnDocViewer__buttons{ + padding-top: 0px !important; + } } .kbnDocViewer { diff --git a/web/src/components/kibana/discover/public/application/components/doc_viewer/doc_viewer_tab.tsx b/web/src/components/kibana/discover/public/application/components/doc_viewer/doc_viewer_tab.tsx index 1bb7a653..d413f935 100644 --- a/web/src/components/kibana/discover/public/application/components/doc_viewer/doc_viewer_tab.tsx +++ b/web/src/components/kibana/discover/public/application/components/doc_viewer/doc_viewer_tab.tsx @@ -51,8 +51,8 @@ export class DocViewerTab extends React.Component { shouldComponentUpdate(nextProps: Props, nextState: State) { return ( - nextProps.renderProps.hit._id !== this.props.renderProps.hit._id || - nextProps.id !== this.props.id || + nextProps.renderProps.hit !== this.props.renderProps.hit || + nextProps.id !== this.props.id || nextProps.renderProps.columns !== this.props.renderProps.columns || nextState.hasError ); } diff --git a/web/src/components/kibana/discover/public/application/components/table/table_row.tsx b/web/src/components/kibana/discover/public/application/components/table/table_row.tsx index 5f7dd9f3..c37d91b6 100644 --- a/web/src/components/kibana/discover/public/application/components/table/table_row.tsx +++ b/web/src/components/kibana/discover/public/application/components/table/table_row.tsx @@ -100,7 +100,7 @@ export function DocViewTableRow({ )} {displayUnderscoreWarning && } - {displayNoMappingWarning && } + {/* {displayNoMappingWarning && } */}
void; @@ -28,23 +26,15 @@ export interface Props { export function DocViewTableRowBtnFilterAdd({ onClick, disabled = false }: Props) { const tooltipContent = disabled ? ( - + "Unindexed fields can not be searched" ) : ( - + "Filter for value" ); return ( void; @@ -34,29 +32,18 @@ export function DocViewTableRowBtnFilterExists({ }: Props) { const tooltipContent = disabled ? ( scripted ? ( - + "Unable to filter for presence of scripted fields" ) : ( - + "Unable to filter for presence of meta fields" ) ) : ( - + "Filter for field present" ); return ( void; @@ -28,23 +26,15 @@ export interface Props { export function DocViewTableRowBtnFilterRemove({ onClick, disabled = false }: Props) { const tooltipContent = disabled ? ( - + "Unindexed fields can not be searched" ) : ( - + "Filter out value" ); return ( - } + content="Toggle column in table" > Index Patterns page', - } - ); + const ariaLabel = 'Warning'; + const tooltipContent = + 'No cached mapping for this field. Refresh field list from the Management > Index Patterns page'; return ( { + ({ indexPattern, history, location, id }: EditIndexPatternProps) => { const { uiSettings, indexPatternManagementStart, @@ -131,8 +132,8 @@ export const EditIndexPattern = withRouter( uiSettings.set('defaultIndex', otherPatterns[0].id); } } - if (indexPattern.id) { - Promise.resolve(data.indexPatterns.delete(indexPattern.id)).then(function () { + if (indexPattern.id || id) { + Promise.resolve(data.indexPatterns.delete(indexPattern.id || id)).then(function () { history.push(''); }); } diff --git a/web/src/components/kibana/index_pattern_management/public/components/edit_index_pattern/edit_index_pattern_container.tsx b/web/src/components/kibana/index_pattern_management/public/components/edit_index_pattern/edit_index_pattern_container.tsx index 0420d1cf..7ed72ac3 100644 --- a/web/src/components/kibana/index_pattern_management/public/components/edit_index_pattern/edit_index_pattern_container.tsx +++ b/web/src/components/kibana/index_pattern_management/public/components/edit_index_pattern/edit_index_pattern_container.tsx @@ -41,7 +41,7 @@ const EditIndexPatternCont: React.FC> = ({ . }, [data.indexPatterns, props.match.params.id, ]); //setBreadcrumbs if (indexPattern) { - return ; + return ; } else { return <>; } diff --git a/web/src/components/kibana/index_pattern_management/public/components/edit_index_pattern/index_header/index_header.tsx b/web/src/components/kibana/index_pattern_management/public/components/edit_index_pattern/index_header/index_header.tsx index 5ef99852..7eb59a72 100644 --- a/web/src/components/kibana/index_pattern_management/public/components/edit_index_pattern/index_header/index_header.tsx +++ b/web/src/components/kibana/index_pattern_management/public/components/edit_index_pattern/index_header/index_header.tsx @@ -20,6 +20,7 @@ import React from 'react'; import { EuiFlexGroup, EuiToolTip, EuiFlexItem, EuiTitle, EuiButtonIcon } from '@elastic/eui'; import { IIndexPattern } from 'src/plugins/data/public'; +import {Popconfirm} from 'antd'; interface IndexHeaderProps { indexPattern: IIndexPattern; @@ -88,13 +89,15 @@ export function IndexHeader({ {deleteIndexPatternClick && ( - + + + )} diff --git a/web/src/pages/Alerting/pages/Dashboard/components/AlertList/AlertList.tsx b/web/src/pages/Alerting/pages/Dashboard/components/AlertList/AlertList.tsx index b6c87172..2ba2bfd4 100644 --- a/web/src/pages/Alerting/pages/Dashboard/components/AlertList/AlertList.tsx +++ b/web/src/pages/Alerting/pages/Dashboard/components/AlertList/AlertList.tsx @@ -1,7 +1,9 @@ -import {List} from 'antd'; +import {List, ConfigProvider, Button} from 'antd'; import {AlertItem, AlertRecord} from './AlertItem'; import './alertlist.scss'; import {Legend, LegendItem} from './Legend'; +import {router} from 'umi'; + interface AlertListProps { dataSource: AlertRecord[]; @@ -9,6 +11,7 @@ interface AlertListProps { title: string; onItemClick: (item: AlertRecord)=>void; legendItems?: LegendItem[]; + onEmptyClick?: ()=>void; } export const AlertList = ({ @@ -16,38 +19,54 @@ export const AlertList = ({ pagination, title, onItemClick, - legendItems + legendItems, + onEmptyClick, }: AlertListProps)=>{ + if(typeof onEmptyClick !== 'function'){ + onEmptyClick = ()=>{ + router.push('/alerting/monitor/create-monitor'); + } + } + + const AlertRenderEmpty = ()=>{ + return
+ +
+ } return ( -
-
-
- {title} - ({pagination?.total}) -
- { - legendItems ? (
- -
):null - } - -
- { - console.log(page); - }, - pageSize: 20, - ...pagination, - }} - dataSource={dataSource} - renderItem={item => ( - - )} - /> -
+
+
+ {title} + ({pagination?.total}) +
+
+
+ { + legendItems ? (
+ +
):null + } + +
+ + { + console.log(page); + }, + pageSize: 20, + ...pagination, + }} + dataSource={dataSource} + renderItem={item => ( + + )} + /> + +
+
) } diff --git a/web/src/pages/Alerting/pages/Dashboard/components/AlertList/alertlist.scss b/web/src/pages/Alerting/pages/Dashboard/components/AlertList/alertlist.scss index 4e16523e..0d51cf24 100644 --- a/web/src/pages/Alerting/pages/Dashboard/components/AlertList/alertlist.scss +++ b/web/src/pages/Alerting/pages/Dashboard/components/AlertList/alertlist.scss @@ -3,19 +3,22 @@ padding: 10px 5px; .header{ display: flex; - .title{ - color: #333; - font-weight:600; - padding-bottom: 6px; - .total{ - color: #999; - margin-left: 15px; - font-size: 12px; - } - } .legend{ margin-left: auto; } + margin-bottom: 5px; + } +} +.alert-list-layout{ + .title{ + color: #333; + font-weight:600; + font-size: 16px; + padding-bottom: 6px; + .total{ + color: #999; + margin-left: 15px; + font-size: 12px; + } } - } \ No newline at end of file diff --git a/web/src/pages/Alerting/pages/Dashboard/containers/AlertOverview.tsx b/web/src/pages/Alerting/pages/Dashboard/containers/AlertOverview.tsx index 28145c63..6d6ae213 100644 --- a/web/src/pages/Alerting/pages/Dashboard/containers/AlertOverview.tsx +++ b/web/src/pages/Alerting/pages/Dashboard/containers/AlertOverview.tsx @@ -76,22 +76,26 @@ export const AlertOverview = (props: any)=>{ return (
- +
+ +
+
+ title={formatMessage({id:'alert.overview.alertlist-history.title'})} + onItemClick={onItemClick} + pagination={{ + pageSize, + total: historyAlerts.total, + onChange: onAlertHistoryPageChange, + }}/> +
{/*
提示
diff --git a/web/src/pages/Alerting/pages/Overview/Overview.js b/web/src/pages/Alerting/pages/Overview/Overview.js index 01e84580..840e15a3 100644 --- a/web/src/pages/Alerting/pages/Overview/Overview.js +++ b/web/src/pages/Alerting/pages/Overview/Overview.js @@ -1,5 +1,5 @@ import React, {useEffect, useState, useMemo} from "react"; -import {Spin, Card} from 'antd'; +import {Spin, Card, Empty, Button} from 'antd'; import {Fetch} from '../../../../components/kibana/core/public/http/fetch'; import './overview.scss'; import { @@ -148,7 +148,49 @@ export default (props)=>{
-
+
+
+ + + + + + +
+
+ + + + Number(d).toFixed(0)} /> + + + +
+
+
+ {alerts.data.length == 0 && historyAlerts.data.length == 0 && + + } { onChange: onAlertPageChange, }}/>
-
+ {historyAlerts.data.length > 0 &&
{ total: historyAlerts.total, onChange: onAlertHistoryPageChange, }}/> -
+
}
-
- - - - - - -
-
- - - - Number(d).toFixed(0)} /> - - - -
+
diff --git a/web/src/pages/Alerting/pages/Overview/overview.scss b/web/src/pages/Alerting/pages/Overview/overview.scss index 0693d785..1607580a 100644 --- a/web/src/pages/Alerting/pages/Overview/overview.scss +++ b/web/src/pages/Alerting/pages/Overview/overview.scss @@ -1,9 +1,9 @@ .layout{ - display: flex; + // display: flex; .left{ - display: flex; - flex: 1 1 60%; - flex-direction: column; + // display: flex; + // flex: 1 1 60%; + // flex-direction: column; .state-count{ display: flex; justify-content: space-between; @@ -21,9 +21,19 @@ font-size: 12px; font-weight: normal; } - } + } margin-bottom: 10px; } + .alertlist-item{ + margin-top: 20px; + } + } + .charts{ + display: flex; + margin-top: 25px; + >.chart{ + flex: 1 1 50%; + } } .right{ flex: 1 1 40%; @@ -31,6 +41,6 @@ } .overview-wrapper { - padding: 10px; + padding: 20px; background-color: #fff; } \ No newline at end of file diff --git a/web/src/pages/Cluster/Overview.js b/web/src/pages/Cluster/Overview.js index 5754e7b6..f6c1cf4f 100644 --- a/web/src/pages/Cluster/Overview.js +++ b/web/src/pages/Cluster/Overview.js @@ -227,7 +227,7 @@ class Overview extends React.Component { >
- {totalStoreSize.size}{totalStoreSize.unit} + {totalStoreSize.size || '-'}{totalStoreSize.unit}
diff --git a/web/src/pages/DataManagement/Discover.jsx b/web/src/pages/DataManagement/Discover.jsx index 47c271cf..1c910cc5 100644 --- a/web/src/pages/DataManagement/Discover.jsx +++ b/web/src/pages/DataManagement/Discover.jsx @@ -31,7 +31,7 @@ import * as styles from './discover.scss'; import { Subscription } from 'rxjs'; import { connect } from 'dva'; -import { Card, Spin } from 'antd'; +import { Card, Spin, message } from 'antd'; // import DiscoverGrid from './Components/discover_grid'; import {flattenHitWrapper} from '../../components/kibana/data/common/index_patterns/index_patterns'; import {getStateColumnActions} from '../../components/kibana/discover/public/application/angular/doc_table/actions/columns'; @@ -56,8 +56,6 @@ const SidebarMemoized = React.memo(DiscoverSidebar); const {filterManager, queryStringManager, timefilter, storage, getEsQuery, getSearchParams, intervalOptions, getTimeBuckets, fetchESRequest, services} = getContext(); -//const histogramData = buildPointSeriesData(chartTable, dimensions); - const SearchBar = createSearchBar(); @@ -246,7 +244,7 @@ const Discover = (props)=>{ state, useNewFieldsApi:false, }), - [indexPattern, state] + [indexPattern,state] ); const collapseIcon = useRef(null); @@ -309,6 +307,41 @@ const Discover = (props)=>{ const hits = searchRes.hits.total?.value || searchRes.hits.total; const resetQuery = ()=>{}; const showDatePicker = indexPattern.timeFieldName != ""; + + const saveDocument = useCallback(async ({_index, _id, _type, _source})=>{ + const {http} = getContext(); + const res = await http.put(`/elasticsearch/${props.selectedCluster.id}/doc/${_index}/${_id}`, { + prependBasePath: false, + query: { + _type, + }, + body: JSON.stringify(_source), + }); + if(res.error){ + message.error(res.error) + return res + } + message.success('saved successfully'); + updateQuery() + return res + },[props.selectedCluster]) + + const deleteDocument = useCallback(async ({_index, _id, _type})=>{ + const {http} = getContext(); + const res = await http.delete(`/elasticsearch/${props.selectedCluster.id}/doc/${_index}/${_id}`, { + prependBasePath: false, + query: { + _type, + } + }); + if(res.error){ + message.error(res.error) + return res + } + message.success('deleted successfully'); + updateQuery() + return res + },[props.selectedCluster]) return ( @@ -495,7 +528,9 @@ const Discover = (props)=>{ onFilter={onAddFilter} onRemoveColumn={onRemoveColumn} onMoveColumn={onMoveColumn} + onAddColumn={onAddColumn} onChangeSortOrder={onSort} + document={{saveDocument, deleteDocument}} hits={rows}/>
):null} diff --git a/web/src/pages/DataManagement/Document.js b/web/src/pages/DataManagement/Document.js index e02caef3..0f69412c 100644 --- a/web/src/pages/DataManagement/Document.js +++ b/web/src/pages/DataManagement/Document.js @@ -383,14 +383,10 @@ class EditableCell extends React.Component { getFieldType = (record, key)=>{ const {doclist} = this.props; - // if(!doclist.mappings[record._index]){ - // console.log(record, doclist.mappings) - // return - // } let properties = null; let _type = record._type || doclist._type; if(typeof _type !== 'undefined' && _type !== '' && _type !== '_doc'){ - properties = doclist.mappings[record._index].mappings[_type].properties; + properties = doclist.mappings[record._index].mappings[_type]?.properties || {}; }else{ properties = doclist.mappings[record._index].mappings.properties; } @@ -565,9 +561,10 @@ class EditableCell extends React.Component { } } -@connect(({document,cluster})=>({ +@connect(({document,global})=>({ document, - cluster, + clusterID: global.selectedClusterID, + cluster: global.selectedCluster, })) @Form.create() class Doucment extends React.Component { @@ -580,10 +577,13 @@ class Doucment extends React.Component { // } fetchData = (params) => { - const {dispatch} = this.props; + const {dispatch, clusterID} = this.props; return dispatch({ type: 'document/fetchDocList', - payload: params, + payload: { + ...params, + clusterID + }, }) } @@ -595,38 +595,28 @@ class Doucment extends React.Component { langDisposer.dispose(); } } - componentDidMount(){ - // initEditor() - const {location, dispatch } = this.props; - //console.log(match, location); - let index = location.query.index; - let cluster = location.query.cluster || 'single-es'; - if(!cluster){ - return + componentDidUpdate(oldProps,newState,snapshot){ + if(oldProps.clusterID != this.props.clusterID){ + this.initData() } + } + initData = ()=>{ + const {dispatch, clusterID} = this.props; dispatch({ type: 'document/fetchMappings', payload: { - cluster, + clusterID, } }); dispatch({ type: 'document/fetchIndices', payload: { - cluster, + clusterID, } - }).then(()=>{ - if(!index){ - return - } - this.fetchData({ - pageSize: 10, - pageIndex: 1, - cluster, - index, - }) }) - + } + componentDidMount(){ + this.initData() } handleNewClick = ()=>{ @@ -644,7 +634,6 @@ class Doucment extends React.Component { let _index = indices[0]; let _type = ''; if(indices.length > 0){ - //console.log(this.indexSelEl); let vals = this.indexSelEl.state.value; if(vals.length === 0){ Modal.error({ @@ -701,9 +690,8 @@ class Doucment extends React.Component { handleSearchClick = (e)=>{ let value = this.keywordEl.state.value; let index = this.indexEl.state.value; - let cluster = this.clusterEl.rcSelect.state.value[0]; let filter = ''; - if(!cluster || !index){ + if(!index){ message.error('please select cluster and index'); return; } @@ -711,7 +699,6 @@ class Doucment extends React.Component { filter = this.filterGetter(); } this.fetchData({ - cluster, index, pageSize: this.props.document.pageSize, pageIndex: 1, @@ -719,10 +706,10 @@ class Doucment extends React.Component { filter, keyword: value, }).then(()=>{ - if(this.hashChanged){ - router.push(`/data/document?cluster=${cluster}&index=${index}`); - this.hashChanged = !this.hashChanged; - } + // if(this.hashChanged){ + // router.push(`/data/document?cluster=${cluster}&index=${index}`); + // this.hashChanged = !this.hashChanged; + // } }) } @@ -741,8 +728,9 @@ class Doucment extends React.Component { // if((indices && indices.length > 1)){ // return; // } - const {major} = this.props.cluster; - if(indices && indices.length >= 0){ + const {version} = this.props.cluster; + const major = version.split('.')?.[0] || ''; + if(indices && indices.length >= 0 && major !=''){ indices = getESAPI(major).extractIndicesFromMappings(mappings).filter(item=>{ if(indices.length > 0){ return indices.indexOf(item.index) > -1; @@ -769,11 +757,6 @@ class Doucment extends React.Component {
{(indices && indices.length>0) ? ({this.indexSelEl=el}} onChange={(vals)=>{this.handleResultTabKeyChange(vals[0])}} value={[resultKey]} options={indices} style={{width: 200, marginRight:5}} placeholder="please select a index"> ) : ''} - {/*{(indices) ? () : ''}*/} {/*Select Viewer: */} @@ -806,9 +789,7 @@ class Doucment extends React.Component { value: index, }; }) - const clusters = ["single-es"]; - let {cluster, index, indices, tableMode}= this.props.document; - cluster = cluster || this.props.location.query.cluster || 'single-es'; + let {index, indices, tableMode}= this.props.document; index = index || this.props.location.query.index; indices = indices || []; @@ -824,12 +805,7 @@ class Doucment extends React.Component {
{this.handleIndexTabChanged(activeKey, editingIndex.index)}}> - + {editingIndex.health} {editingIndex.status} {editingIndex.shards} {editingIndex.replicas} {editingIndex.docs_count} {editingIndex.docs_deleted} - - - - + {editingIndex.store_size} + {editingIndex.pri_store_size} + {/* + */} @@ -431,7 +453,7 @@ class Index extends PureComponent { - + ); } } diff --git a/web/src/pages/DataManagement/context.js b/web/src/pages/DataManagement/context.js index fc34f797..9922cd42 100644 --- a/web/src/pages/DataManagement/context.js +++ b/web/src/pages/DataManagement/context.js @@ -2,7 +2,7 @@ import {AutocompleteService} from '../../components/kibana/data/public/autocompl import {FilterManager} from '../../components/kibana/data/public/query/filter_manager/filter_manager'; import {QueryStringManager} from '../../components/kibana/data/public/query/query_string/query_string_manager'; import {Timefilter, TimeHistory} from '../../components/kibana/data/public/query/timefilter'; -import { useState, useEffect } from 'react'; +import { useState, useEffect, createContext } from 'react'; import { Subscription } from 'rxjs'; import {buildEsQuery} from '../../components/kibana/data/common/es_query/es_query/build_es_query'; import {getCalculateAutoTimeExpression} from '../../components/kibana/data/common/search/aggs/utils/calculate_auto_time_expression'; diff --git a/web/src/pages/DataManagement/models/document.js b/web/src/pages/DataManagement/models/document.js index 079b1947..b37ce0c8 100644 --- a/web/src/pages/DataManagement/models/document.js +++ b/web/src/pages/DataManagement/models/document.js @@ -200,29 +200,28 @@ export default { message.success("添加文档成功") }, *fetchIndices({payload}, {call, put}){ - let resp = yield call(getIndices) - if(resp.status === false){ + let resp = yield call(getIndices, payload) + if(resp.error){ message.warn("获取数据失败") return } yield put({ type: 'saveData', payload: { - clusterIndices: resp.payload, - cluster: payload.cluster, + clusterIndices: resp, } }) }, *fetchMappings({payload}, {call, put}){ let resp = yield call(getMappings, payload); - if(resp.status === false){ + if(resp.error){ message.warn("get mappings failed") return } yield put({ type: 'saveData', payload: { - mappings: resp.payload, + mappings: resp, } }) } diff --git a/web/src/pages/DataManagement/models/index.js b/web/src/pages/DataManagement/models/index.js index 9c878028..3f50f102 100644 --- a/web/src/pages/DataManagement/models/index.js +++ b/web/src/pages/DataManagement/models/index.js @@ -11,48 +11,48 @@ export default { }, effects:{ *fetchIndices({payload}, {call, put}){ - let resp = yield call(getIndices) - if(resp.status === false){ + let resp = yield call(getIndices, payload) + if(resp.error){ message.warn("获取数据失败") return } yield put({ type: 'saveData', payload: { - clusterIndices: resp.payload, + clusterIndices: resp, // cluster: payload.cluster, } }) }, *fetchMappings({payload}, {call, put}){ let resp = yield call(getMappings, payload); - if(resp.status === false){ + if(resp.error){ message.warn("get mappings failed") return } yield put({ type: 'saveData', payload: { - mappings: resp.payload, + mappings: resp, } }) }, *fetchSettings({payload}, {call, put}){ let resp = yield call(getSettings, payload); - if(resp.status === false){ + if(resp.error){ message.warn("get settings failed") return } yield put({ type: 'saveData', payload: { - settings: resp.payload, + settings: resp, } }) }, *saveSettings({payload}, {call, put, select}){ let resp = yield call(updateSettings, payload); - if(resp.status === false){ + if(resp.error){ message.warn("save settings failed") return } @@ -67,7 +67,7 @@ export default { }, *removeIndex({payload}, {call, put, select}){ let resp = yield call(deleteIndex, payload); - if(resp.status === false){ + if(resp.error){ message.warn("get mappings failed") return } @@ -82,12 +82,15 @@ export default { }, *addIndex({payload}, {call, put, select}){ let resp = yield call(createIndex, payload); - if(resp.status === false){ + if(resp.error){ message.warn("create index failed") return } yield put({ - type: 'fetchIndices' + type: 'fetchIndices', + payload: { + clusterID: payload.clusterID, + } }) }, }, diff --git a/web/src/pages/List/TableList.less b/web/src/pages/List/TableList.less index 792757df..1808e50b 100644 --- a/web/src/pages/List/TableList.less +++ b/web/src/pages/List/TableList.less @@ -7,6 +7,7 @@ button { margin-right: 8px; } + display: flex; } } diff --git a/web/src/pages/SearchManage/alias/AliasManage.js b/web/src/pages/SearchManage/alias/AliasManage.js index 9577c649..e5ea76f9 100644 --- a/web/src/pages/SearchManage/alias/AliasManage.js +++ b/web/src/pages/SearchManage/alias/AliasManage.js @@ -11,6 +11,7 @@ import { message, Divider, Table, AutoComplete, Switch, + Popconfirm } from 'antd'; import styles from '../../List/TableList.less'; @@ -18,42 +19,6 @@ import styles from '../../List/TableList.less'; const FormItem = Form.Item; const { TextArea } = Input; -const CreateForm = Form.create()(props => { - const { modalVisible, form, handleAdd, handleModalVisible } = props; - const okHandle = () => { - form.validateFields((err, fieldsValue) => { - if (err) return; - form.resetFields(); - handleAdd(fieldsValue); - }); - }; - return ( - handleModalVisible()} - > - - {form.getFieldDecorator('index', { - rules: [{ required: true, message: '请输入至少五个字符的名称!', min: 5 }], - })()} - - - {form.getFieldDecorator('settings', { - rules: [{ required: true }], - })(