delete web dir
|
@ -2,6 +2,7 @@ package index_management
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
log "github.com/cihub/seelog"
|
||||||
httprouter "infini.sh/framework/core/api/router"
|
httprouter "infini.sh/framework/core/api/router"
|
||||||
"infini.sh/framework/core/elastic"
|
"infini.sh/framework/core/elastic"
|
||||||
"infini.sh/framework/core/orm"
|
"infini.sh/framework/core/orm"
|
||||||
|
@ -19,6 +20,7 @@ func (h *APIHandler) HandleAddCommonCommandAction(w http.ResponseWriter, req *ht
|
||||||
reqParams := elastic.CommonCommand{}
|
reqParams := elastic.CommonCommand{}
|
||||||
err := h.DecodeJSON(req, &reqParams)
|
err := h.DecodeJSON(req, &reqParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
resBody["error"] = err.Error()
|
resBody["error"] = err.Error()
|
||||||
h.WriteJSON(w, resBody, http.StatusOK)
|
h.WriteJSON(w, resBody, http.StatusOK)
|
||||||
return
|
return
|
||||||
|
@ -32,17 +34,20 @@ func (h *APIHandler) HandleAddCommonCommandAction(w http.ResponseWriter, req *ht
|
||||||
var indexName = orm.GetIndexName(reqParams)
|
var indexName = orm.GetIndexName(reqParams)
|
||||||
searchRes, err := esClient.SearchWithRawQueryDSL(indexName, queryDSL)
|
searchRes, err := esClient.SearchWithRawQueryDSL(indexName, queryDSL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
resBody["error"] = err.Error()
|
resBody["error"] = err.Error()
|
||||||
h.WriteJSON(w, resBody, http.StatusOK)
|
h.WriteJSON(w, resBody, http.StatusOK)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(searchRes.Hits.Hits) > 0 {
|
if len(searchRes.Hits.Hits) > 0 {
|
||||||
resBody["error"] = "title already exists"
|
resBody["error"] = "title already exists"
|
||||||
|
log.Error(resBody["error"])
|
||||||
h.WriteJSON(w, resBody, http.StatusOK)
|
h.WriteJSON(w, resBody, http.StatusOK)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_, err = esClient.Index(indexName,"", reqParams.ID, reqParams)
|
_, err = esClient.Index(indexName,"", reqParams.ID, reqParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
resBody["error"] = err.Error()
|
resBody["error"] = err.Error()
|
||||||
h.WriteJSON(w, resBody, http.StatusOK)
|
h.WriteJSON(w, resBody, http.StatusOK)
|
||||||
return
|
return
|
||||||
|
@ -61,8 +66,9 @@ func (h *APIHandler) HandleSaveCommonCommandAction(w http.ResponseWriter, req *h
|
||||||
reqParams := elastic.CommonCommand{}
|
reqParams := elastic.CommonCommand{}
|
||||||
err := h.DecodeJSON(req, &reqParams)
|
err := h.DecodeJSON(req, &reqParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
resBody["error"] = err.Error()
|
resBody["error"] = err.Error()
|
||||||
h.WriteJSON(w, resBody, http.StatusOK)
|
h.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqParams.ID = ps.ByName("cid")
|
reqParams.ID = ps.ByName("cid")
|
||||||
|
@ -72,19 +78,22 @@ func (h *APIHandler) HandleSaveCommonCommandAction(w http.ResponseWriter, req *h
|
||||||
var indexName = orm.GetIndexName(reqParams)
|
var indexName = orm.GetIndexName(reqParams)
|
||||||
searchRes, err := esClient.SearchWithRawQueryDSL(indexName, queryDSL)
|
searchRes, err := esClient.SearchWithRawQueryDSL(indexName, queryDSL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
resBody["error"] = err.Error()
|
resBody["error"] = err.Error()
|
||||||
h.WriteJSON(w, resBody, http.StatusOK)
|
h.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(searchRes.Hits.Hits) > 0 && searchRes.Hits.Hits[0].ID.(string) != reqParams.ID {
|
if len(searchRes.Hits.Hits) > 0 && searchRes.Hits.Hits[0].ID.(string) != reqParams.ID {
|
||||||
resBody["error"] = "title already exists"
|
resBody["error"] = "title already exists"
|
||||||
h.WriteJSON(w, resBody, http.StatusOK)
|
log.Error(resBody["error"])
|
||||||
|
h.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_, err = esClient.Index(indexName,"", reqParams.ID, reqParams)
|
_, err = esClient.Index(indexName,"", reqParams.ID, reqParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
resBody["error"] = err.Error()
|
resBody["error"] = err.Error()
|
||||||
h.WriteJSON(w, resBody, http.StatusOK)
|
h.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,6 +136,7 @@ func (h *APIHandler) HandleQueryCommonCommandAction(w http.ResponseWriter, req *
|
||||||
|
|
||||||
searchRes, err := esClient.SearchWithRawQueryDSL(orm.GetIndexName(elastic.CommonCommand{}), []byte(queryDSL))
|
searchRes, err := esClient.SearchWithRawQueryDSL(orm.GetIndexName(elastic.CommonCommand{}), []byte(queryDSL))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
resBody["error"] = err
|
resBody["error"] = err
|
||||||
h.WriteJSON(w, resBody, http.StatusInternalServerError)
|
h.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
|
@ -141,6 +151,7 @@ func (h *APIHandler) HandleDeleteCommonCommandAction(w http.ResponseWriter, req
|
||||||
esClient := elastic.GetClient(h.Config.Elasticsearch)
|
esClient := elastic.GetClient(h.Config.Elasticsearch)
|
||||||
delRes, err := esClient.Delete(orm.GetIndexName(elastic.CommonCommand{}), "", id, "wait_for")
|
delRes, err := esClient.Delete(orm.GetIndexName(elastic.CommonCommand{}), "", id, "wait_for")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
resBody["error"] = err.Error()
|
resBody["error"] = err.Error()
|
||||||
if delRes!=nil{
|
if delRes!=nil{
|
||||||
h.WriteJSON(w, resBody, delRes.StatusCode)
|
h.WriteJSON(w, resBody, delRes.StatusCode)
|
||||||
|
|
|
@ -79,6 +79,7 @@ func (handler APIHandler) getLatestClusterMonitorData(clusterID interface{}) (ut
|
||||||
queryDSL := fmt.Sprintf(queryDSLTpl, clusterID)
|
queryDSL := fmt.Sprintf(queryDSLTpl, clusterID)
|
||||||
searchRes, err := client.SearchWithRawQueryDSL(orm.GetIndexName(event.Event{}), []byte(queryDSL))
|
searchRes, err := client.SearchWithRawQueryDSL(orm.GetIndexName(event.Event{}), []byte(queryDSL))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(searchRes.Hits.Hits) == 0 {
|
if len(searchRes.Hits.Hits) == 0 {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package index_management
|
package index_management
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
log "github.com/cihub/seelog"
|
||||||
httprouter "infini.sh/framework/core/api/router"
|
httprouter "infini.sh/framework/core/api/router"
|
||||||
"infini.sh/framework/core/elastic"
|
"infini.sh/framework/core/elastic"
|
||||||
"infini.sh/framework/core/util"
|
"infini.sh/framework/core/util"
|
||||||
"net/http"
|
"net/http"
|
||||||
"runtime/debug"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (handler APIHandler) HandleGetMappingsAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
func (handler APIHandler) HandleGetMappingsAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
||||||
|
@ -20,8 +20,9 @@ func (handler APIHandler) HandleGetMappingsAction(w http.ResponseWriter, req *ht
|
||||||
}
|
}
|
||||||
_, _, idxs, err := client.GetMapping(copyAll, indexName)
|
_, _, idxs, err := client.GetMapping(copyAll, indexName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
resBody["error"] = err
|
resBody["error"] = err
|
||||||
handler.WriteJSON(w, resBody, http.StatusOK)
|
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//if copyAll {
|
//if copyAll {
|
||||||
|
@ -41,8 +42,9 @@ func (handler APIHandler) HandleGetIndicesAction(w http.ResponseWriter, req *htt
|
||||||
catIndices, err := client.GetIndices("")
|
catIndices, err := client.GetIndices("")
|
||||||
resBody := util.MapStr{}
|
resBody := util.MapStr{}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
resBody["error"] = err
|
log.Error(err)
|
||||||
handler.WriteJSON(w, resBody, http.StatusOK)
|
resBody["error"] = err.Error()
|
||||||
|
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
handler.WriteJSON(w, catIndices, http.StatusOK)
|
handler.WriteJSON(w, catIndices, http.StatusOK)
|
||||||
|
@ -55,19 +57,15 @@ func (handler APIHandler) HandleGetSettingsAction(w http.ResponseWriter, req *ht
|
||||||
resBody := newResponseBody()
|
resBody := newResponseBody()
|
||||||
indexes, err := client.GetIndexSettings(indexName)
|
indexes, err := client.GetIndexSettings(indexName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
resBody["error"] = err
|
log.Error(err)
|
||||||
handler.WriteJSON(w, resBody, http.StatusOK)
|
resBody["error"] = err.Error()
|
||||||
|
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
handler.WriteJSON(w, indexes, http.StatusOK)
|
handler.WriteJSON(w, indexes, http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (handler APIHandler) HandleUpdateSettingsAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
func (handler APIHandler) HandleUpdateSettingsAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
||||||
defer func() {
|
|
||||||
if err := recover(); err != nil {
|
|
||||||
debug.PrintStack()
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
targetClusterID := ps.ByName("id")
|
targetClusterID := ps.ByName("id")
|
||||||
client := elastic.GetClient(targetClusterID)
|
client := elastic.GetClient(targetClusterID)
|
||||||
indexName := ps.ByName("index")
|
indexName := ps.ByName("index")
|
||||||
|
@ -75,18 +73,20 @@ func (handler APIHandler) HandleUpdateSettingsAction(w http.ResponseWriter, req
|
||||||
resBody := newResponseBody()
|
resBody := newResponseBody()
|
||||||
err := handler.DecodeJSON(req, &settings)
|
err := handler.DecodeJSON(req, &settings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
resBody["error"] = err
|
resBody["error"] = err
|
||||||
handler.WriteJSON(w, resBody, http.StatusOK)
|
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = client.UpdateIndexSettings(indexName, settings)
|
err = client.UpdateIndexSettings(indexName, settings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
resBody["error"] = err
|
resBody["error"] = err
|
||||||
handler.WriteJSON(w, resBody, http.StatusOK)
|
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resBody["result"] = "updated"
|
resBody["result"] = "updated"
|
||||||
handler.WriteJSON(w, resBody, http.StatusOK)
|
handler.WriteJSON(w, resBody, http.StatusCreated)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (handler APIHandler) HandleDeleteIndexAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
func (handler APIHandler) HandleDeleteIndexAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
||||||
|
@ -96,8 +96,9 @@ func (handler APIHandler) HandleDeleteIndexAction(w http.ResponseWriter, req *ht
|
||||||
resBody := newResponseBody()
|
resBody := newResponseBody()
|
||||||
err := client.DeleteIndex(indexName)
|
err := client.DeleteIndex(indexName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
resBody["error"] = err
|
resBody["error"] = err
|
||||||
handler.WriteJSON(w, resBody, http.StatusOK)
|
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resBody["result"] = "deleted"
|
resBody["result"] = "deleted"
|
||||||
|
@ -112,16 +113,18 @@ func (handler APIHandler) HandleCreateIndexAction(w http.ResponseWriter, req *ht
|
||||||
config := map[string]interface{}{}
|
config := map[string]interface{}{}
|
||||||
err := handler.DecodeJSON(req, &config)
|
err := handler.DecodeJSON(req, &config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
resBody["error"] = err
|
resBody["error"] = err
|
||||||
handler.WriteJSON(w, resBody, http.StatusOK)
|
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = client.CreateIndex(indexName, config)
|
err = client.CreateIndex(indexName, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
resBody["error"] = err
|
resBody["error"] = err
|
||||||
handler.WriteJSON(w, resBody, http.StatusOK)
|
handler.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resBody["result"] = "created"
|
resBody["result"] = "created"
|
||||||
handler.WriteJSON(w, resBody, http.StatusOK)
|
handler.WriteJSON(w, resBody, http.StatusCreated)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"infini.sh/framework/core/orm"
|
"infini.sh/framework/core/orm"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
log "github.com/cihub/seelog"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -24,8 +25,8 @@ func (handler APIHandler) HandleReindexAction(w http.ResponseWriter, req *http.R
|
||||||
|
|
||||||
err := handler.DecodeJSON(req, reindexItem)
|
err := handler.DecodeJSON(req, reindexItem)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
resResult["error"] = err
|
resResult["error"] = err
|
||||||
resResult["status"] = false
|
|
||||||
handler.WriteJSON(w, resResult, http.StatusOK)
|
handler.WriteJSON(w, resResult, http.StatusOK)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -34,8 +35,8 @@ func (handler APIHandler) HandleReindexAction(w http.ResponseWriter, req *http.R
|
||||||
typ := handler.GetParameter(req, "_type")
|
typ := handler.GetParameter(req, "_type")
|
||||||
ID, err := reindex(handler.Config.Elasticsearch, reindexItem, typ)
|
ID, err := reindex(handler.Config.Elasticsearch, reindexItem, typ)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
resResult["error"] = err
|
resResult["error"] = err
|
||||||
resResult["status"] = false
|
|
||||||
handler.WriteJSON(w, resResult, http.StatusOK)
|
handler.WriteJSON(w, resResult, http.StatusOK)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -95,8 +96,8 @@ func (handler APIHandler) HandleDeleteRebuildAction(w http.ResponseWriter, req *
|
||||||
resBody := newResponseBody()
|
resBody := newResponseBody()
|
||||||
err := deleteTasksByIds(handler.Config.Elasticsearch, ids)
|
err := deleteTasksByIds(handler.Config.Elasticsearch, ids)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
resBody["error"] = err
|
resBody["error"] = err
|
||||||
resBody["status"] = false
|
|
||||||
handler.WriteJSON(w, resBody, http.StatusOK)
|
handler.WriteJSON(w, resBody, http.StatusOK)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -105,11 +106,6 @@ func (handler APIHandler) HandleDeleteRebuildAction(w http.ResponseWriter, req *
|
||||||
}
|
}
|
||||||
|
|
||||||
func (handler APIHandler) HandleGetRebuildListAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
func (handler APIHandler) HandleGetRebuildListAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
||||||
defer func() {
|
|
||||||
if err := recover(); err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
var (
|
var (
|
||||||
from = handler.GetIntOrDefault(req, "from", 0)
|
from = handler.GetIntOrDefault(req, "from", 0)
|
||||||
size = handler.GetIntOrDefault(req, "size", 10)
|
size = handler.GetIntOrDefault(req, "size", 10)
|
||||||
|
@ -119,14 +115,14 @@ func (handler APIHandler) HandleGetRebuildListAction(w http.ResponseWriter, req
|
||||||
)
|
)
|
||||||
esResp, err := model.GetRebuildList(esName, from, size, name)
|
esResp, err := model.GetRebuildList(esName, from, size, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
resBody["error"] = err.Error()
|
resBody["error"] = err.Error()
|
||||||
resBody["status"] = false
|
|
||||||
handler.WriteJSON(w, resBody, http.StatusOK)
|
handler.WriteJSON(w, resBody, http.StatusOK)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = SyncRebuildResult(esName)
|
err = SyncRebuildResult(esName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
resBody["status"] = false
|
log.Error(err)
|
||||||
resBody["error"] = err
|
resBody["error"] = err
|
||||||
handler.WriteJSON(w, resBody, http.StatusOK)
|
handler.WriteJSON(w, resBody, http.StatusOK)
|
||||||
return
|
return
|
||||||
|
|
2
main.go
|
@ -105,7 +105,7 @@ func main() {
|
||||||
orm.RegisterSchemaWithIndexName(alerting.Alert{}, "alerting-alerts")
|
orm.RegisterSchemaWithIndexName(alerting.Alert{}, "alerting-alerts")
|
||||||
orm.RegisterSchemaWithIndexName(alerting.AlertingHistory{}, "alerting-alert-history")
|
orm.RegisterSchemaWithIndexName(alerting.AlertingHistory{}, "alerting-alert-history")
|
||||||
orm.RegisterSchema(elastic.CommonCommand{})
|
orm.RegisterSchema(elastic.CommonCommand{})
|
||||||
orm.RegisterSchemaWithIndexName(elastic.TraceMeta{}, "traces")
|
orm.RegisterSchemaWithIndexName(elastic.TraceTemplate{}, "trace-template")
|
||||||
alertSrv.GetScheduler().Start()
|
alertSrv.GetScheduler().Start()
|
||||||
},nil){
|
},nil){
|
||||||
app.Run()
|
app.Run()
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
write: true,
|
|
||||||
prefix: '^',
|
|
||||||
plugin: 'autod-egg',
|
|
||||||
test: [
|
|
||||||
'test',
|
|
||||||
'benchmark',
|
|
||||||
'script',
|
|
||||||
'.roadhogrc.mock.js',
|
|
||||||
],
|
|
||||||
dep: [
|
|
||||||
'egg',
|
|
||||||
'egg-scripts',
|
|
||||||
],
|
|
||||||
devdep: [
|
|
||||||
'egg-ci',
|
|
||||||
'egg-bin',
|
|
||||||
'egg-mock',
|
|
||||||
'autod',
|
|
||||||
'autod-egg',
|
|
||||||
'eslint',
|
|
||||||
'eslint-config-egg',
|
|
||||||
'webstorm-disable-index',
|
|
||||||
],
|
|
||||||
exclude: [
|
|
||||||
'./test/fixtures',
|
|
||||||
'./dist',
|
|
||||||
'**/*.test.js',
|
|
||||||
'**/*.e2e.js',
|
|
||||||
],
|
|
||||||
};
|
|
|
@ -1,5 +0,0 @@
|
||||||
.temp
|
|
||||||
.git
|
|
||||||
*.swp
|
|
||||||
node_modules/
|
|
||||||
.github/
|
|
|
@ -1,3 +0,0 @@
|
||||||
coverage
|
|
||||||
node_modules
|
|
||||||
app/public
|
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"extends": "eslint-config-egg"
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
module.exports = {
|
|
||||||
parser: 'babel-eslint',
|
|
||||||
extends: ['airbnb', 'prettier', 'plugin:compat/recommended'],
|
|
||||||
env: {
|
|
||||||
browser: true,
|
|
||||||
node: true,
|
|
||||||
es6: true,
|
|
||||||
mocha: true,
|
|
||||||
jest: true,
|
|
||||||
jasmine: true,
|
|
||||||
},
|
|
||||||
globals: {
|
|
||||||
APP_TYPE: true,
|
|
||||||
},
|
|
||||||
rules: {
|
|
||||||
'react/jsx-filename-extension': [1, { extensions: ['.js'] }],
|
|
||||||
'react/jsx-wrap-multilines': 0,
|
|
||||||
'react/prop-types': 0,
|
|
||||||
'react/forbid-prop-types': 0,
|
|
||||||
'react/jsx-one-expression-per-line': 0,
|
|
||||||
'import/no-unresolved': [2, { ignore: ['^@/', '^umi/'] }],
|
|
||||||
'import/no-extraneous-dependencies': [2, { optionalDependencies: true }],
|
|
||||||
'jsx-a11y/no-noninteractive-element-interactions': 0,
|
|
||||||
'jsx-a11y/click-events-have-key-events': 0,
|
|
||||||
'jsx-a11y/no-static-element-interactions': 0,
|
|
||||||
'jsx-a11y/anchor-is-valid': 0,
|
|
||||||
'linebreak-style': 0,
|
|
||||||
},
|
|
||||||
settings: {
|
|
||||||
polyfills: ['fetch', 'promises', 'url'],
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -1,136 +0,0 @@
|
||||||
// https://umijs.org/config/
|
|
||||||
import os from 'os';
|
|
||||||
import pageRoutes from './router.config';
|
|
||||||
import webpackPlugin from './plugin.config';
|
|
||||||
import defaultSettings from '../src/defaultSettings';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
// add for transfer to umi
|
|
||||||
plugins: [
|
|
||||||
[
|
|
||||||
'umi-plugin-react',
|
|
||||||
{
|
|
||||||
antd: true,
|
|
||||||
dva: {
|
|
||||||
hmr: true,
|
|
||||||
},
|
|
||||||
targets: {
|
|
||||||
ie: 11,
|
|
||||||
},
|
|
||||||
locale: {
|
|
||||||
enable: true, // default false
|
|
||||||
default: 'zh-CN', // default zh-CN
|
|
||||||
baseNavigator: true, // default true, when it is true, will use `navigator.language` overwrite default
|
|
||||||
},
|
|
||||||
dynamicImport: {
|
|
||||||
loadingComponent: './components/PageLoading/index',
|
|
||||||
},
|
|
||||||
...(!process.env.TEST && os.platform() === 'darwin'
|
|
||||||
? {
|
|
||||||
dll: {
|
|
||||||
include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
|
|
||||||
exclude: ['@babel/runtime'],
|
|
||||||
},
|
|
||||||
hardSource: false,
|
|
||||||
}
|
|
||||||
: {}),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'umi-plugin-ga',
|
|
||||||
{
|
|
||||||
code: 'UA-12123-6',
|
|
||||||
judge: () => process.env.APP_TYPE === 'site',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
],
|
|
||||||
targets: {
|
|
||||||
ie: 11,
|
|
||||||
},
|
|
||||||
define: {
|
|
||||||
APP_TYPE: process.env.APP_TYPE || '',
|
|
||||||
ENV: process.env.NODE_ENV,
|
|
||||||
API_ENDPOINT: process.env.API_ENDPOINT || '',
|
|
||||||
},
|
|
||||||
// 路由配置
|
|
||||||
routes: pageRoutes,
|
|
||||||
// Theme for antd
|
|
||||||
// https://ant.design/docs/react/customize-theme-cn
|
|
||||||
theme: {
|
|
||||||
'primary-color': defaultSettings.primaryColor,
|
|
||||||
},
|
|
||||||
externals: {
|
|
||||||
'@antv/data-set': 'DataSet',
|
|
||||||
},
|
|
||||||
// proxy: {
|
|
||||||
// '/server/api/': {
|
|
||||||
// target: 'https://preview.pro.ant.design/',
|
|
||||||
// changeOrigin: true,
|
|
||||||
// pathRewrite: { '^/server': '' },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
proxy: {
|
|
||||||
'/elasticsearch/': {
|
|
||||||
target: 'http://localhost:9000',
|
|
||||||
changeOrigin: true,
|
|
||||||
// pathRewrite: { '^/server': '' },
|
|
||||||
},
|
|
||||||
'/_search-center/': {
|
|
||||||
target: 'http://localhost:9000',
|
|
||||||
changeOrigin: true,
|
|
||||||
// pathRewrite: { '^/server': '' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
ignoreMomentLocale: true,
|
|
||||||
lessLoaderOptions: {
|
|
||||||
javascriptEnabled: true,
|
|
||||||
},
|
|
||||||
disableRedirectHoist: true,
|
|
||||||
cssLoaderOptions: {
|
|
||||||
modules: true,
|
|
||||||
getLocalIdent: (context, localIdentName, localName) => {
|
|
||||||
if (
|
|
||||||
context.resourcePath.includes('node_modules') ||
|
|
||||||
context.resourcePath.includes('ant.design.pro.less') ||
|
|
||||||
context.resourcePath.includes('global.less') ||
|
|
||||||
context.resourcePath.includes('.scss')
|
|
||||||
) {
|
|
||||||
return localName;
|
|
||||||
}
|
|
||||||
const match = context.resourcePath.match(/src(.*)/);
|
|
||||||
if (match && match[1]) {
|
|
||||||
const antdProPath = match[1].replace('.less', '');
|
|
||||||
const arr = antdProPath
|
|
||||||
.split('/')
|
|
||||||
.map(a => a.replace(/([A-Z])/g, '-$1'))
|
|
||||||
.map(a => a.toLowerCase());
|
|
||||||
return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
|
|
||||||
}
|
|
||||||
return localName;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
// chainWebpack: webpackPlugin,
|
|
||||||
cssnano: {
|
|
||||||
mergeRules: false,
|
|
||||||
},
|
|
||||||
|
|
||||||
// extra configuration for egg
|
|
||||||
runtimePublicPath: true,
|
|
||||||
hash: true,
|
|
||||||
outputPath: '../.public',
|
|
||||||
manifest: {
|
|
||||||
fileName: '../.public/manifest.json',
|
|
||||||
publicPath: '',
|
|
||||||
},
|
|
||||||
|
|
||||||
copy:[
|
|
||||||
'./src/assets/favicon.ico',
|
|
||||||
],
|
|
||||||
history: 'hash',
|
|
||||||
// exportStatic: {
|
|
||||||
// // htmlSuffix: true,
|
|
||||||
// dynamicRoot: true,
|
|
||||||
// },
|
|
||||||
sass: { },
|
|
||||||
};
|
|
|
@ -1,28 +0,0 @@
|
||||||
// Change theme plugin
|
|
||||||
|
|
||||||
import MergeLessPlugin from 'antd-pro-merge-less';
|
|
||||||
import AntDesignThemePlugin from 'antd-theme-webpack-plugin';
|
|
||||||
import path from 'path';
|
|
||||||
|
|
||||||
export default config => {
|
|
||||||
// 将所有 less 合并为一个供 themePlugin使用
|
|
||||||
const outFile = path.join(__dirname, '../.temp/ant-design-pro.less');
|
|
||||||
const stylesDir = path.join(__dirname, '../src/');
|
|
||||||
|
|
||||||
config.plugin('merge-less').use(MergeLessPlugin, [
|
|
||||||
{
|
|
||||||
stylesDir,
|
|
||||||
outFile,
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
config.plugin('ant-design-theme').use(AntDesignThemePlugin, [
|
|
||||||
{
|
|
||||||
antDir: require.resolve('antd').replace('lib/index.js', ''),
|
|
||||||
stylesDir,
|
|
||||||
varFile: require.resolve('antd/lib/style/themes/default.less'),
|
|
||||||
mainLessFile: outFile, // themeVariables: ['@primary-color'],
|
|
||||||
indexFileName: 'index.html',
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
};
|
|
|
@ -1,757 +0,0 @@
|
||||||
export default [
|
|
||||||
// user
|
|
||||||
{
|
|
||||||
path: "/user",
|
|
||||||
component: "../layouts/UserLayout",
|
|
||||||
routes: [
|
|
||||||
{ path: "/user", redirect: "/user/login" },
|
|
||||||
{ path: "/user/login", component: "./User/Login" },
|
|
||||||
{ path: "/user/register", component: "./User/Register" },
|
|
||||||
{ path: "/user/register-result", component: "./User/RegisterResult" },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
// app
|
|
||||||
{
|
|
||||||
path: "/",
|
|
||||||
component: "../layouts/BasicLayout",
|
|
||||||
Routes: ["src/pages/Authorized"],
|
|
||||||
authority: ["admin", "user"],
|
|
||||||
routes: [
|
|
||||||
// cluster
|
|
||||||
{ path: "/", redirect: "/cluster/metrics" },
|
|
||||||
{
|
|
||||||
path: "/cluster",
|
|
||||||
name: "cluster",
|
|
||||||
icon: "cluster",
|
|
||||||
routes: [
|
|
||||||
// { path: '/', redirect: '/platform/gateway' },
|
|
||||||
// {
|
|
||||||
// path: '/cluster/overview/',
|
|
||||||
// name: 'overview',
|
|
||||||
// component: './Cluster/Overview',
|
|
||||||
// routes:[
|
|
||||||
// { path: '/', redirect: '/' },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: "/cluster/overview",
|
|
||||||
// name: "overview",
|
|
||||||
// component: "./Cluster/NewOverview",
|
|
||||||
// // hideInMenu: true,
|
|
||||||
// routes: [{ path: "/", redirect: "/" }],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: "/cluster/monitoring/:cluster_id",
|
|
||||||
// name: "cluster",
|
|
||||||
// component: "./Cluster/ClusterMonitor",
|
|
||||||
// hideInMenu: true,
|
|
||||||
// routes: [{ path: "/", redirect: "/" }],
|
|
||||||
// },
|
|
||||||
{
|
|
||||||
path: "/cluster/metrics/",
|
|
||||||
name: "monitoring",
|
|
||||||
component: "./Cluster/Metrics",
|
|
||||||
routes: [{ path: "/", redirect: "/" }],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/cluster/metrics/:cluster_id",
|
|
||||||
name: "monitoring",
|
|
||||||
component: "./Cluster/Metrics",
|
|
||||||
hideInMenu: true,
|
|
||||||
},
|
|
||||||
// {
|
|
||||||
// path: '/cluster/logs/',
|
|
||||||
// name: 'logging',
|
|
||||||
// component: './Cluster/SearchMonitor',
|
|
||||||
// routes:[
|
|
||||||
// { path: '/', redirect: '/' },
|
|
||||||
// ],
|
|
||||||
// },{
|
|
||||||
// path: '/cluster/settings/',
|
|
||||||
// name: 'settings',
|
|
||||||
// component: './Cluster/Settings/Base',
|
|
||||||
// routes: [
|
|
||||||
// {
|
|
||||||
// path: '/cluster/settings',
|
|
||||||
// redirect: '/cluster/settings/repository',
|
|
||||||
// routes:[
|
|
||||||
// { path: '/', redirect: '/' },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/cluster/settings/repository',
|
|
||||||
// component: './Cluster/Settings/Repository',
|
|
||||||
// routes:[
|
|
||||||
// { path: '/', redirect: '/' },
|
|
||||||
// ],
|
|
||||||
// }
|
|
||||||
// ]
|
|
||||||
// },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
//devtools
|
|
||||||
// {
|
|
||||||
// routes:[
|
|
||||||
// { path: '/', redirect: '/' },
|
|
||||||
// ],
|
|
||||||
// path: '/dev_tool',
|
|
||||||
// name: 'devtool',
|
|
||||||
// icon: 'code',
|
|
||||||
// component: './DevTool/Console',
|
|
||||||
// },
|
|
||||||
|
|
||||||
//alerting
|
|
||||||
// {
|
|
||||||
// path: "/alerting",
|
|
||||||
// name: "alerting",
|
|
||||||
// icon: "alert",
|
|
||||||
// routes: [
|
|
||||||
// {
|
|
||||||
// routes: [{ path: "/", redirect: "/" }],
|
|
||||||
// path: "/alerting/overview",
|
|
||||||
// component: "./Alerting/pages/Overview/Overview",
|
|
||||||
// name: "overview",
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// routes: [{ path: "/", redirect: "/" }],
|
|
||||||
// path: "/alerting/monitor",
|
|
||||||
// component: "./Alerting/index",
|
|
||||||
// name: "monitor",
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// routes: [{ path: "/", redirect: "/" }],
|
|
||||||
// path: "/alerting/destination",
|
|
||||||
// component: "./Alerting/destination",
|
|
||||||
// name: "destination",
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
|
|
||||||
// data
|
|
||||||
{
|
|
||||||
path: "/data",
|
|
||||||
name: "data",
|
|
||||||
icon: "database",
|
|
||||||
routes: [
|
|
||||||
// {
|
|
||||||
// path: '/data/overview',
|
|
||||||
// name: 'overview',
|
|
||||||
// component: './DataManagement/IndexSummary',
|
|
||||||
// routes:[
|
|
||||||
// { path: '/', redirect: '/' },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
{
|
|
||||||
path: "/data/index",
|
|
||||||
name: "index",
|
|
||||||
component: "./DataManagement/Index",
|
|
||||||
routes: [{ path: "/", redirect: "/" }],
|
|
||||||
},
|
|
||||||
// {
|
|
||||||
// path: '/data/document',
|
|
||||||
// name: 'document',
|
|
||||||
// component: './DataManagement/Document',
|
|
||||||
// routes:[
|
|
||||||
// { path: '/', redirect: '/' },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/data/template',
|
|
||||||
// name: 'template',
|
|
||||||
// component: './DataManagement/IndexTemplate',
|
|
||||||
// routes:[
|
|
||||||
// { path: '/', redirect: '/' },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/data/lifecycle',
|
|
||||||
// name: 'lifecycle',
|
|
||||||
// component: './DataManagement/IndexLifeCycle',
|
|
||||||
// routes:[
|
|
||||||
// { path: '/', redirect: '/' },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
{
|
|
||||||
routes: [{ path: "/", redirect: "/" }],
|
|
||||||
path: "/data/discover",
|
|
||||||
name: "discover",
|
|
||||||
component: "./DataManagement/Discover",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
routes: [{ path: "/", redirect: "/" }],
|
|
||||||
path: "/data/views/",
|
|
||||||
name: "indexPatterns",
|
|
||||||
component: "./DataManagement/IndexPatterns",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
|
|
||||||
//search
|
|
||||||
// {
|
|
||||||
// path: "/search",
|
|
||||||
// name: "search",
|
|
||||||
// icon: "search",
|
|
||||||
// routes: [
|
|
||||||
// // {
|
|
||||||
// // path: '/search/overview',
|
|
||||||
// // name: 'overview',
|
|
||||||
// // component: './SearchManage/template/Template',
|
|
||||||
// // routes:[
|
|
||||||
// // { path: '/', redirect: '/' },
|
|
||||||
// // ],
|
|
||||||
// // },
|
|
||||||
// // {
|
|
||||||
// // path: '/search/template',
|
|
||||||
// // name: 'template',
|
|
||||||
// // component: './SearchManage/template/Template',
|
|
||||||
// // routes: [
|
|
||||||
// // {
|
|
||||||
// // path: '/search/template',
|
|
||||||
// // redirect: '/search/template/template',
|
|
||||||
// // },
|
|
||||||
// // {
|
|
||||||
// // path: '/search/template/template',
|
|
||||||
// // component: './SearchManage/template/SearchTemplate',
|
|
||||||
// // routes:[
|
|
||||||
// // { path: '/', redirect: '/' },
|
|
||||||
// // ],
|
|
||||||
// // },
|
|
||||||
// // {
|
|
||||||
// // path: '/search/template/:cluster_id',
|
|
||||||
// // component: './SearchManage/template/SearchTemplate',
|
|
||||||
// // routes:[
|
|
||||||
// // { path: '/', redirect: '/' },
|
|
||||||
// // ],
|
|
||||||
// // },
|
|
||||||
// // {
|
|
||||||
// // path: '/search/template/history',
|
|
||||||
// // component: './SearchManage/template/History',
|
|
||||||
// // routes:[
|
|
||||||
// // { path: '/', redirect: '/' },
|
|
||||||
// // ],
|
|
||||||
// // },
|
|
||||||
// // ]
|
|
||||||
// // },
|
|
||||||
// {
|
|
||||||
// path: "/search/alias",
|
|
||||||
// name: "alias",
|
|
||||||
// component: "./SearchManage/alias/Alias",
|
|
||||||
// routes: [
|
|
||||||
// {
|
|
||||||
// path: "/search/alias",
|
|
||||||
// redirect: "/search/alias/index",
|
|
||||||
// // routes:[
|
|
||||||
// // { path: '/', redirect: '/' },
|
|
||||||
// // ],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: "/search/alias/index",
|
|
||||||
// component: "./SearchManage/alias/AliasManage",
|
|
||||||
// routes: [{ path: "/", redirect: "/" }],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: "/search/alias/rule",
|
|
||||||
// component: "./SearchManage/alias/Rule",
|
|
||||||
// routes: [{ path: "/", redirect: "/" }],
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// // {
|
|
||||||
// // path: '/search/dict',
|
|
||||||
// // name: 'dict',
|
|
||||||
// // component: './SearchManage/dict/Dict',
|
|
||||||
// // routes: [
|
|
||||||
// // {
|
|
||||||
// // path: '/search/dict',
|
|
||||||
// // redirect: '/search/dict/professional',
|
|
||||||
// // // routes:[
|
|
||||||
// // // { path: '/', redirect: '/' },
|
|
||||||
// // // ],
|
|
||||||
// // },
|
|
||||||
// // {
|
|
||||||
// // path: '/search/dict/professional',
|
|
||||||
// // component: './SearchManage/dict/Pro',
|
|
||||||
// // routes:[
|
|
||||||
// // { path: '/', redirect: '/' },
|
|
||||||
// // ],
|
|
||||||
// // },
|
|
||||||
// // {
|
|
||||||
// // path: '/search/dict/common',
|
|
||||||
// // component: './SearchManage/dict/Common',
|
|
||||||
// // routes:[
|
|
||||||
// // { path: '/', redirect: '/' },
|
|
||||||
// // ],
|
|
||||||
// // }
|
|
||||||
// // ]
|
|
||||||
// // },
|
|
||||||
// // {
|
|
||||||
// // path: '/search/analyzer',
|
|
||||||
// // name: 'analyzer',
|
|
||||||
// // component: './SearchManage/analyzer/Analyzer',
|
|
||||||
// // routes: [
|
|
||||||
// // {
|
|
||||||
// // path: '/search/analyzer',
|
|
||||||
// // redirect: '/search/analyzer/manage',
|
|
||||||
// // },
|
|
||||||
// // {
|
|
||||||
// // path: '/search/analyzer/manage',
|
|
||||||
// // component: './SearchManage/analyzer/Manage',
|
|
||||||
// // routes:[
|
|
||||||
// // { path: '/', redirect: '/' },
|
|
||||||
// // ],
|
|
||||||
// // },
|
|
||||||
// // {
|
|
||||||
// // path: '/search/analyzer/test',
|
|
||||||
// // component: './SearchManage/analyzer/AnalyzerTest',
|
|
||||||
// // routes:[
|
|
||||||
// // { path: '/', redirect: '/' },
|
|
||||||
// // ],
|
|
||||||
// // }
|
|
||||||
// // ]
|
|
||||||
// // }
|
|
||||||
// //, {
|
|
||||||
// // path: '/search/nlp',
|
|
||||||
// // name: 'nlp',
|
|
||||||
// // component: './SearchManage/nlp/NLP',
|
|
||||||
// // routes: [
|
|
||||||
// // {
|
|
||||||
// // path: '/search/nlp',
|
|
||||||
// // redirect: '/search/nlp/query',
|
|
||||||
// // },
|
|
||||||
// // {
|
|
||||||
// // path: '/search/nlp/query',
|
|
||||||
// // component: './SearchManage/nlp/Query',
|
|
||||||
// // },
|
|
||||||
// // {
|
|
||||||
// // path: '/search/nlp/intention',
|
|
||||||
// // component: './SearchManage/nlp/Intention',
|
|
||||||
// // },
|
|
||||||
// // {
|
|
||||||
// // path: '/search/nlp/knowledge',
|
|
||||||
// // component: './SearchManage/nlp/Knowledge',
|
|
||||||
// // },
|
|
||||||
// // {
|
|
||||||
// // path: '/search/nlp/text',
|
|
||||||
// // component: './SearchManage/nlp/Text',
|
|
||||||
// // }
|
|
||||||
// //]
|
|
||||||
// //},
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
//
|
|
||||||
// //sync
|
|
||||||
// {
|
|
||||||
// path: '/sync',
|
|
||||||
// name: 'synchronize',
|
|
||||||
// icon: 'sync',
|
|
||||||
// routes: [
|
|
||||||
// {
|
|
||||||
// path: '/sync/overview',
|
|
||||||
// name: 'overview',
|
|
||||||
// component: './Synchronize/Pipes',
|
|
||||||
// routes:[
|
|
||||||
// { path: '/', redirect: '/' },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/sync/pipeline',
|
|
||||||
// name: 'pipeline',
|
|
||||||
// component: './Synchronize/Pipes',
|
|
||||||
// routes: [
|
|
||||||
// {
|
|
||||||
// path: '/sync/pipeline',
|
|
||||||
// redirect: '/sync/pipeline/logstash',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/sync/pipeline/ingestpipeline',
|
|
||||||
// component: './Synchronize/IngestPipeline',
|
|
||||||
// routes:[
|
|
||||||
// { path: '/', redirect: '/' },
|
|
||||||
// ],
|
|
||||||
// }, {
|
|
||||||
// path: '/sync/pipeline/logstash',
|
|
||||||
// component: './Synchronize/LogstashConfig',
|
|
||||||
// routes:[
|
|
||||||
// { path: '/', redirect: '/' },
|
|
||||||
// ],
|
|
||||||
// }]
|
|
||||||
// },{
|
|
||||||
// path: '/sync/rebuild',
|
|
||||||
// name: 'rebuild',
|
|
||||||
// component: './Synchronize/RebuildList',
|
|
||||||
// routes:[
|
|
||||||
// { path: '/', redirect: '/' },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/sync/rebuild/new',
|
|
||||||
// component: './Synchronize/Rebuild',
|
|
||||||
// hideInMenu: true,
|
|
||||||
// },{
|
|
||||||
// path: '/sync/inout',
|
|
||||||
// name: 'inout',
|
|
||||||
// component: './Synchronize/Import',
|
|
||||||
// routes:[
|
|
||||||
// { path: '/', redirect: '/' },
|
|
||||||
// ],
|
|
||||||
// }
|
|
||||||
// ]
|
|
||||||
// },
|
|
||||||
//
|
|
||||||
// //backup
|
|
||||||
// {
|
|
||||||
// path: '/backup',
|
|
||||||
// name: 'backup',
|
|
||||||
// icon: 'cloud',
|
|
||||||
// routes: [
|
|
||||||
// {
|
|
||||||
// path: '/backup/overview',
|
|
||||||
// name: 'overview',
|
|
||||||
// component: './SearchManage/template/Template',
|
|
||||||
// routes:[
|
|
||||||
// { path: '/', redirect: '/' },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/backup/bakandrestore',
|
|
||||||
// name: 'index',
|
|
||||||
// component: './Backup/BakAndRestore',
|
|
||||||
// routes:[
|
|
||||||
// { path: '/', redirect: '/' },
|
|
||||||
// ],
|
|
||||||
// },{
|
|
||||||
// path: '/backup/lifecycle',
|
|
||||||
// name: 'lifecycle',
|
|
||||||
// component: './Backup/BakCycle',
|
|
||||||
// routes:[
|
|
||||||
// { path: '/', redirect: '/' },
|
|
||||||
// ],
|
|
||||||
// }
|
|
||||||
// ]
|
|
||||||
// },
|
|
||||||
|
|
||||||
//settings
|
|
||||||
{
|
|
||||||
path: "/system",
|
|
||||||
name: "system",
|
|
||||||
icon: "setting",
|
|
||||||
routes: [
|
|
||||||
{
|
|
||||||
path: "/system/cluster",
|
|
||||||
name: "cluster",
|
|
||||||
component: "./System/Cluster/Index",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/system/cluster/regist",
|
|
||||||
name: "registCluster",
|
|
||||||
component: "./System/Cluster/Step",
|
|
||||||
hideInMenu: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/system/cluster/:id/edit",
|
|
||||||
name: "editCluster",
|
|
||||||
component: "./System/Cluster/Form",
|
|
||||||
hideInMenu: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/system/command",
|
|
||||||
name: "commonCommand",
|
|
||||||
component: "./System/Command/Index",
|
|
||||||
// hideInMenu: true
|
|
||||||
},
|
|
||||||
// {
|
|
||||||
// path: '/system/settings',
|
|
||||||
// name: 'settings',
|
|
||||||
// component: './System/Settings/Base',
|
|
||||||
// hideChildrenInMenu: true,
|
|
||||||
// routes: [
|
|
||||||
// {
|
|
||||||
// path: '/system/settings',
|
|
||||||
// redirect: '/system/settings/global',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/system/settings/global',
|
|
||||||
// component: './System/Settings/Global',
|
|
||||||
// }, {
|
|
||||||
// path: '/system/settings/gateway',
|
|
||||||
// component: './System/Settings/Gateway',
|
|
||||||
// },
|
|
||||||
// ]
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/system/security',
|
|
||||||
// name: 'security',
|
|
||||||
// component: './System/Security/Base',
|
|
||||||
// hideChildrenInMenu: true,
|
|
||||||
// routes: [
|
|
||||||
// {
|
|
||||||
// path: '/system/security',
|
|
||||||
// redirect: '/system/security/general',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/system/security/general',
|
|
||||||
// component: './System/Security/General',
|
|
||||||
// }, {
|
|
||||||
// path: '/system/security/sso',
|
|
||||||
// component: './System/Security/SSO',
|
|
||||||
// }, {
|
|
||||||
// path: '/system/security/roles',
|
|
||||||
// component: './System/Security/Roles',
|
|
||||||
// }, {
|
|
||||||
// path: '/system/security/users',
|
|
||||||
// component: './System/Security/Users',
|
|
||||||
// }, {
|
|
||||||
// path: '/system/security/certs',
|
|
||||||
// component: './System/Security/Certs',
|
|
||||||
// },
|
|
||||||
// ]
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/system/logs',
|
|
||||||
// name: 'logs',
|
|
||||||
// component: './System/Logs/Base',
|
|
||||||
// hideChildrenInMenu: true,
|
|
||||||
// routes: [
|
|
||||||
// {
|
|
||||||
// path: '/system/logs',
|
|
||||||
// redirect: '/system/logs/overview',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/system/logs/overview',
|
|
||||||
// component: './System/Logs/Overview',
|
|
||||||
// }, {
|
|
||||||
// path: '/system/logs/audit',
|
|
||||||
// component: './System/Logs/Audit',
|
|
||||||
// }, {
|
|
||||||
// path: '/system/logs/query',
|
|
||||||
// component: './System/Logs/Audit',
|
|
||||||
// }, {
|
|
||||||
// path: '/system/logs/slow',
|
|
||||||
// component: './System/Logs/Audit',
|
|
||||||
// },
|
|
||||||
// ]
|
|
||||||
// },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
|
|
||||||
// // forms
|
|
||||||
// {
|
|
||||||
// path: '/form',
|
|
||||||
// icon: 'form',
|
|
||||||
// name: 'form',
|
|
||||||
// routes: [
|
|
||||||
// {
|
|
||||||
// path: '/form/basic-form',
|
|
||||||
// name: 'basicform',
|
|
||||||
// component: './Forms/BasicForm',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/form/step-form',
|
|
||||||
// name: 'stepform',
|
|
||||||
// component: './Forms/StepForm',
|
|
||||||
// hideChildrenInMenu: true,
|
|
||||||
// routes: [
|
|
||||||
// {
|
|
||||||
// path: '/form/step-form',
|
|
||||||
// name: 'stepform',
|
|
||||||
// redirect: '/form/step-form/info',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/form/step-form/info',
|
|
||||||
// name: 'info',
|
|
||||||
// component: './Forms/StepForm/Step1',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/form/step-form/confirm',
|
|
||||||
// name: 'confirm',
|
|
||||||
// component: './Forms/StepForm/Step2',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/form/step-form/result',
|
|
||||||
// name: 'result',
|
|
||||||
// component: './Forms/StepForm/Step3',
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/form/advanced-form',
|
|
||||||
// name: 'advancedform',
|
|
||||||
// authority: ['admin'],
|
|
||||||
// component: './Forms/AdvancedForm',
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// // list
|
|
||||||
// {
|
|
||||||
// path: '/list',
|
|
||||||
// icon: 'table',
|
|
||||||
// name: 'list',
|
|
||||||
// routes: [
|
|
||||||
// {
|
|
||||||
// path: '/list/table-list',
|
|
||||||
// name: 'searchtable',
|
|
||||||
// component: './List/TableList',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/list/basic-list',
|
|
||||||
// name: 'basiclist',
|
|
||||||
// component: './List/BasicList',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/list/card-list',
|
|
||||||
// name: 'cardlist',
|
|
||||||
// component: './List/CardList',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/list/search',
|
|
||||||
// name: 'searchlist',
|
|
||||||
// component: './List/List',
|
|
||||||
// routes: [
|
|
||||||
// {
|
|
||||||
// path: '/list/search',
|
|
||||||
// redirect: '/list/search/articles',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/list/search/articles',
|
|
||||||
// name: 'articles',
|
|
||||||
// component: './List/Articles',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/list/search/projects',
|
|
||||||
// name: 'projects',
|
|
||||||
// component: './List/Projects',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/list/search/applications',
|
|
||||||
// name: 'applications',
|
|
||||||
// component: './List/Applications',
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/profile',
|
|
||||||
// name: 'profile',
|
|
||||||
// icon: 'profile',
|
|
||||||
// routes: [
|
|
||||||
// // profile
|
|
||||||
// {
|
|
||||||
// path: '/profile/basic',
|
|
||||||
// name: 'basic',
|
|
||||||
// component: './Profile/BasicProfile',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/profile/advanced',
|
|
||||||
// name: 'advanced',
|
|
||||||
// authority: ['admin'],
|
|
||||||
// component: './Profile/AdvancedProfile',
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// name: 'result',
|
|
||||||
// icon: 'check-circle-o',
|
|
||||||
// path: '/result',
|
|
||||||
// routes: [
|
|
||||||
// // result
|
|
||||||
// {
|
|
||||||
// path: '/result/success',
|
|
||||||
// name: 'success',
|
|
||||||
// component: './Result/Success',
|
|
||||||
// },
|
|
||||||
// { path: '/result/fail', name: 'fail', component: './Result/Error' },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// name: 'exception',
|
|
||||||
// icon: 'warning',
|
|
||||||
// path: '/exception',
|
|
||||||
// routes: [
|
|
||||||
// // exception
|
|
||||||
// {
|
|
||||||
// path: '/exception/403',
|
|
||||||
// name: 'not-permission',
|
|
||||||
// component: './Exception/403',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/exception/404',
|
|
||||||
// name: 'not-find',
|
|
||||||
// component: './Exception/404',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/exception/500',
|
|
||||||
// name: 'server-error',
|
|
||||||
// component: './Exception/500',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/exception/trigger',
|
|
||||||
// name: 'trigger',
|
|
||||||
// hideInMenu: true,
|
|
||||||
// component: './Exception/TriggerException',
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// name: 'account',
|
|
||||||
// icon: 'user',
|
|
||||||
// path: '/account',
|
|
||||||
// routes: [
|
|
||||||
// {
|
|
||||||
// path: '/account/center',
|
|
||||||
// name: 'center',
|
|
||||||
// component: './Account/Center/Center',
|
|
||||||
// routes: [
|
|
||||||
// {
|
|
||||||
// path: '/account/center',
|
|
||||||
// redirect: '/account/center/articles',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/account/center/articles',
|
|
||||||
// component: './Account/Center/Articles',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/account/center/applications',
|
|
||||||
// component: './Account/Center/Applications',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/account/center/projects',
|
|
||||||
// component: './Account/Center/Projects',
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/account/settings',
|
|
||||||
// name: 'settings',
|
|
||||||
// component: './Account/Settings/Info',
|
|
||||||
// routes: [
|
|
||||||
// {
|
|
||||||
// path: '/account/settings',
|
|
||||||
// redirect: '/account/settings/base',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/account/settings/base',
|
|
||||||
// component: './Account/Settings/BaseView',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/account/settings/security',
|
|
||||||
// component: './Account/Settings/SecurityView',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/account/settings/binding',
|
|
||||||
// component: './Account/Settings/BindingView',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/account/settings/notification',
|
|
||||||
// component: './Account/Settings/NotificationView',
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
{
|
|
||||||
component: "404",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
];
|
|
|
@ -1,31 +0,0 @@
|
||||||
FROM alpine:latest
|
|
||||||
|
|
||||||
ENV TIME_ZONE=Asia/Shanghai
|
|
||||||
|
|
||||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
|
|
||||||
&& apk update \
|
|
||||||
&& apk add --no-cache shadow git nodejs nodejs-current-npm bash vim tar curl python python-dev py-pip gcc g++ libcurl make\
|
|
||||||
&& usermod -s /bin/bash root \
|
|
||||||
&& rm -rf /var/cache/apk/*
|
|
||||||
|
|
||||||
|
|
||||||
RUN \
|
|
||||||
mkdir -p /usr/src/app \
|
|
||||||
&& apk add --no-cache tzdata \
|
|
||||||
&& echo "${TIME_ZONE}" > /etc/timezone \
|
|
||||||
&& ln -sf /usr/share/zoneinfo/${TIME_ZONE} /etc/localtime
|
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
|
||||||
|
|
||||||
#COPY package.json /usr/src/app/
|
|
||||||
COPY ./entrypoint.sh /
|
|
||||||
|
|
||||||
|
|
||||||
#RUN npm install --registry=https://registry.npm.taobao.org
|
|
||||||
|
|
||||||
# COPY . /usr/src/app
|
|
||||||
|
|
||||||
EXPOSE 10000
|
|
||||||
|
|
||||||
#CMD npm run dev
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
|
|
@ -1,23 +0,0 @@
|
||||||
version: "3.5"
|
|
||||||
|
|
||||||
services:
|
|
||||||
infini-search-center-ui-dev:
|
|
||||||
# option 1: pull image from infini docker registry
|
|
||||||
image: docker.infini.ltd:64443/nodejs-dev:latest
|
|
||||||
|
|
||||||
# option 2: build image locally
|
|
||||||
# build:
|
|
||||||
# context: ./
|
|
||||||
# dockerfile: ./Dockerfile
|
|
||||||
|
|
||||||
container_name: "infini-search-center-ui-dev"
|
|
||||||
volumes:
|
|
||||||
- ../src:/usr/src/app/src
|
|
||||||
- ../config:/usr/src/app/config
|
|
||||||
- ../mock:/usr/src/app/mock
|
|
||||||
- ../package.json:/usr/src/app/package.json
|
|
||||||
- ../../.public:/usr/src/.public
|
|
||||||
- ./entrypoint-build.sh:/entrypoint.sh
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
dist:
|
|
|
@ -1,25 +0,0 @@
|
||||||
version: "3.5"
|
|
||||||
|
|
||||||
services:
|
|
||||||
infini-search-center-ui-build:
|
|
||||||
# option 1: pull image from infini docker registry
|
|
||||||
image: docker.infini.ltd:64443/nodejs-dev:latest
|
|
||||||
|
|
||||||
# # option 2: build image locally
|
|
||||||
# build:
|
|
||||||
# context: ./
|
|
||||||
# dockerfile: ./Dockerfile
|
|
||||||
|
|
||||||
ports:
|
|
||||||
- 3010:3000
|
|
||||||
- 8010:8000
|
|
||||||
container_name: "infini-search-center-ui-build"
|
|
||||||
volumes:
|
|
||||||
- ../src:/usr/src/app/src
|
|
||||||
- ../config:/usr/src/app/config
|
|
||||||
- ../mock:/usr/src/app/mock
|
|
||||||
- ../package.json:/usr/src/app/package.json
|
|
||||||
- ./entrypoint-dev.sh:/entrypoint.sh
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
dist:
|
|
|
@ -1,10 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
npm config set registry http://registry.npm.taobao.org/;
|
|
||||||
|
|
||||||
cd /usr/src/app
|
|
||||||
|
|
||||||
echo "START TO RELEASE INFINI-SEARCH-CENTER"
|
|
||||||
|
|
||||||
npm install --registry=https://registry.npm.taobao.org
|
|
||||||
npm run build
|
|
|
@ -1,16 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
lockPath="/tmp/init.lock"
|
|
||||||
|
|
||||||
npm config set registry http://registry.npm.taobao.org/;
|
|
||||||
|
|
||||||
cd /usr/src/app
|
|
||||||
|
|
||||||
echo "START DEBUG INFINI-SEARCH-CENTER"
|
|
||||||
|
|
||||||
if [ ! -f "$lockPath" ]; then
|
|
||||||
npm install --registry=https://registry.npm.taobao.org
|
|
||||||
npm run dev
|
|
||||||
else
|
|
||||||
npm run dev
|
|
||||||
fi
|
|
|
@ -1,5 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
npm config set registry http://registry.npm.taobao.org/;
|
|
||||||
cd /usr/src/app
|
|
||||||
echo "INFINI NODEJS ENV READY TO ROCK!"
|
|
336
web/mock/api.js
|
@ -1,336 +0,0 @@
|
||||||
import mockjs from 'mockjs';
|
|
||||||
|
|
||||||
const titles = [
|
|
||||||
'Alipay',
|
|
||||||
'Angular',
|
|
||||||
'Ant Design',
|
|
||||||
'Ant Design Pro',
|
|
||||||
'Bootstrap',
|
|
||||||
'React',
|
|
||||||
'Vue',
|
|
||||||
'Webpack',
|
|
||||||
];
|
|
||||||
const avatars = [
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png', // Alipay
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png', // Angular
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/dURIMkkrRFpPgTuzkwnB.png', // Ant Design
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png', // Ant Design Pro
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/siCrBXXhmvTQGWPNLBow.png', // Bootstrap
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png', // React
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/ComBAopevLwENQdKWiIn.png', // Vue
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/nxkuOJlFJuAUhzlMTCEe.png', // Webpack
|
|
||||||
];
|
|
||||||
|
|
||||||
const avatars2 = [
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png',
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/cnrhVkzwxjPwAaCfPbdc.png',
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/gaOngJwsRYRaVAuXXcmB.png',
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/ubnKSIfAJTxIgXOKlciN.png',
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/WhxKECPNujWoWEFNdnJE.png',
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/jZUIxmJycoymBprLOUbT.png',
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/psOgztMplJMGpVEqfcgF.png',
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/ZpBqSxLxVEXfcUNoPKrz.png',
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/laiEnJdGHVOhJrUShBaJ.png',
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/UrQsqscbKEpNuJcvBZBu.png',
|
|
||||||
];
|
|
||||||
|
|
||||||
const covers = [
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/uMfMFlvUuceEyPpotzlq.png',
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/iZBVOIhGJiAnhplqjvZW.png',
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/iXjVmWVHbCJAyqvDxdtx.png',
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/gLaIAoVWTtLbBWZNYEMg.png',
|
|
||||||
];
|
|
||||||
const desc = [
|
|
||||||
'那是一种内在的东西, 他们到达不了,也无法触及的',
|
|
||||||
'希望是一个好东西,也许是最好的,好东西是不会消亡的',
|
|
||||||
'生命就像一盒巧克力,结果往往出人意料',
|
|
||||||
'城镇中有那么多的酒馆,她却偏偏走进了我的酒馆',
|
|
||||||
'那时候我只会想自己想要什么,从不想自己拥有什么',
|
|
||||||
];
|
|
||||||
|
|
||||||
const user = [
|
|
||||||
'付小小',
|
|
||||||
'曲丽丽',
|
|
||||||
'林东东',
|
|
||||||
'周星星',
|
|
||||||
'吴加好',
|
|
||||||
'朱偏右',
|
|
||||||
'鱼酱',
|
|
||||||
'乐哥',
|
|
||||||
'谭小仪',
|
|
||||||
'仲尼',
|
|
||||||
];
|
|
||||||
|
|
||||||
function fakeList(count) {
|
|
||||||
const list = [];
|
|
||||||
for (let i = 0; i < count; i += 1) {
|
|
||||||
list.push({
|
|
||||||
id: `fake-list-${i}`,
|
|
||||||
owner: user[i % 10],
|
|
||||||
title: titles[i % 8],
|
|
||||||
avatar: avatars[i % 8],
|
|
||||||
cover: parseInt(i / 4, 10) % 2 === 0 ? covers[i % 4] : covers[3 - (i % 4)],
|
|
||||||
status: ['active', 'exception', 'normal'][i % 3],
|
|
||||||
percent: Math.ceil(Math.random() * 50) + 50,
|
|
||||||
logo: avatars[i % 8],
|
|
||||||
href: 'https://ant.design',
|
|
||||||
updatedAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i),
|
|
||||||
createdAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i),
|
|
||||||
subDescription: desc[i % 5],
|
|
||||||
description:
|
|
||||||
'在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。',
|
|
||||||
activeUser: Math.ceil(Math.random() * 100000) + 100000,
|
|
||||||
newUser: Math.ceil(Math.random() * 1000) + 1000,
|
|
||||||
star: Math.ceil(Math.random() * 100) + 100,
|
|
||||||
like: Math.ceil(Math.random() * 100) + 100,
|
|
||||||
message: Math.ceil(Math.random() * 10) + 10,
|
|
||||||
content:
|
|
||||||
'段落示意:蚂蚁金服设计平台 ant.design,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。蚂蚁金服设计平台 ant.design,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。',
|
|
||||||
members: [
|
|
||||||
{
|
|
||||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ZiESqWwCXBRQoaPONSJe.png',
|
|
||||||
name: '曲丽丽',
|
|
||||||
id: 'member1',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/tBOxZPlITHqwlGjsJWaF.png',
|
|
||||||
name: '王昭君',
|
|
||||||
id: 'member2',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/sBxjgqiuHMGRkIjqlQCd.png',
|
|
||||||
name: '董娜娜',
|
|
||||||
id: 'member3',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
let sourceData;
|
|
||||||
|
|
||||||
function getFakeList(req, res) {
|
|
||||||
const params = req.query;
|
|
||||||
|
|
||||||
const count = params.count * 1 || 20;
|
|
||||||
|
|
||||||
const result = fakeList(count);
|
|
||||||
sourceData = result;
|
|
||||||
return res.json(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function postFakeList(req, res) {
|
|
||||||
const { /* url = '', */ body } = req;
|
|
||||||
// const params = getUrlParams(url);
|
|
||||||
const { method, id } = body;
|
|
||||||
// const count = (params.count * 1) || 20;
|
|
||||||
let result = sourceData;
|
|
||||||
|
|
||||||
switch (method) {
|
|
||||||
case 'delete':
|
|
||||||
result = result.filter(item => item.id !== id);
|
|
||||||
break;
|
|
||||||
case 'update':
|
|
||||||
result.forEach((item, i) => {
|
|
||||||
if (item.id === id) {
|
|
||||||
result[i] = Object.assign(item, body);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case 'post':
|
|
||||||
result.unshift({
|
|
||||||
body,
|
|
||||||
id: `fake-list-${result.length}`,
|
|
||||||
createdAt: new Date().getTime(),
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return res.json(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
const getNotice = [
|
|
||||||
{
|
|
||||||
id: 'xxx1',
|
|
||||||
title: titles[0],
|
|
||||||
logo: avatars[0],
|
|
||||||
description: '那是一种内在的东西,他们到达不了,也无法触及的',
|
|
||||||
updatedAt: new Date(),
|
|
||||||
member: '科学搬砖组',
|
|
||||||
href: '',
|
|
||||||
memberLink: '',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'xxx2',
|
|
||||||
title: titles[1],
|
|
||||||
logo: avatars[1],
|
|
||||||
description: '希望是一个好东西,也许是最好的,好东西是不会消亡的',
|
|
||||||
updatedAt: new Date('2017-07-24'),
|
|
||||||
member: '全组都是吴彦祖',
|
|
||||||
href: '',
|
|
||||||
memberLink: '',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'xxx3',
|
|
||||||
title: titles[2],
|
|
||||||
logo: avatars[2],
|
|
||||||
description: '城镇中有那么多的酒馆,她却偏偏走进了我的酒馆',
|
|
||||||
updatedAt: new Date(),
|
|
||||||
member: '中二少女团',
|
|
||||||
href: '',
|
|
||||||
memberLink: '',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'xxx4',
|
|
||||||
title: titles[3],
|
|
||||||
logo: avatars[3],
|
|
||||||
description: '那时候我只会想自己想要什么,从不想自己拥有什么',
|
|
||||||
updatedAt: new Date('2017-07-23'),
|
|
||||||
member: '程序员日常',
|
|
||||||
href: '',
|
|
||||||
memberLink: '',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'xxx5',
|
|
||||||
title: titles[4],
|
|
||||||
logo: avatars[4],
|
|
||||||
description: '凛冬将至',
|
|
||||||
updatedAt: new Date('2017-07-23'),
|
|
||||||
member: '高逼格设计天团',
|
|
||||||
href: '',
|
|
||||||
memberLink: '',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'xxx6',
|
|
||||||
title: titles[5],
|
|
||||||
logo: avatars[5],
|
|
||||||
description: '生命就像一盒巧克力,结果往往出人意料',
|
|
||||||
updatedAt: new Date('2017-07-23'),
|
|
||||||
member: '骗你来学计算机',
|
|
||||||
href: '',
|
|
||||||
memberLink: '',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const getActivities = [
|
|
||||||
{
|
|
||||||
id: 'trend-1',
|
|
||||||
updatedAt: new Date(),
|
|
||||||
user: {
|
|
||||||
name: '曲丽丽',
|
|
||||||
avatar: avatars2[0],
|
|
||||||
},
|
|
||||||
group: {
|
|
||||||
name: '高逼格设计天团',
|
|
||||||
link: 'http://github.com/',
|
|
||||||
},
|
|
||||||
project: {
|
|
||||||
name: '六月迭代',
|
|
||||||
link: 'http://github.com/',
|
|
||||||
},
|
|
||||||
template: '在 @{group} 新建项目 @{project}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'trend-2',
|
|
||||||
updatedAt: new Date(),
|
|
||||||
user: {
|
|
||||||
name: '付小小',
|
|
||||||
avatar: avatars2[1],
|
|
||||||
},
|
|
||||||
group: {
|
|
||||||
name: '高逼格设计天团',
|
|
||||||
link: 'http://github.com/',
|
|
||||||
},
|
|
||||||
project: {
|
|
||||||
name: '六月迭代',
|
|
||||||
link: 'http://github.com/',
|
|
||||||
},
|
|
||||||
template: '在 @{group} 新建项目 @{project}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'trend-3',
|
|
||||||
updatedAt: new Date(),
|
|
||||||
user: {
|
|
||||||
name: '林东东',
|
|
||||||
avatar: avatars2[2],
|
|
||||||
},
|
|
||||||
group: {
|
|
||||||
name: '中二少女团',
|
|
||||||
link: 'http://github.com/',
|
|
||||||
},
|
|
||||||
project: {
|
|
||||||
name: '六月迭代',
|
|
||||||
link: 'http://github.com/',
|
|
||||||
},
|
|
||||||
template: '在 @{group} 新建项目 @{project}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'trend-4',
|
|
||||||
updatedAt: new Date(),
|
|
||||||
user: {
|
|
||||||
name: '周星星',
|
|
||||||
avatar: avatars2[4],
|
|
||||||
},
|
|
||||||
project: {
|
|
||||||
name: '5 月日常迭代',
|
|
||||||
link: 'http://github.com/',
|
|
||||||
},
|
|
||||||
template: '将 @{project} 更新至已发布状态',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'trend-5',
|
|
||||||
updatedAt: new Date(),
|
|
||||||
user: {
|
|
||||||
name: '朱偏右',
|
|
||||||
avatar: avatars2[3],
|
|
||||||
},
|
|
||||||
project: {
|
|
||||||
name: '工程效能',
|
|
||||||
link: 'http://github.com/',
|
|
||||||
},
|
|
||||||
comment: {
|
|
||||||
name: '留言',
|
|
||||||
link: 'http://github.com/',
|
|
||||||
},
|
|
||||||
template: '在 @{project} 发布了 @{comment}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'trend-6',
|
|
||||||
updatedAt: new Date(),
|
|
||||||
user: {
|
|
||||||
name: '乐哥',
|
|
||||||
avatar: avatars2[5],
|
|
||||||
},
|
|
||||||
group: {
|
|
||||||
name: '程序员日常',
|
|
||||||
link: 'http://github.com/',
|
|
||||||
},
|
|
||||||
project: {
|
|
||||||
name: '品牌迭代',
|
|
||||||
link: 'http://github.com/',
|
|
||||||
},
|
|
||||||
template: '在 @{group} 新建项目 @{project}',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
function getFakeCaptcha(req, res) {
|
|
||||||
return res.json('captcha-xxx');
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
'GET /api/project/notice': getNotice,
|
|
||||||
'GET /api/activities': getActivities,
|
|
||||||
'POST /api/forms': (req, res) => {
|
|
||||||
res.send({ message: 'Ok' });
|
|
||||||
},
|
|
||||||
'GET /api/tags': mockjs.mock({
|
|
||||||
'list|100': [{ name: '@city', 'value|1-100': 150, 'type|0-2': 1 }],
|
|
||||||
}),
|
|
||||||
'GET /api/fake_list': getFakeList,
|
|
||||||
'POST /api/fake_list': postFakeList,
|
|
||||||
'GET /api/captcha': getFakeCaptcha,
|
|
||||||
};
|
|
|
@ -1,324 +0,0 @@
|
||||||
import moment from 'moment';
|
|
||||||
|
|
||||||
// mock data
|
|
||||||
const visitData = [];
|
|
||||||
const beginDay = new Date().getTime();
|
|
||||||
|
|
||||||
const fakeY = [7, 5, 4, 2, 4, 7, 5, 6, 5, 9, 6, 3, 1, 5, 3, 6, 5];
|
|
||||||
for (let i = 0; i < fakeY.length; i += 1) {
|
|
||||||
visitData.push({
|
|
||||||
x: moment(new Date(beginDay + 1000 * 60 * 60 * 24 * i)).format('YYYY-MM-DD'),
|
|
||||||
y: fakeY[i],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const visitData2 = [];
|
|
||||||
const fakeY2 = [1, 6, 4, 8, 3, 7, 2];
|
|
||||||
for (let i = 0; i < fakeY2.length; i += 1) {
|
|
||||||
visitData2.push({
|
|
||||||
x: moment(new Date(beginDay + 1000 * 60 * 60 * 24 * i)).format('YYYY-MM-DD'),
|
|
||||||
y: fakeY2[i],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const salesData = [];
|
|
||||||
for (let i = 0; i < 12; i += 1) {
|
|
||||||
salesData.push({
|
|
||||||
x: `${i + 1}月`,
|
|
||||||
y: Math.floor(Math.random() * 1000) + 200,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const searchData = [];
|
|
||||||
for (let i = 0; i < 50; i += 1) {
|
|
||||||
searchData.push({
|
|
||||||
index: i + 1,
|
|
||||||
keyword: `搜索关键词-${i}`,
|
|
||||||
count: Math.floor(Math.random() * 1000),
|
|
||||||
range: Math.floor(Math.random() * 100),
|
|
||||||
status: Math.floor((Math.random() * 10) % 2),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const searchDataBaseTerms = [{
|
|
||||||
"name": "北京",
|
|
||||||
"value": Math.floor((Math.random() * 1000)),
|
|
||||||
"category": "城市"
|
|
||||||
}, {
|
|
||||||
"name": "广州",
|
|
||||||
"value": Math.floor((Math.random() * 1000)),
|
|
||||||
"category": "城市"
|
|
||||||
}, {
|
|
||||||
"name": "深圳",
|
|
||||||
"value": Math.floor((Math.random() * 1000)),
|
|
||||||
"category": "城市"
|
|
||||||
}, {
|
|
||||||
"name": "长沙",
|
|
||||||
"value": Math.floor((Math.random() * 1000)),
|
|
||||||
"category": "城市"
|
|
||||||
}, {
|
|
||||||
"name": "上海",
|
|
||||||
"value": Math.floor((Math.random() * 1000)),
|
|
||||||
"category": "城市"
|
|
||||||
}, {
|
|
||||||
"name": "成都",
|
|
||||||
"value": Math.floor((Math.random() * 1000)),
|
|
||||||
"category": "城市"
|
|
||||||
}, {
|
|
||||||
"name": "哈尔滨",
|
|
||||||
"value": Math.floor((Math.random() * 1000)),
|
|
||||||
"category": "城市"
|
|
||||||
}, {
|
|
||||||
"name": "海口",
|
|
||||||
"value": Math.floor((Math.random() * 1000)),
|
|
||||||
"category": "城市"
|
|
||||||
}, {
|
|
||||||
"name": "青岛",
|
|
||||||
"value": Math.floor((Math.random() * 1000)),
|
|
||||||
"category": "城市"
|
|
||||||
}, {
|
|
||||||
"name": "G71",
|
|
||||||
"value": Math.floor((Math.random() * 1000)),
|
|
||||||
"category": "车次"
|
|
||||||
}, {
|
|
||||||
"name": "G121",
|
|
||||||
"value": Math.floor((Math.random() * 1000)),
|
|
||||||
"category": "车次"
|
|
||||||
}, {
|
|
||||||
"name": "T109",
|
|
||||||
"value": Math.floor((Math.random() * 1000)),
|
|
||||||
"category": "车次"
|
|
||||||
}, {
|
|
||||||
"name": "K81",
|
|
||||||
"value": Math.floor((Math.random() * 1000)),
|
|
||||||
"category": "车次"
|
|
||||||
}, {
|
|
||||||
"name": "Z13",
|
|
||||||
"value": Math.floor((Math.random() * 1000)),
|
|
||||||
"category": "车次"
|
|
||||||
}, {
|
|
||||||
"name": "Z121",
|
|
||||||
"value": Math.floor((Math.random() * 1000)),
|
|
||||||
"category": "车次"
|
|
||||||
}, {
|
|
||||||
"name": "G431",
|
|
||||||
"value": Math.floor((Math.random() * 1000)),
|
|
||||||
"category": "车次"
|
|
||||||
}, {
|
|
||||||
"name": "退票",
|
|
||||||
"value": Math.floor((Math.random() * 1000)),
|
|
||||||
"category": "票务"
|
|
||||||
}, {
|
|
||||||
"name": "春运",
|
|
||||||
"value": Math.floor((Math.random() * 1000)),
|
|
||||||
"category": "票务"
|
|
||||||
}, {
|
|
||||||
"name": "学生票",
|
|
||||||
"value": Math.floor((Math.random() * 1000)),
|
|
||||||
"category": "票务"
|
|
||||||
}, {
|
|
||||||
"name": "二等座",
|
|
||||||
"value": Math.floor((Math.random() * 1000)),
|
|
||||||
"category": "其他"
|
|
||||||
}, {
|
|
||||||
"name": "订餐",
|
|
||||||
"value": Math.floor((Math.random() * 1000)),
|
|
||||||
"category": "其他"
|
|
||||||
}];
|
|
||||||
|
|
||||||
const searchDataInfini = [];
|
|
||||||
for (let i = 0; i < searchDataBaseTerms.length; i += 1) {
|
|
||||||
searchDataInfini.push({
|
|
||||||
index: i + 1,
|
|
||||||
keyword: `${searchDataBaseTerms[i].name}`,
|
|
||||||
count: Math.floor(Math.random() * 1000),
|
|
||||||
range: Math.floor(Math.random() * 100),
|
|
||||||
status: Math.floor((Math.random() * 10) % 2),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const docTypeDataInfini = [
|
|
||||||
{
|
|
||||||
x: 'user',
|
|
||||||
y: 39274,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: 'city',
|
|
||||||
y: 31008,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: 'train',
|
|
||||||
y: 27610,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: 'news',
|
|
||||||
y: 19302,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: 'order',
|
|
||||||
y: 17624,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: 'other',
|
|
||||||
y: 12900,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const salesTypeData = [
|
|
||||||
{
|
|
||||||
x: '家用电器',
|
|
||||||
y: 4544,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: '食用酒水',
|
|
||||||
y: 3321,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: '个护健康',
|
|
||||||
y: 3113,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: '服饰箱包',
|
|
||||||
y: 2341,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: '母婴产品',
|
|
||||||
y: 1231,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: '其他',
|
|
||||||
y: 1231,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const salesTypeDataOnline = [
|
|
||||||
{
|
|
||||||
x: '家用电器',
|
|
||||||
y: 244,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: '食用酒水',
|
|
||||||
y: 321,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: '个护健康',
|
|
||||||
y: 311,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: '服饰箱包',
|
|
||||||
y: 41,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: '母婴产品',
|
|
||||||
y: 121,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: '其他',
|
|
||||||
y: 111,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const salesTypeDataOffline = [
|
|
||||||
{
|
|
||||||
x: '家用电器',
|
|
||||||
y: 99,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: '食用酒水',
|
|
||||||
y: 188,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: '个护健康',
|
|
||||||
y: 344,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: '服饰箱包',
|
|
||||||
y: 255,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: '其他',
|
|
||||||
y: 65,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const offlineData = [];
|
|
||||||
for (let i = 0; i < 10; i += 1) {
|
|
||||||
offlineData.push({
|
|
||||||
name: `Stores ${i}`,
|
|
||||||
cvr: Math.ceil(Math.random() * 9) / 10,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const offlineChartData = [];
|
|
||||||
for (let i = 0; i < 20; i += 1) {
|
|
||||||
offlineChartData.push({
|
|
||||||
x: new Date().getTime() + 1000 * 60 * 30 * i,
|
|
||||||
y1: Math.floor(Math.random() * 100) + 10,
|
|
||||||
y2: Math.floor(Math.random() * 100) + 10,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const radarOriginData = [
|
|
||||||
{
|
|
||||||
name: '个人',
|
|
||||||
ref: 10,
|
|
||||||
koubei: 8,
|
|
||||||
output: 4,
|
|
||||||
contribute: 5,
|
|
||||||
hot: 7,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '团队',
|
|
||||||
ref: 3,
|
|
||||||
koubei: 9,
|
|
||||||
output: 6,
|
|
||||||
contribute: 3,
|
|
||||||
hot: 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '部门',
|
|
||||||
ref: 4,
|
|
||||||
koubei: 1,
|
|
||||||
output: 6,
|
|
||||||
contribute: 5,
|
|
||||||
hot: 7,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const radarData = [];
|
|
||||||
const radarTitleMap = {
|
|
||||||
ref: '引用',
|
|
||||||
koubei: '口碑',
|
|
||||||
output: '产量',
|
|
||||||
contribute: '贡献',
|
|
||||||
hot: '热度',
|
|
||||||
};
|
|
||||||
radarOriginData.forEach(item => {
|
|
||||||
Object.keys(item).forEach(key => {
|
|
||||||
if (key !== 'name') {
|
|
||||||
radarData.push({
|
|
||||||
name: item.name,
|
|
||||||
label: radarTitleMap[key],
|
|
||||||
value: item[key],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const getFakeChartData = {
|
|
||||||
visitData,
|
|
||||||
visitData2,
|
|
||||||
salesData,
|
|
||||||
searchData,
|
|
||||||
offlineData,
|
|
||||||
offlineChartData,
|
|
||||||
salesTypeData,
|
|
||||||
salesTypeDataOnline,
|
|
||||||
salesTypeDataOffline,
|
|
||||||
radarData,
|
|
||||||
searchDataInfini,
|
|
||||||
docTypeDataInfini,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
|
||||||
'GET /api/fake_chart_data': getFakeChartData,
|
|
||||||
};
|
|
|
@ -1,79 +0,0 @@
|
||||||
import moment from 'moment';
|
|
||||||
|
|
||||||
const d = moment.duration;
|
|
||||||
const roundingRules = [
|
|
||||||
[d(500, 'ms'), d(100, 'ms')],
|
|
||||||
[d(5, 'second'), d(1, 'second')],
|
|
||||||
[d(7.5, 'second'), d(5, 'second')],
|
|
||||||
[d(15, 'second'), d(10, 'second')],
|
|
||||||
[d(45, 'second'), d(30, 'second')],
|
|
||||||
[d(3, 'minute'), d(1, 'minute')],
|
|
||||||
[d(9, 'minute'), d(5, 'minute')],
|
|
||||||
[d(20, 'minute'), d(10, 'minute')],
|
|
||||||
[d(45, 'minute'), d(30, 'minute')],
|
|
||||||
[d(2, 'hour'), d(1, 'hour')],
|
|
||||||
[d(6, 'hour'), d(3, 'hour')],
|
|
||||||
[d(24, 'hour'), d(12, 'hour')],
|
|
||||||
[d(1, 'week'), d(1, 'd')],
|
|
||||||
[d(3, 'week'), d(1, 'week')],
|
|
||||||
[d(1, 'year'), d(1, 'month')],
|
|
||||||
[Infinity, d(1, 'year')],
|
|
||||||
];
|
|
||||||
|
|
||||||
function find(rules, check) {
|
|
||||||
function pick(buckets, duration) {
|
|
||||||
const target = duration / buckets;
|
|
||||||
let lastResp;
|
|
||||||
|
|
||||||
for (let i = 0; i < rules.length; i++) {
|
|
||||||
const rule = rules[i];
|
|
||||||
const resp = check(rule[0], rule[1], target);
|
|
||||||
|
|
||||||
if (resp == null) {
|
|
||||||
if (lastResp) {
|
|
||||||
return lastResp;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
lastResp = resp;
|
|
||||||
}
|
|
||||||
|
|
||||||
// fallback to just a number of milliseconds, ensure ms is >= 1
|
|
||||||
const ms = Math.max(Math.floor(target), 1);
|
|
||||||
return moment.duration(ms, 'ms');
|
|
||||||
}
|
|
||||||
|
|
||||||
return function (buckets, duration) {
|
|
||||||
const interval = pick(buckets, duration);
|
|
||||||
if (interval) {
|
|
||||||
return moment.duration(interval._data);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const revRoundingRules = roundingRules.slice(0).reverse();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 24 hours: 600 seconds
|
|
||||||
* 12 hours: 300 seconds
|
|
||||||
* 4 hours: 60 seconds
|
|
||||||
* 1 hour: 30 seconds
|
|
||||||
* 15 minutes: 10 seconds
|
|
||||||
*/
|
|
||||||
export const calculateAuto = find(revRoundingRules, (bound, interval, target) => {
|
|
||||||
if (bound > target) {
|
|
||||||
return interval;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
export function calculateTimeseriesInterval(
|
|
||||||
lowerBoundInMsSinceEpoch,
|
|
||||||
upperBoundInMsSinceEpoch,
|
|
||||||
minIntervalSeconds
|
|
||||||
) {
|
|
||||||
const duration = moment.duration(upperBoundInMsSinceEpoch - lowerBoundInMsSinceEpoch, 'ms');
|
|
||||||
|
|
||||||
return Math.max(minIntervalSeconds, calculateAuto(100, duration).asSeconds());
|
|
||||||
}
|
|
|
@ -1,291 +0,0 @@
|
||||||
import fetch from 'node-fetch';
|
|
||||||
import moment from 'moment';
|
|
||||||
import {calculateTimeseriesInterval} from './calculate_timeseries_interval';
|
|
||||||
import { promises } from 'dns';
|
|
||||||
//import {formatTimestampToDuration} from './format_timestamp_to_duration';
|
|
||||||
const minIntervalSeconds = 10;
|
|
||||||
|
|
||||||
import {clusterData, clusterList} from './data/cluster';
|
|
||||||
|
|
||||||
function getOverviewBody(params){
|
|
||||||
let body = {
|
|
||||||
_source: [ "cluster_stats"],
|
|
||||||
size: 1,
|
|
||||||
sort: [
|
|
||||||
{
|
|
||||||
timestamp: {
|
|
||||||
order: "desc"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
query: {
|
|
||||||
bool: {
|
|
||||||
must: [
|
|
||||||
{
|
|
||||||
match: {
|
|
||||||
type: "cluster_stats"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
filter: [
|
|
||||||
{
|
|
||||||
range: {
|
|
||||||
timestamp: {
|
|
||||||
"gte": params.timeRange.min,
|
|
||||||
lte: params.timeRange.max
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return JSON.stringify(body);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getNodesStatsBody(params){
|
|
||||||
let min = moment(params.timeRange.min).valueOf();
|
|
||||||
let max = moment(params.timeRange.max).valueOf();
|
|
||||||
const bucketSizeInSeconds = calculateTimeseriesInterval(min, max, minIntervalSeconds);
|
|
||||||
console.log(bucketSizeInSeconds);
|
|
||||||
let body = {
|
|
||||||
"size": 0,
|
|
||||||
"query": {
|
|
||||||
"bool": {
|
|
||||||
"must": [
|
|
||||||
{
|
|
||||||
"match": {
|
|
||||||
"type": "node_stats"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"filter": [
|
|
||||||
{
|
|
||||||
"range": {
|
|
||||||
"timestamp": {
|
|
||||||
"gte": params.timeRange.min,
|
|
||||||
"lte": params.timeRange.max
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"aggs": {
|
|
||||||
"nodes": {
|
|
||||||
"terms": {
|
|
||||||
"field": "source_node.name",
|
|
||||||
"size": 10
|
|
||||||
},
|
|
||||||
"aggs": {
|
|
||||||
"metrics": {
|
|
||||||
"date_histogram": {
|
|
||||||
"field": "timestamp",
|
|
||||||
"fixed_interval": bucketSizeInSeconds + 's'
|
|
||||||
},
|
|
||||||
"aggs": {
|
|
||||||
"cpu_used": {
|
|
||||||
"max": {
|
|
||||||
"field": "node_stats.process.cpu.percent"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"heap_used": {
|
|
||||||
"max": {
|
|
||||||
"field": "node_stats.jvm.mem.heap_used_in_bytes"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"heap_percent": {
|
|
||||||
"max": {
|
|
||||||
"field": "node_stats.jvm.mem.heap_used_percent"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"search_query_total": {
|
|
||||||
"max": {
|
|
||||||
"field": "node_stats.indices.search.query_total"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"search_query_time": {
|
|
||||||
"max": {
|
|
||||||
"field": "node_stats.indices.search.query_time_in_millis"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ds": {
|
|
||||||
"derivative": {
|
|
||||||
"buckets_path": "search_query_total"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ds1": {
|
|
||||||
"derivative": {
|
|
||||||
"buckets_path": "search_query_time"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"index_total": {
|
|
||||||
"max": {
|
|
||||||
"field": "node_stats.indices.indexing.index_total"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"index_time": {
|
|
||||||
"max": {
|
|
||||||
"field": "node_stats.indices.indexing.index_time_in_millis"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ds3": {
|
|
||||||
"derivative": {
|
|
||||||
"buckets_path": "index_total"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ds4": {
|
|
||||||
"derivative": {
|
|
||||||
"buckets_path": "index_time"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"search_qps":{
|
|
||||||
"derivative": {
|
|
||||||
"buckets_path": "search_query_total",
|
|
||||||
"gap_policy": "skip",
|
|
||||||
"unit": "1s"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"index_qps":{
|
|
||||||
"derivative": {
|
|
||||||
"buckets_path": "index_total",
|
|
||||||
"gap_policy": "skip",
|
|
||||||
"unit": "1s"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"read_threads_queue":{
|
|
||||||
"max": {
|
|
||||||
"field": "node_stats.thread_pool.get.queue"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"write_threads_queue":{
|
|
||||||
"max": {
|
|
||||||
"field": "node_stats.thread_pool.write.queue"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return JSON.stringify(body);
|
|
||||||
}
|
|
||||||
|
|
||||||
const apiUrls = {
|
|
||||||
CLUSTER_OVERVIEW: {
|
|
||||||
path:'/.monitoring-es-*/_search',
|
|
||||||
},
|
|
||||||
"GET_ES_NODE_STATS":{
|
|
||||||
path: '/.monitoring-es-*/_search',
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const gatewayUrl = 'http://localhost:9200';
|
|
||||||
|
|
||||||
function getClusterOverview(params){
|
|
||||||
return fetch(gatewayUrl+apiUrls.CLUSTER_OVERVIEW.path, {
|
|
||||||
method: 'POST',
|
|
||||||
body: getOverviewBody(params),
|
|
||||||
headers:{
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
}
|
|
||||||
}).then(esRes=>{
|
|
||||||
return esRes.json();
|
|
||||||
}).then(rel=>{
|
|
||||||
//console.log(rel);
|
|
||||||
if(rel.hits.hits.length>0){
|
|
||||||
var rdata = rel.hits.hits[0]._source;
|
|
||||||
}else{
|
|
||||||
rdata = data;
|
|
||||||
}
|
|
||||||
let cluster_stats = rdata.cluster_stats;
|
|
||||||
let result = {
|
|
||||||
elasticsearch:{
|
|
||||||
cluster_stats:{
|
|
||||||
status: cluster_stats.status,
|
|
||||||
indices: {
|
|
||||||
count: cluster_stats.indices.count,
|
|
||||||
docs: cluster_stats.indices.docs,
|
|
||||||
shards: cluster_stats.indices.shards,
|
|
||||||
store: cluster_stats.indices.store,
|
|
||||||
},
|
|
||||||
nodes: {
|
|
||||||
count:{
|
|
||||||
total: cluster_stats.nodes.count.total,
|
|
||||||
},
|
|
||||||
fs: cluster_stats.nodes.fs,
|
|
||||||
jvm: {
|
|
||||||
max_uptime_in_millis: cluster_stats.nodes.jvm.max_uptime_in_millis,
|
|
||||||
mem: cluster_stats.nodes.jvm.mem,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return Promise.resolve(result);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getNodesStats(params){
|
|
||||||
return fetch(gatewayUrl+apiUrls.GET_ES_NODE_STATS.path, {
|
|
||||||
method: 'POST',
|
|
||||||
body: getNodesStatsBody(params),
|
|
||||||
headers:{
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
}
|
|
||||||
}).then(esRes=>{
|
|
||||||
return esRes.json();
|
|
||||||
// return esRes.json();
|
|
||||||
}).then(rel=>{
|
|
||||||
//console.log(rel);
|
|
||||||
if(rel.aggregations.nodes.buckets.length>0){
|
|
||||||
var rdata = rel.aggregations.nodes.buckets;
|
|
||||||
//console.log(rdata);
|
|
||||||
}else{
|
|
||||||
rdata = nodesStats;
|
|
||||||
}
|
|
||||||
return Promise.resolve(rdata);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
'POST /dashboard/cluster/overview': function(req, res){
|
|
||||||
//console.log(1, req.body);
|
|
||||||
// let params = req.body;
|
|
||||||
// !params.timeRange && (params.timeRange={
|
|
||||||
// min: 'now-1h',
|
|
||||||
// max: 'now'
|
|
||||||
// });
|
|
||||||
// Promise.all([getClusterOverview(params),getNodesStats(params)]).then(function(values){
|
|
||||||
// let robj = values[0];
|
|
||||||
// robj = Object.assign(robj, {nodes_stats: values[1]});
|
|
||||||
// res.send(robj);
|
|
||||||
// }).catch(function(err){
|
|
||||||
// console.log(err);
|
|
||||||
// });
|
|
||||||
res.send(clusterData);
|
|
||||||
},
|
|
||||||
'GET /dashboard/cluster/nodes_stats': function(req, res) {
|
|
||||||
let min = moment(1607839878669 - 2592000000).valueOf();
|
|
||||||
const max = moment(1607839878669).valueOf();
|
|
||||||
const bucketSizeInSeconds = calculateTimeseriesInterval(min, max, minIntervalSeconds);
|
|
||||||
const now = moment();
|
|
||||||
const timestamp = moment(now).add(bucketSizeInSeconds, 'seconds'); // clone the `now` object
|
|
||||||
|
|
||||||
//console.log(bucketSizeInSeconds); //, formatTimestampToDuration(timestamp, 'until', now));
|
|
||||||
|
|
||||||
Promise.all([ getNodesStats()]).then((values) => {
|
|
||||||
//console.log(values);
|
|
||||||
res.send({
|
|
||||||
// elasticsearch: values[0].elasticsearch,
|
|
||||||
nodes_stats: values[0],
|
|
||||||
});
|
|
||||||
}).catch(err=>{
|
|
||||||
console.log(err);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'GET /dashboard/cluster/list': function(req, res){
|
|
||||||
res.send(clusterList);
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -1,157 +0,0 @@
|
||||||
export const queryData = {
|
|
||||||
"payload": {
|
|
||||||
"took": 0,
|
|
||||||
"timed_out": false,
|
|
||||||
"hits": {
|
|
||||||
"total": {
|
|
||||||
"relation": "eq",
|
|
||||||
"value": 12
|
|
||||||
},
|
|
||||||
"max_score": 1,
|
|
||||||
"hits": [
|
|
||||||
{
|
|
||||||
"_index": "test-custom",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "jc6_jXYBKoaaPbVfj_8W",
|
|
||||||
"_source": {
|
|
||||||
"address": "hunan changsha",
|
|
||||||
"created_at": "2020-12-23T03:57:57.620Z",
|
|
||||||
"email": "liugq@qq.com",
|
|
||||||
"hobbies": "[\"basketball\",\"pingpan\"]",
|
|
||||||
"id": "jc6_jXYBKoaaPbVfj_8W",
|
|
||||||
"name": "liugq国家"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"_index": "test-custom",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "bvhm18dath2d6oa9046g",
|
|
||||||
"_source": {
|
|
||||||
"address": "hunan changsha",
|
|
||||||
"created_at": "2020-12-23T03:57:57.620Z",
|
|
||||||
"email": "786027438@qq.com",
|
|
||||||
"hobbies": "[\"test5\"]",
|
|
||||||
"name": "hello4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"_index": "test-custom",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "bvhlv6dath2d6oa9045g",
|
|
||||||
"_source": {
|
|
||||||
"address": "hunan changsha",
|
|
||||||
"created_at": "2020-12-23T03:57:57.620Z",
|
|
||||||
"email": "786027438@qq.com",
|
|
||||||
"hobbies": "[\"test2\"]",
|
|
||||||
"name": "test 词典"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"_index": "test-custom",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "bvhltpdath2d6oa90450",
|
|
||||||
"_source": {
|
|
||||||
"address": "hunan changsha",
|
|
||||||
"created_at": "2020-12-23T03:57:57.620Z",
|
|
||||||
"email": "786027438@qq.com",
|
|
||||||
"hobbies": "[\"test1\"]",
|
|
||||||
"name": "liugqy"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"_index": "test-custom",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "bvi5ellath2e0ukbq5e0",
|
|
||||||
"_source": {
|
|
||||||
"address": "湖北武汉2",
|
|
||||||
"created_at": "2020-12-23T03:57:57.620Z",
|
|
||||||
"email": "786027438@qq.com",
|
|
||||||
"hobbies": [
|
|
||||||
"test3"
|
|
||||||
],
|
|
||||||
"id": "bvi5ellath2e0ukbq5e0",
|
|
||||||
"name": "武汉test"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"_index": "test-custom",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "bvia41lath2eneoeeij0",
|
|
||||||
"_source": {
|
|
||||||
"address": "hunan changsha",
|
|
||||||
"created_at": "2020-12-23T03:57:57.620Z",
|
|
||||||
"email": "786027438@qq.com",
|
|
||||||
"hobbies": [
|
|
||||||
"test3"
|
|
||||||
],
|
|
||||||
"name": "铁路测试词典"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"_index": "test-custom",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "bvi5omtath2e0ukbq5eg",
|
|
||||||
"_source": {
|
|
||||||
"address": "湖北武汉",
|
|
||||||
"created_at": "2020-12-23T03:57:57.620Z",
|
|
||||||
"email": "786027438@qq.com",
|
|
||||||
"hobbies": [
|
|
||||||
"test4"
|
|
||||||
],
|
|
||||||
"id": "bvi5omtath2e0ukbq5eg",
|
|
||||||
"name": "武汉2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"_index": "test-custom",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "bvhlsptath2d6oa9044g",
|
|
||||||
"_source": {
|
|
||||||
"address": "hunan changsha",
|
|
||||||
"created_at": "2020-12-29T08:24:49.715Z",
|
|
||||||
"email": "786027438@qq.com",
|
|
||||||
"hobbies": [
|
|
||||||
"test"
|
|
||||||
],
|
|
||||||
"id": "bvhlsptath2d6oa9044g",
|
|
||||||
"name": "hello"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"_index": "test-custom",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "bvhm0d5ath2d6oa90460",
|
|
||||||
"_source": {
|
|
||||||
"address": "hunan changsha1",
|
|
||||||
"age": 30,
|
|
||||||
"created_at": "2020-12-23T03:57:57.620Z",
|
|
||||||
"email": "786027438@qq.com",
|
|
||||||
"hobbies": [
|
|
||||||
"test3"
|
|
||||||
],
|
|
||||||
"id": "bvhm0d5ath2d6oa90460",
|
|
||||||
"name": "hello2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"_index": "test-custom",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "bvia4ctath2eneoeeijg",
|
|
||||||
"_source": {
|
|
||||||
"address": "beijing",
|
|
||||||
"age": 31,
|
|
||||||
"created_at": "2020-12-23T03:57:57.620Z",
|
|
||||||
"email": "786027438@qq.com",
|
|
||||||
"hobbies": [
|
|
||||||
"basketball1",
|
|
||||||
"badminton"
|
|
||||||
],
|
|
||||||
"id": "bvia4ctath2eneoeeijg",
|
|
||||||
"name": "北京"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"status": true
|
|
||||||
};
|
|
|
@ -1,40 +0,0 @@
|
||||||
import {queryData} from './data/doc';
|
|
||||||
|
|
||||||
function getUUID(len){
|
|
||||||
len = len || 20;
|
|
||||||
let chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
||||||
var maxPos = chars.length;
|
|
||||||
var uuid = '';
|
|
||||||
for (let i = 0; i < len; i++) {
|
|
||||||
uuid += chars.charAt(Math.floor(Math.random() * maxPos));
|
|
||||||
}
|
|
||||||
return uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
// 'post /_search-center/doc/:index/_search': function(req, res){
|
|
||||||
// res.send(queryData)
|
|
||||||
// },
|
|
||||||
// 'post /_search-center/doc/:index/_create': function(req, res){
|
|
||||||
// res.send({
|
|
||||||
// status: true,
|
|
||||||
// payload: {
|
|
||||||
// ...req.body.payload,
|
|
||||||
// id: getUUID(),
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// },
|
|
||||||
// 'put /_search-center/doc/:index/:id': function(req, res){
|
|
||||||
// res.send({
|
|
||||||
// status: true,
|
|
||||||
// payload: req.body
|
|
||||||
// });
|
|
||||||
// },
|
|
||||||
//
|
|
||||||
// 'delete /_search-center/doc/:index/:id': function(req, res){
|
|
||||||
// res.send({
|
|
||||||
// status: true,
|
|
||||||
// payload: null,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
const savedObjectsResult = {"page":1,"per_page":10000,"total":4,"saved_objects":[{"type":"index-pattern","id":"c7fbafd0-34a9-11eb-925f-9db57376c4ce","attributes":{"title":".monitoring-es-7-mb-*"},"references":[],"migrationVersion":{"index-pattern":"7.6.0"},"updated_at":"2020-12-02T14:34:38.010Z","version":"WzgyNCw3XQ==","namespaces":["default"],"score":0},{"type":"index-pattern","id":"861ea7f0-3a9b-11eb-9b55-45d33507027a","attributes":{"title":"mock_log*"},"references":[],"migrationVersion":{"index-pattern":"7.6.0"},"updated_at":"2020-12-10T04:09:09.044Z","version":"WzE3NTgsMTBd","namespaces":["default"],"score":0},{"type":"index-pattern","id":"1a28c950-0f6b-11eb-9512-2d0c0eda237d","attributes":{"title":"gateway_requests*"},"references":[],"migrationVersion":{"index-pattern":"7.6.0"},"updated_at":"2021-05-22T11:04:23.811Z","version":"WzkxMTgsNDhd","namespaces":["default"],"score":0},{"type":"index-pattern","id":"1ccce5c0-bb9a-11eb-957b-939add21a246","attributes":{"title":"test-custom*"},"references":[],"migrationVersion":{"index-pattern":"7.6.0"},"updated_at":"2021-06-03T14:51:14.139Z","version":"WzEwMTEzLDQ4XQ==","namespaces":["default"],"score":0}]};
|
|
||||||
|
|
||||||
const resolveIndexResult1 = {"indices":[{"name":".apm-agent-configuration","attributes":["open"]},{"name":".apm-custom-link","attributes":["open"]},{"name":".async-search","attributes":["open"]},{"name":".infini-search-center_cluster","attributes":["open"]},{"name":".infini-search-center_dict","attributes":["open"]},{"name":".infini-search-center_monitoring","attributes":["open"]},{"name":".infini-search-center_reindex","attributes":["open"]},{"name":".infini-search-center_searchtemplate","attributes":["open"]},{"name":".infini-search-center_searchtemplatehistory","attributes":["open"]},{"name":".kibana-event-log-7.10.0-000004","aliases":[".kibana-event-log-7.10.0"],"attributes":["open"]},{"name":".kibana-event-log-7.10.0-000005","aliases":[".kibana-event-log-7.10.0"],"attributes":["open"]},{"name":".kibana-event-log-7.10.0-000006","aliases":[".kibana-event-log-7.10.0"],"attributes":["open"]},{"name":".kibana-event-log-7.10.0-000007","aliases":[".kibana-event-log-7.10.0"],"attributes":["open"]},{"name":".kibana_1","aliases":[".kibana"],"attributes":["open"]},{"name":".kibana_2","attributes":["open"]},{"name":".kibana_task_manager_1","aliases":[".kibana_task_manager"],"attributes":["open"]},{"name":".tasks","attributes":["open"]},{"name":"cluster","attributes":["open"]},{"name":"dict","attributes":["open"]},{"name":"gateway_requests","attributes":["open"]},{"name":"infini-dict","attributes":["open"]},{"name":"infini-reindex","attributes":["open"]},{"name":"metricbeat-7.10.0-2021.02.03-000001","aliases":["metricbeat-7.10.0"],"attributes":["open"]},{"name":"metricbeat-7.10.0-2021.03.06-000002","aliases":["metricbeat-7.10.0"],"attributes":["open"]},{"name":"metricbeat-7.10.0-2021.04.07-000003","aliases":["metricbeat-7.10.0"],"attributes":["open"]},{"name":"metricbeat-7.10.0-2021.05.07-000004","aliases":["metricbeat-7.10.0"],"attributes":["open"]},{"name":"metricbeat-7.10.0-2021.06.06-000005","aliases":["metricbeat-7.10.0"],"attributes":["open"]},{"name":"mock_log","attributes":["open"]},{"name":"nginx_mock_log","attributes":["open"]},{"name":"reindex","attributes":["open"]},{"name":"test-custom","aliases":["custom"],"attributes":["open"]},{"name":"test-custom1","aliases":["custom"],"attributes":["open"]},{"name":"test-custom8","aliases":["custom"],"attributes":["open"]},{"name":"test-custom9","aliases":["custom"],"attributes":["open"]}],"aliases":[{"name":".kibana","indices":[".kibana_1"]},{"name":".kibana-event-log-7.10.0","indices":[".kibana-event-log-7.10.0-000004",".kibana-event-log-7.10.0-000005",".kibana-event-log-7.10.0-000006",".kibana-event-log-7.10.0-000007"]},{"name":".kibana_task_manager","indices":[".kibana_task_manager_1"]},{"name":"custom","indices":["test-custom","test-custom1","test-custom8","test-custom9"]},{"name":"metricbeat-7.10.0","indices":["metricbeat-7.10.0-2021.02.03-000001","metricbeat-7.10.0-2021.03.06-000002","metricbeat-7.10.0-2021.04.07-000003","metricbeat-7.10.0-2021.05.07-000004","metricbeat-7.10.0-2021.06.06-000005"]}],"data_streams":[]};
|
|
||||||
|
|
||||||
const resolveIndexResult2 = {"indices":[],"aliases":[],"data_streams":[]};
|
|
||||||
|
|
||||||
export default {
|
|
||||||
'GET /elasticsearch/:clusterID/saved_objects/_find': (req, res) =>{
|
|
||||||
return res.json(savedObjectsResult);
|
|
||||||
},
|
|
||||||
'GET /elasticsearch/:clusterID/internal/index-pattern-management/resolve_index/:pattern': (req, res)=>{
|
|
||||||
const {pattern} = req.params;
|
|
||||||
if(pattern == '*')
|
|
||||||
return res.json(resolveIndexResult1);
|
|
||||||
else if(pattern == '*:*'){
|
|
||||||
return res.json(resolveIndexResult2);
|
|
||||||
}else{
|
|
||||||
const result = {...resolveIndexResult1};
|
|
||||||
result.aliases = result.aliases.filter(alias=>alias.name.startsWith(pattern.replace('*', '')))
|
|
||||||
result.indices = result.indices.filter(index=>index.name.startsWith(pattern.replace('*', '')))
|
|
||||||
return res.json(result);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'POST /elasticsearch/:clusterID/saved_objects/_bulk_get': (req, res) => {
|
|
||||||
if(req.body && req.body.length > 0 ){
|
|
||||||
let mockObj =
|
|
||||||
{
|
|
||||||
"attributes": {
|
|
||||||
"fields": "[{\"count\":0,\"name\":\"_id\",\"type\":\"string\",\"esTypes\":[\"_id\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"count\":0,\"name\":\"_index\",\"type\":\"string\",\"esTypes\":[\"_index\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"count\":0,\"name\":\"_score\",\"type\":\"number\",\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"count\":0,\"name\":\"_source\",\"type\":\"_source\",\"esTypes\":[\"_source\"],\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"count\":0,\"name\":\"_type\",\"type\":\"string\",\"esTypes\":[\"_type\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"count\":0,\"name\":\"address\",\"type\":\"string\",\"esTypes\":[\"text\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"count\":0,\"name\":\"address.keyword\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"address\"}}},{\"count\":0,\"conflictDescriptions\":{\"text\":[\"test-custom1\"],\"long\":[\"test-custom\",\"test-custom8\",\"test-custom9\"]},\"name\":\"age\",\"type\":\"conflict\",\"esTypes\":[\"text\",\"long\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"count\":0,\"name\":\"age.keyword\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"age\"}}},{\"count\":0,\"name\":\"created_at\",\"type\":\"date\",\"esTypes\":[\"date\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"count\":0,\"name\":\"email\",\"type\":\"string\",\"esTypes\":[\"text\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"count\":0,\"name\":\"email.keyword\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"email\"}}},{\"count\":0,\"name\":\"hobbies\",\"type\":\"string\",\"esTypes\":[\"text\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"count\":0,\"name\":\"hobbies.keyword\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"hobbies\"}}},{\"count\":0,\"name\":\"id\",\"type\":\"string\",\"esTypes\":[\"text\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"count\":0,\"name\":\"id.keyword\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"id\"}}},{\"count\":0,\"name\":\"name\",\"type\":\"string\",\"esTypes\":[\"text\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"count\":0,\"name\":\"name.keyword\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"name\"}}}]",
|
|
||||||
"timeFieldName": "created_at",
|
|
||||||
"title": "test*",
|
|
||||||
"fieldFormatMap": `{"age":{"id":"bytes","params":{"parsedUrl":{"origin":"http://localhost:9000","pathname":"/","basePath":""}}}}`,
|
|
||||||
},
|
|
||||||
"id": "1ccce5c0-bb9a-11eb-957b-939add21a246",
|
|
||||||
"migrationVersion": {
|
|
||||||
"index-pattern": "7.6.0"
|
|
||||||
},
|
|
||||||
"namespaces": [
|
|
||||||
"default"
|
|
||||||
],
|
|
||||||
"score": 0,
|
|
||||||
"type": "index-pattern",
|
|
||||||
"updated_at": "2021-06-27T10:13:23.639105+08:00",
|
|
||||||
// "version":"WzEwMTEzLDQ4XQ=="
|
|
||||||
|
|
||||||
}//({"id":"1ccce5c0-bb9a-11eb-957b-939add21a246","type":"index-pattern","namespaces":["default"],"updated_at":"2021-06-03T14:51:14.139Z","version":"WzEwMTEzLDQ4XQ==","attributes":{"title":"test-custom*","timeFieldName":"created_at","fields":"[{\"count\":4,\"name\":\"_id\",\"type\":\"string\",\"esTypes\":[\"_id\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"count\":0,\"name\":\"_index\",\"type\":\"string\",\"esTypes\":[\"_index\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"count\":0,\"name\":\"_score\",\"type\":\"number\",\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"count\":0,\"name\":\"_source\",\"type\":\"_source\",\"esTypes\":[\"_source\"],\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"count\":0,\"name\":\"_type\",\"type\":\"string\",\"esTypes\":[\"_type\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"count\":4,\"name\":\"address\",\"type\":\"string\",\"esTypes\":[\"text\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"count\":0,\"name\":\"address.keyword\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"address\"}}},{\"count\":0,\"conflictDescriptions\":{\"text\":[\"test-custom1\"],\"long\":[\"test-custom\",\"test-custom8\",\"test-custom9\"]},\"name\":\"age\",\"type\":\"conflict\",\"esTypes\":[\"text\",\"long\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"count\":0,\"name\":\"age.keyword\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"age\"}}},{\"count\":0,\"name\":\"created_at\",\"type\":\"date\",\"esTypes\":[\"date\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"count\":3,\"name\":\"email\",\"type\":\"string\",\"esTypes\":[\"text\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"count\":0,\"name\":\"email.keyword\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"email\"}}},{\"count\":0,\"name\":\"hobbies\",\"type\":\"string\",\"esTypes\":[\"text\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"count\":0,\"name\":\"hobbies.keyword\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"hobbies\"}}},{\"count\":0,\"name\":\"id\",\"type\":\"string\",\"esTypes\":[\"text\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"count\":0,\"name\":\"id.keyword\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"id\"}}},{\"count\":0,\"name\":\"name\",\"type\":\"string\",\"esTypes\":[\"text\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"count\":0,\"name\":\"name.keyword\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"name\"}}}]"},"references":[],"migrationVersion":{"index-pattern":"7.6.0"}});
|
|
||||||
let savedObjects = [];
|
|
||||||
req.body.forEach((reqObj)=>{
|
|
||||||
savedObjects.push({
|
|
||||||
...mockObj,
|
|
||||||
id: reqObj.id,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
return res.json({
|
|
||||||
saved_objects: savedObjects,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return res.json({"saved_objects":[{"id":"telemetry","type":"telemetry","namespaces":[],"updated_at":"2020-11-23T11:30:51.234Z","version":"WzgsMV0=","attributes":{"userHasSeenNotice":true},"references":[]}]});
|
|
||||||
},
|
|
||||||
'GET /elasticsearch/:clusterID/index_patterns/_fields_for_wildcard': (req, res)=>{
|
|
||||||
return res.json({"fields":[{"name":"_id","type":"string","esTypes":["_id"],"searchable":true,"aggregatable":true,"readFromDocValues":false},{"name":"_index","type":"string","esTypes":["_index"],"searchable":true,"aggregatable":true,"readFromDocValues":false},{"name":"_score","type":"number","searchable":false,"aggregatable":false,"readFromDocValues":false},{"name":"_source","type":"_source","esTypes":["_source"],"searchable":false,"aggregatable":false,"readFromDocValues":false},{"name":"_type","type":"string","esTypes":["_type"],"searchable":true,"aggregatable":true,"readFromDocValues":false},{"name":"address","type":"string","esTypes":["text"],"searchable":true,"aggregatable":false,"readFromDocValues":false},{"name":"address.keyword","type":"string","esTypes":["keyword"],"searchable":true,"aggregatable":true,"readFromDocValues":true,"subType":{"multi":{"parent":"address"}}},{"name":"age","type":"conflict","esTypes":["text","long"],"searchable":true,"aggregatable":true,"readFromDocValues":false,"conflictDescriptions":{"text":["test-custom1"],"long":["test-custom","test-custom8","test-custom9"]}},{"name":"age.keyword","type":"string","esTypes":["keyword"],"searchable":true,"aggregatable":true,"readFromDocValues":true,"subType":{"multi":{"parent":"age"}}},{"name":"created_at","type":"date","esTypes":["date"],"searchable":true,"aggregatable":true,"readFromDocValues":true},{"name":"email","type":"string","esTypes":["text"],"searchable":true,"aggregatable":false,"readFromDocValues":false},{"name":"email.keyword","type":"string","esTypes":["keyword"],"searchable":true,"aggregatable":true,"readFromDocValues":true,"subType":{"multi":{"parent":"email"}}},{"name":"hobbies","type":"string","esTypes":["text"],"searchable":true,"aggregatable":false,"readFromDocValues":false},{"name":"hobbies.keyword","type":"string","esTypes":["keyword"],"searchable":true,"aggregatable":true,"readFromDocValues":true,"subType":{"multi":{"parent":"hobbies"}}},{"name":"id","type":"string","esTypes":["text"],"searchable":true,"aggregatable":false,"readFromDocValues":false},{"name":"id.keyword","type":"string","esTypes":["keyword"],"searchable":true,"aggregatable":true,"readFromDocValues":true,"subType":{"multi":{"parent":"id"}}},{"name":"name","type":"string","esTypes":["text"],"searchable":true,"aggregatable":false,"readFromDocValues":false},{"name":"name.keyword","type":"string","esTypes":["keyword"],"searchable":true,"aggregatable":true,"readFromDocValues":true,"subType":{"multi":{"parent":"name"}}}]})
|
|
||||||
},
|
|
||||||
'GET elasticsearch/:clusterID/setting/defaultIndex': (req, res)=>{
|
|
||||||
return res.json('');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,657 +0,0 @@
|
||||||
const data = {
|
|
||||||
"payload": {
|
|
||||||
"blogs": {
|
|
||||||
"id": "3YOmOx_BSDqF-6EqAzBLVg",
|
|
||||||
"index": "blogs",
|
|
||||||
"status": "open",
|
|
||||||
"health": "green",
|
|
||||||
"shards": 1,
|
|
||||||
"replicas": 1,
|
|
||||||
"docs_count": 3
|
|
||||||
},
|
|
||||||
"dict": {
|
|
||||||
"id": "F6vp1k_XRn-FmXoHOsBl2Q",
|
|
||||||
"index": "dict",
|
|
||||||
"status": "open",
|
|
||||||
"health": "green",
|
|
||||||
"shards": 1,
|
|
||||||
"replicas": 1,
|
|
||||||
"docs_count": 8,
|
|
||||||
"docs_deleted": 1
|
|
||||||
},
|
|
||||||
"gateway_requests": {
|
|
||||||
"id": "C0j0942KR6muJMHyagG2AQ",
|
|
||||||
"index": "gateway_requests",
|
|
||||||
"status": "open",
|
|
||||||
"health": "green",
|
|
||||||
"shards": 1,
|
|
||||||
"replicas": 1,
|
|
||||||
"docs_count": 17961
|
|
||||||
},
|
|
||||||
"metricbeat-7.10.0-2020.11.24-000001": {
|
|
||||||
"id": "j5hJlvknQliWmVvdLVSH7w",
|
|
||||||
"index": "metricbeat-7.10.0-2020.11.24-000001",
|
|
||||||
"status": "open",
|
|
||||||
"health": "green",
|
|
||||||
"shards": 1,
|
|
||||||
"replicas": 1,
|
|
||||||
"docs_count": 257315
|
|
||||||
},
|
|
||||||
"metricbeat-7.10.0-2020.12.24-000002": {
|
|
||||||
"id": "Q3f7CTSfScCLTUCBKURzCw",
|
|
||||||
"index": "metricbeat-7.10.0-2020.12.24-000002",
|
|
||||||
"status": "open",
|
|
||||||
"health": "green",
|
|
||||||
"shards": 1,
|
|
||||||
"replicas": 1
|
|
||||||
},
|
|
||||||
"mock_log": {
|
|
||||||
"id": "NI7ntH_YRHapvjqB30LFQA",
|
|
||||||
"index": "mock_log",
|
|
||||||
"status": "open",
|
|
||||||
"health": "green",
|
|
||||||
"shards": 1,
|
|
||||||
"replicas": 1,
|
|
||||||
"docs_count": 45806
|
|
||||||
},
|
|
||||||
"mock_log1": {
|
|
||||||
"id": "FEuAjVAYTCG5FJSVqjB4cA",
|
|
||||||
"index": "mock_log1",
|
|
||||||
"status": "open",
|
|
||||||
"health": "green",
|
|
||||||
"shards": 1,
|
|
||||||
"replicas": 1,
|
|
||||||
"docs_count": 45806
|
|
||||||
},
|
|
||||||
"reindex": {
|
|
||||||
"id": "o7x8G6csQbyAMrWYqZOojA",
|
|
||||||
"index": "reindex",
|
|
||||||
"status": "open",
|
|
||||||
"health": "green",
|
|
||||||
"shards": 1,
|
|
||||||
"replicas": 1
|
|
||||||
},
|
|
||||||
"test-custom": {
|
|
||||||
"id": "17I4JLDWRdGrBL15sL3qIA",
|
|
||||||
"index": "test-custom",
|
|
||||||
"status": "open",
|
|
||||||
"health": "green",
|
|
||||||
"shards": 1,
|
|
||||||
"replicas": 1,
|
|
||||||
"docs_count": 12,
|
|
||||||
"docs_deleted": 1
|
|
||||||
},
|
|
||||||
"test-custom1": {
|
|
||||||
"id": "SEpAkmImQsGD0zVCHMtteQ",
|
|
||||||
"index": "test-custom1",
|
|
||||||
"status": "open",
|
|
||||||
"health": "green",
|
|
||||||
"shards": 1,
|
|
||||||
"replicas": 1,
|
|
||||||
"docs_count": 4
|
|
||||||
},
|
|
||||||
"test-custom8": {
|
|
||||||
"id": "PyHOJ_ytQxCzeamGBhs1_Q",
|
|
||||||
"index": "test-custom8",
|
|
||||||
"status": "open",
|
|
||||||
"health": "green",
|
|
||||||
"shards": 1,
|
|
||||||
"replicas": 1,
|
|
||||||
"docs_count": 12
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"status": true
|
|
||||||
};
|
|
||||||
|
|
||||||
const mappings = {
|
|
||||||
"payload": {
|
|
||||||
"blogs": {
|
|
||||||
"mappings": {
|
|
||||||
"properties": {
|
|
||||||
"created_at": {
|
|
||||||
"type": "date"
|
|
||||||
},
|
|
||||||
"test_field": {
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"test_field2": {
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"title": {
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"view_count": {
|
|
||||||
"type": "long"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"dict": {
|
|
||||||
"mappings": {
|
|
||||||
"properties": {
|
|
||||||
"content": {
|
|
||||||
"type": "binary"
|
|
||||||
},
|
|
||||||
"created_at": {
|
|
||||||
"type": "date"
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"tags": {
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"updated_at": {
|
|
||||||
"type": "date"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"gateway_requests": {
|
|
||||||
"mappings": {
|
|
||||||
"dynamic_templates": [
|
|
||||||
{
|
|
||||||
"strings": {
|
|
||||||
"mapping": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"match_mapping_type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"@timestamp": {
|
|
||||||
"type": "date"
|
|
||||||
},
|
|
||||||
"conn_time": {
|
|
||||||
"type": "date"
|
|
||||||
},
|
|
||||||
"flow": {
|
|
||||||
"properties": {
|
|
||||||
"from": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"relay": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"to": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
"type": "long"
|
|
||||||
},
|
|
||||||
"local_ip": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"remote_ip": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"request": {
|
|
||||||
"properties": {
|
|
||||||
"body": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"body_length": {
|
|
||||||
"type": "long"
|
|
||||||
},
|
|
||||||
"header": {
|
|
||||||
"properties": {
|
|
||||||
"accept": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"accept-encoding": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"accept-language": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"cache-control": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"connection": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"content-length": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"content-type": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"content_type": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"cookie": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"host": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"if-none-match": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"pragma": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"referer": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"sec-fetch-dest": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"sec-fetch-mode": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"sec-fetch-site": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"sec-fetch-user": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"upgrade-insecure-requests": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"user-agent": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"host": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"local_addr": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"method": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"path": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"query_args": {
|
|
||||||
"type": "object"
|
|
||||||
},
|
|
||||||
"remote_addr": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"started": {
|
|
||||||
"type": "date"
|
|
||||||
},
|
|
||||||
"uri": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"response": {
|
|
||||||
"properties": {
|
|
||||||
"body": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"body_length": {
|
|
||||||
"type": "long"
|
|
||||||
},
|
|
||||||
"cached": {
|
|
||||||
"type": "boolean"
|
|
||||||
},
|
|
||||||
"elapsed": {
|
|
||||||
"type": "float"
|
|
||||||
},
|
|
||||||
"header": {
|
|
||||||
"properties": {
|
|
||||||
"content-encoding": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"content-length": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"content-type": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"infini-cache": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"server": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"local_addr": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"remote_addr": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"status_code": {
|
|
||||||
"type": "long"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tls": {
|
|
||||||
"type": "boolean"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"mock_log": {
|
|
||||||
"mappings": {
|
|
||||||
"properties": {
|
|
||||||
"method": {
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"msg": {
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"timestamp": {
|
|
||||||
"type": "date"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"mock_log1": {
|
|
||||||
"mappings": {
|
|
||||||
"properties": {
|
|
||||||
"method": {
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"msg": {
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"timestamp": {
|
|
||||||
"type": "long"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"reindex": {
|
|
||||||
"mappings": {
|
|
||||||
"properties": {
|
|
||||||
"created_at": {
|
|
||||||
"type": "date"
|
|
||||||
},
|
|
||||||
"desc": {
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"dest": {
|
|
||||||
"type": "object"
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"source": {
|
|
||||||
"type": "object"
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
"type": "keyword"
|
|
||||||
},
|
|
||||||
"task_id": {
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"test-custom": {
|
|
||||||
"mappings": {
|
|
||||||
"properties": {
|
|
||||||
"address": {
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"age": {
|
|
||||||
"type": "long"
|
|
||||||
},
|
|
||||||
"created_at": {
|
|
||||||
"type": "date"
|
|
||||||
},
|
|
||||||
"email": {
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"hobbies": {
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "text"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"test-custom1": {
|
|
||||||
"mappings": {
|
|
||||||
"properties": {
|
|
||||||
"address": {
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"created_at": {
|
|
||||||
"type": "date"
|
|
||||||
},
|
|
||||||
"email": {
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"hobbies": {
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "text"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"test-custom8": {
|
|
||||||
"mappings": {
|
|
||||||
"properties": {
|
|
||||||
"address": {
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"age": {
|
|
||||||
"type": "long"
|
|
||||||
},
|
|
||||||
"created_at": {
|
|
||||||
"type": "date"
|
|
||||||
},
|
|
||||||
"email": {
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"hobbies": {
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"ignore_above": 256,
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "text"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"status": true
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
|
||||||
// 'get /_search-center/_cat/indices': function(req, res){
|
|
||||||
// res.send(data)
|
|
||||||
// },
|
|
||||||
// 'get /_search-center/index/:index/_mappings': function(req, res){
|
|
||||||
// res.send(mappings)
|
|
||||||
// }
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
var logstashConf = {
|
|
||||||
jdbc: {
|
|
||||||
type: 'oracle',
|
|
||||||
config: ` jdbc_driver_library => "/etc/logstash/drivers/ojdbc8.jar"
|
|
||||||
jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"
|
|
||||||
jdbc_connection_string => "jdbc:oracle:test:@192.168.1.68:1521/testdb"
|
|
||||||
jdbc_user => "testuser"
|
|
||||||
jdbc_password => "testpwd"
|
|
||||||
|
|
||||||
jdbc_paging_enabled => "true"
|
|
||||||
jdbc_page_size => "1000"
|
|
||||||
|
|
||||||
schedule => "*/1 * * * *"
|
|
||||||
statement => "SELECT a.SID, a.SERIAL#, c.spid, a.USERNAME, a.SQL_ID, a.PROGRAM, a.TERMINAL, a.MACHINE, a.MODULE, a.LOGON_TIME, a.EVENT, a.seconds_in_wait, a.status, b.sql_text FROM v$session a, v$sqlarea b, v$process c WHERE a.sql_id = b.sql_id AND c.addr = a.paddr AND a.status = 'ACTIVE' AND a.USERNAME NOT IN ('SYS', 'SYSMAN', 'DBSNMP')"
|
|
||||||
last_run_metadata_path =>"/tmp/logstash_jdbc_last_run_oracle-xxfnd-log-messages.txt"
|
|
||||||
|
|
||||||
id => "oracle-jdbc-input"
|
|
||||||
|
|
||||||
add_field => { "[labels][application]" => "oracle12.1" }
|
|
||||||
add_field => { "[labels][environment]" => "uat" }
|
|
||||||
add_field => { "[labels][location]" => "beijing" }
|
|
||||||
add_field => { "[labels][business]" => "jxoic" }
|
|
||||||
add_field => { "[labels][pdb]" => "testdb" }
|
|
||||||
|
|
||||||
add_field => { "[cloud][provider]" => "aws" }
|
|
||||||
add_field => { "[cloud][region]" => "cn-north-1" }
|
|
||||||
|
|
||||||
add_field => { "[host][ip]" => "192.168.1.68" }`
|
|
||||||
},
|
|
||||||
kafka: {
|
|
||||||
config: ` codec => json
|
|
||||||
bootstrap_servers => "192.168.1.68:9092,192.168.1.60:9092,192.168.1.61:9092"
|
|
||||||
client_id=> "logstash_pipeline_syslog_input"
|
|
||||||
security_protocol=> "PLAINTEXT"
|
|
||||||
topics=> "syslog"
|
|
||||||
consumer_threads => "1"
|
|
||||||
group_id=> "logstash-1"
|
|
||||||
decorate_events=> true`
|
|
||||||
},
|
|
||||||
};
|
|
||||||
export default {
|
|
||||||
'get /data/logstash/config': function (req, res) {
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
res.json(logstashConf);
|
|
||||||
}, 1500);
|
|
||||||
},
|
|
||||||
'POST /data/logstash/config': (req, res) => {
|
|
||||||
Object.assign(logstashConf, req.body);
|
|
||||||
console.log(logstashConf,1);
|
|
||||||
setTimeout(() => {
|
|
||||||
res.send({ message: 'Ok' });
|
|
||||||
},2000);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,101 +0,0 @@
|
||||||
var pipelineList = [{
|
|
||||||
name:"fix_locales",
|
|
||||||
desc: "test fix_locales",
|
|
||||||
processors: ` [
|
|
||||||
{
|
|
||||||
"set": {
|
|
||||||
"if": "ctx['locales'].empty",
|
|
||||||
"field": "locales",
|
|
||||||
"value": "en-en"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"set": {
|
|
||||||
"field": "reindexBatch",
|
|
||||||
"value": 3
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"split": {
|
|
||||||
"field": "locales",
|
|
||||||
"separator": ","
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]`
|
|
||||||
},{
|
|
||||||
name:"fix_locales",
|
|
||||||
desc: "test fix_locales",
|
|
||||||
processors: ` [
|
|
||||||
{
|
|
||||||
"set": {
|
|
||||||
"if": "ctx['locales'].empty",
|
|
||||||
"field": "locales",
|
|
||||||
"value": "en-en"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"set": {
|
|
||||||
"field": "reindexBatch",
|
|
||||||
"value": 3
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"split": {
|
|
||||||
"field": "locales",
|
|
||||||
"separator": ","
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]`
|
|
||||||
}];
|
|
||||||
export default {
|
|
||||||
'get /data/pipeline': function (req, res) {
|
|
||||||
res.json(pipelineList);
|
|
||||||
},
|
|
||||||
'POST /data/pipeline/add': (req, res) => {
|
|
||||||
pipelineList.push(req.body);
|
|
||||||
setTimeout(() => {
|
|
||||||
res.send({ message: 'Ok' });
|
|
||||||
},2000);
|
|
||||||
},
|
|
||||||
'PUT /data/pipeline/update': (req, res) => {
|
|
||||||
var targetIdx = -1;
|
|
||||||
pipelineList.forEach(function(p, i){
|
|
||||||
if(p.name == req.body.name){
|
|
||||||
targetIdx = i;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
console.log(req.body);
|
|
||||||
if(targetIdx > -1) {
|
|
||||||
pipelineList[targetIdx] = req.body
|
|
||||||
setTimeout(() => {
|
|
||||||
res.send({ message: 'Ok' });
|
|
||||||
},2000);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
res.send({ message: 'Fail' });
|
|
||||||
},
|
|
||||||
//delete /data/pipeline/:name
|
|
||||||
'POST /data/pipeline': (req, res) => {
|
|
||||||
var keys = req.body.key || [];
|
|
||||||
var hasDeleted = false;
|
|
||||||
for(let i=0; i< keys.length; i++){
|
|
||||||
var targetIdx = -1;
|
|
||||||
pipelineList.forEach(function(p, j){
|
|
||||||
if(keys[i] == p.name){
|
|
||||||
targetIdx = j;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if(targetIdx > -1) {
|
|
||||||
pipelineList.splice(targetIdx, 1);
|
|
||||||
hasDeleted = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(hasDeleted) {
|
|
||||||
setTimeout(() => {
|
|
||||||
res.send({ message: 'Ok' });
|
|
||||||
},2000);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
res.send({ message: 'Fail' });
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -1,533 +0,0 @@
|
||||||
let data = {
|
|
||||||
"payload": {
|
|
||||||
"took": 0,
|
|
||||||
"timed_out": false,
|
|
||||||
"hits": {
|
|
||||||
"total": {
|
|
||||||
"relation": "eq",
|
|
||||||
"value": 7
|
|
||||||
},
|
|
||||||
"max_score": 0,
|
|
||||||
"hits": [
|
|
||||||
{
|
|
||||||
"_index": "infinireindex",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "bvrdoldath27go6rq64g",
|
|
||||||
"_source": {
|
|
||||||
"created_at": "2021-01-07T18:03:01.769901+08:00",
|
|
||||||
"desc": "",
|
|
||||||
"dest": {
|
|
||||||
"index": "infini-test8",
|
|
||||||
"pipeline": ""
|
|
||||||
},
|
|
||||||
"id": "bvrdoldath27go6rq64g",
|
|
||||||
"name": "test ddd",
|
|
||||||
"source": {
|
|
||||||
"_source": [],
|
|
||||||
"index": "infini-test",
|
|
||||||
"query": null
|
|
||||||
},
|
|
||||||
"status": "SUCCEED",
|
|
||||||
"task_id": "F0D6OfeVSzuMhf5528ANTw:1050387",
|
|
||||||
"task_source": {
|
|
||||||
"completed": true,
|
|
||||||
"response": {
|
|
||||||
"batches": 1,
|
|
||||||
"created": 0,
|
|
||||||
"deleted": 0,
|
|
||||||
"failures": [],
|
|
||||||
"noops": 0,
|
|
||||||
"requests_per_second": -1,
|
|
||||||
"retries": {
|
|
||||||
"bulk": 0,
|
|
||||||
"search": 0
|
|
||||||
},
|
|
||||||
"throttled": "0s",
|
|
||||||
"throttled_millis": 0,
|
|
||||||
"throttled_until": "0s",
|
|
||||||
"throttled_until_millis": 0,
|
|
||||||
"timed_out": false,
|
|
||||||
"took": 79,
|
|
||||||
"total": 11,
|
|
||||||
"updated": 11,
|
|
||||||
"version_conflicts": 0
|
|
||||||
},
|
|
||||||
"task": {
|
|
||||||
"action": "indices:data/write/reindex",
|
|
||||||
"cancellable": true,
|
|
||||||
"description": "reindex from [infini-test] to [infini-test8][_doc]",
|
|
||||||
"headers": {},
|
|
||||||
"id": 1050387,
|
|
||||||
"node": "F0D6OfeVSzuMhf5528ANTw",
|
|
||||||
"running_time_in_nanos": 79494026,
|
|
||||||
"start_time_in_millis": 1610013781769,
|
|
||||||
"status": {
|
|
||||||
"batches": 1,
|
|
||||||
"created": 0,
|
|
||||||
"deleted": 0,
|
|
||||||
"noops": 0,
|
|
||||||
"requests_per_second": -1,
|
|
||||||
"retries": {
|
|
||||||
"bulk": 0,
|
|
||||||
"search": 0
|
|
||||||
},
|
|
||||||
"throttled_millis": 0,
|
|
||||||
"throttled_until_millis": 0,
|
|
||||||
"total": 11,
|
|
||||||
"updated": 11,
|
|
||||||
"version_conflicts": 0
|
|
||||||
},
|
|
||||||
"type": "transport"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"_index": "infinireindex",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "bvqmpstath24tgfo107g",
|
|
||||||
"_source": {
|
|
||||||
"created_at": "2021-01-06T15:55:31.426604+08:00",
|
|
||||||
"desc": "test source index not exists",
|
|
||||||
"dest": {
|
|
||||||
"index": "infini-test8",
|
|
||||||
"pipeline": ""
|
|
||||||
},
|
|
||||||
"id": "bvqmpstath24tgfo107g",
|
|
||||||
"name": "test failed",
|
|
||||||
"source": {
|
|
||||||
"_source": [],
|
|
||||||
"index": "infini-testx",
|
|
||||||
"query": null
|
|
||||||
},
|
|
||||||
"status": "FAILED",
|
|
||||||
"task_id": "F0D6OfeVSzuMhf5528ANTw:824925",
|
|
||||||
"task_source": {
|
|
||||||
"completed": true,
|
|
||||||
"error": {
|
|
||||||
"index": "infini-testx",
|
|
||||||
"index_uuid": "_na_",
|
|
||||||
"reason": "no such index [infini-testx]",
|
|
||||||
"resource.id": "infini-testx",
|
|
||||||
"resource.type": "index_or_alias",
|
|
||||||
"type": "index_not_found_exception"
|
|
||||||
},
|
|
||||||
"task": {
|
|
||||||
"action": "indices:data/write/reindex",
|
|
||||||
"cancellable": true,
|
|
||||||
"description": "reindex from [infini-testx] to [infini-test8][_doc]",
|
|
||||||
"headers": {},
|
|
||||||
"id": 824925,
|
|
||||||
"node": "F0D6OfeVSzuMhf5528ANTw",
|
|
||||||
"running_time_in_nanos": 172714,
|
|
||||||
"start_time_in_millis": 1609919731425,
|
|
||||||
"status": {
|
|
||||||
"batches": 0,
|
|
||||||
"created": 0,
|
|
||||||
"deleted": 0,
|
|
||||||
"noops": 0,
|
|
||||||
"requests_per_second": 0,
|
|
||||||
"retries": {
|
|
||||||
"bulk": 0,
|
|
||||||
"search": 0
|
|
||||||
},
|
|
||||||
"throttled_millis": 0,
|
|
||||||
"throttled_until_millis": 0,
|
|
||||||
"total": 0,
|
|
||||||
"updated": 0,
|
|
||||||
"version_conflicts": 0
|
|
||||||
},
|
|
||||||
"type": "transport"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"_index": "infinireindex",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "bvqmmnlath24tgfo1070",
|
|
||||||
"_source": {
|
|
||||||
"created_at": "2021-01-06T15:48:46.585112+08:00",
|
|
||||||
"desc": "test query param again",
|
|
||||||
"dest": {
|
|
||||||
"index": "infini-test8",
|
|
||||||
"pipeline": ""
|
|
||||||
},
|
|
||||||
"id": "bvqmmnlath24tgfo1070",
|
|
||||||
"name": "test query one",
|
|
||||||
"source": {
|
|
||||||
"_source": [],
|
|
||||||
"index": "infini-test",
|
|
||||||
"query": {
|
|
||||||
"match": {
|
|
||||||
"name": "cincky"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"status": "SUCCEED",
|
|
||||||
"task_id": "F0D6OfeVSzuMhf5528ANTw:822567",
|
|
||||||
"task_source": {
|
|
||||||
"completed": true,
|
|
||||||
"response": {
|
|
||||||
"batches": 1,
|
|
||||||
"created": 0,
|
|
||||||
"deleted": 0,
|
|
||||||
"failures": [],
|
|
||||||
"noops": 0,
|
|
||||||
"requests_per_second": -1,
|
|
||||||
"retries": {
|
|
||||||
"bulk": 0,
|
|
||||||
"search": 0
|
|
||||||
},
|
|
||||||
"throttled": "0s",
|
|
||||||
"throttled_millis": 0,
|
|
||||||
"throttled_until": "0s",
|
|
||||||
"throttled_until_millis": 0,
|
|
||||||
"timed_out": false,
|
|
||||||
"took": 44,
|
|
||||||
"total": 1,
|
|
||||||
"updated": 1,
|
|
||||||
"version_conflicts": 0
|
|
||||||
},
|
|
||||||
"task": {
|
|
||||||
"action": "indices:data/write/reindex",
|
|
||||||
"cancellable": true,
|
|
||||||
"description": "reindex from [infini-test] to [infini-test8][_doc]",
|
|
||||||
"headers": {},
|
|
||||||
"id": 822567,
|
|
||||||
"node": "F0D6OfeVSzuMhf5528ANTw",
|
|
||||||
"running_time_in_nanos": 44277146,
|
|
||||||
"start_time_in_millis": 1609919326584,
|
|
||||||
"status": {
|
|
||||||
"batches": 1,
|
|
||||||
"created": 0,
|
|
||||||
"deleted": 0,
|
|
||||||
"noops": 0,
|
|
||||||
"requests_per_second": -1,
|
|
||||||
"retries": {
|
|
||||||
"bulk": 0,
|
|
||||||
"search": 0
|
|
||||||
},
|
|
||||||
"throttled_millis": 0,
|
|
||||||
"throttled_until_millis": 0,
|
|
||||||
"total": 1,
|
|
||||||
"updated": 1,
|
|
||||||
"version_conflicts": 0
|
|
||||||
},
|
|
||||||
"type": "transport"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"_index": "infinireindex",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "bvqmlf5ath24tgfo106g",
|
|
||||||
"_source": {
|
|
||||||
"created_at": "2021-01-06T15:46:04.745132+08:00",
|
|
||||||
"desc": "test query param",
|
|
||||||
"dest": {
|
|
||||||
"index": "infini-test8",
|
|
||||||
"pipeline": ""
|
|
||||||
},
|
|
||||||
"id": "bvqmlf5ath24tgfo106g",
|
|
||||||
"name": "test query",
|
|
||||||
"source": {
|
|
||||||
"_source": [],
|
|
||||||
"index": "infini-test1",
|
|
||||||
"query": {
|
|
||||||
"match": {
|
|
||||||
"name": "test"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"status": "SUCCEED",
|
|
||||||
"task_id": "F0D6OfeVSzuMhf5528ANTw:821548",
|
|
||||||
"task_source": {
|
|
||||||
"completed": true,
|
|
||||||
"response": {
|
|
||||||
"batches": 0,
|
|
||||||
"created": 0,
|
|
||||||
"deleted": 0,
|
|
||||||
"failures": [],
|
|
||||||
"noops": 0,
|
|
||||||
"requests_per_second": -1,
|
|
||||||
"retries": {
|
|
||||||
"bulk": 0,
|
|
||||||
"search": 0
|
|
||||||
},
|
|
||||||
"throttled": "0s",
|
|
||||||
"throttled_millis": 0,
|
|
||||||
"throttled_until": "0s",
|
|
||||||
"throttled_until_millis": 0,
|
|
||||||
"timed_out": false,
|
|
||||||
"took": 0,
|
|
||||||
"total": 0,
|
|
||||||
"updated": 0,
|
|
||||||
"version_conflicts": 0
|
|
||||||
},
|
|
||||||
"task": {
|
|
||||||
"action": "indices:data/write/reindex",
|
|
||||||
"cancellable": true,
|
|
||||||
"description": "reindex from [infini-test1] to [infini-test8][_doc]",
|
|
||||||
"headers": {},
|
|
||||||
"id": 821548,
|
|
||||||
"node": "F0D6OfeVSzuMhf5528ANTw",
|
|
||||||
"running_time_in_nanos": 982379,
|
|
||||||
"start_time_in_millis": 1609919164744,
|
|
||||||
"status": {
|
|
||||||
"batches": 0,
|
|
||||||
"created": 0,
|
|
||||||
"deleted": 0,
|
|
||||||
"noops": 0,
|
|
||||||
"requests_per_second": -1,
|
|
||||||
"retries": {
|
|
||||||
"bulk": 0,
|
|
||||||
"search": 0
|
|
||||||
},
|
|
||||||
"throttled_millis": 0,
|
|
||||||
"throttled_until_millis": 0,
|
|
||||||
"total": 0,
|
|
||||||
"updated": 0,
|
|
||||||
"version_conflicts": 0
|
|
||||||
},
|
|
||||||
"type": "transport"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"_index": "infinireindex",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "bvqmkilath24tgfo1060",
|
|
||||||
"_source": {
|
|
||||||
"created_at": "2021-01-06T15:44:10.535851+08:00",
|
|
||||||
"desc": "test source param",
|
|
||||||
"dest": {
|
|
||||||
"index": "infini-test8",
|
|
||||||
"pipeline": ""
|
|
||||||
},
|
|
||||||
"id": "bvqmkilath24tgfo1060",
|
|
||||||
"name": "test source",
|
|
||||||
"source": {
|
|
||||||
"_source": [
|
|
||||||
"email",
|
|
||||||
"hobbies",
|
|
||||||
"created_at",
|
|
||||||
"name"
|
|
||||||
],
|
|
||||||
"index": "infini-test1",
|
|
||||||
"query": null
|
|
||||||
},
|
|
||||||
"status": "SUCCEED",
|
|
||||||
"task_id": "F0D6OfeVSzuMhf5528ANTw:820833",
|
|
||||||
"task_source": {
|
|
||||||
"completed": true,
|
|
||||||
"response": {
|
|
||||||
"batches": 1,
|
|
||||||
"created": 0,
|
|
||||||
"deleted": 0,
|
|
||||||
"failures": [],
|
|
||||||
"noops": 0,
|
|
||||||
"requests_per_second": -1,
|
|
||||||
"retries": {
|
|
||||||
"bulk": 0,
|
|
||||||
"search": 0
|
|
||||||
},
|
|
||||||
"throttled": "0s",
|
|
||||||
"throttled_millis": 0,
|
|
||||||
"throttled_until": "0s",
|
|
||||||
"throttled_until_millis": 0,
|
|
||||||
"timed_out": false,
|
|
||||||
"took": 53,
|
|
||||||
"total": 4,
|
|
||||||
"updated": 4,
|
|
||||||
"version_conflicts": 0
|
|
||||||
},
|
|
||||||
"task": {
|
|
||||||
"action": "indices:data/write/reindex",
|
|
||||||
"cancellable": true,
|
|
||||||
"description": "reindex from [infini-test1] to [infini-test8][_doc]",
|
|
||||||
"headers": {},
|
|
||||||
"id": 820833,
|
|
||||||
"node": "F0D6OfeVSzuMhf5528ANTw",
|
|
||||||
"running_time_in_nanos": 53101238,
|
|
||||||
"start_time_in_millis": 1609919050535,
|
|
||||||
"status": {
|
|
||||||
"batches": 1,
|
|
||||||
"created": 0,
|
|
||||||
"deleted": 0,
|
|
||||||
"noops": 0,
|
|
||||||
"requests_per_second": -1,
|
|
||||||
"retries": {
|
|
||||||
"bulk": 0,
|
|
||||||
"search": 0
|
|
||||||
},
|
|
||||||
"throttled_millis": 0,
|
|
||||||
"throttled_until_millis": 0,
|
|
||||||
"total": 4,
|
|
||||||
"updated": 4,
|
|
||||||
"version_conflicts": 0
|
|
||||||
},
|
|
||||||
"type": "transport"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"_index": "infinireindex",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "bvqmj55ath24tgfo105g",
|
|
||||||
"_source": {
|
|
||||||
"created_at": "2021-01-06T15:41:08.159721+08:00",
|
|
||||||
"desc": "test pipeline param",
|
|
||||||
"dest": {
|
|
||||||
"index": "infini-test8",
|
|
||||||
"pipeline": "test"
|
|
||||||
},
|
|
||||||
"id": "bvqmj55ath24tgfo105g",
|
|
||||||
"name": "test pipeline",
|
|
||||||
"source": {
|
|
||||||
"_source": [],
|
|
||||||
"index": "infini-test1",
|
|
||||||
"query": null
|
|
||||||
},
|
|
||||||
"status": "SUCCEED",
|
|
||||||
"task_id": "F0D6OfeVSzuMhf5528ANTw:819744",
|
|
||||||
"task_source": {
|
|
||||||
"completed": true,
|
|
||||||
"response": {
|
|
||||||
"batches": 1,
|
|
||||||
"created": 0,
|
|
||||||
"deleted": 0,
|
|
||||||
"failures": [],
|
|
||||||
"noops": 0,
|
|
||||||
"requests_per_second": -1,
|
|
||||||
"retries": {
|
|
||||||
"bulk": 0,
|
|
||||||
"search": 0
|
|
||||||
},
|
|
||||||
"throttled": "0s",
|
|
||||||
"throttled_millis": 0,
|
|
||||||
"throttled_until": "0s",
|
|
||||||
"throttled_until_millis": 0,
|
|
||||||
"timed_out": false,
|
|
||||||
"took": 251,
|
|
||||||
"total": 4,
|
|
||||||
"updated": 4,
|
|
||||||
"version_conflicts": 0
|
|
||||||
},
|
|
||||||
"task": {
|
|
||||||
"action": "indices:data/write/reindex",
|
|
||||||
"cancellable": true,
|
|
||||||
"description": "reindex from [infini-test1] to [infini-test8][_doc]",
|
|
||||||
"headers": {},
|
|
||||||
"id": 819744,
|
|
||||||
"node": "F0D6OfeVSzuMhf5528ANTw",
|
|
||||||
"running_time_in_nanos": 251872120,
|
|
||||||
"start_time_in_millis": 1609918868159,
|
|
||||||
"status": {
|
|
||||||
"batches": 1,
|
|
||||||
"created": 0,
|
|
||||||
"deleted": 0,
|
|
||||||
"noops": 0,
|
|
||||||
"requests_per_second": -1,
|
|
||||||
"retries": {
|
|
||||||
"bulk": 0,
|
|
||||||
"search": 0
|
|
||||||
},
|
|
||||||
"throttled_millis": 0,
|
|
||||||
"throttled_until_millis": 0,
|
|
||||||
"total": 4,
|
|
||||||
"updated": 4,
|
|
||||||
"version_conflicts": 0
|
|
||||||
},
|
|
||||||
"type": "transport"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"_index": "infinireindex",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "bvq89p5ath243f63hngg",
|
|
||||||
"_source": {
|
|
||||||
"created_at": "2021-01-05T23:25:24.751473+08:00",
|
|
||||||
"desc": "test new rebuild api",
|
|
||||||
"dest": {
|
|
||||||
"index": "infini-test8",
|
|
||||||
"pipeline": ""
|
|
||||||
},
|
|
||||||
"id": "bvq89p5ath243f63hngg",
|
|
||||||
"name": "test new rebuild api",
|
|
||||||
"source": {
|
|
||||||
"_source": [],
|
|
||||||
"index": "infini-test",
|
|
||||||
"query": null
|
|
||||||
},
|
|
||||||
"status": "SUCCEED",
|
|
||||||
"task_id": "F0D6OfeVSzuMhf5528ANTw:707730",
|
|
||||||
"task_source": {
|
|
||||||
"completed": true,
|
|
||||||
"response": {
|
|
||||||
"batches": 1,
|
|
||||||
"created": 11,
|
|
||||||
"deleted": 0,
|
|
||||||
"failures": [],
|
|
||||||
"noops": 0,
|
|
||||||
"requests_per_second": -1,
|
|
||||||
"retries": {
|
|
||||||
"bulk": 0,
|
|
||||||
"search": 0
|
|
||||||
},
|
|
||||||
"throttled": "0s",
|
|
||||||
"throttled_millis": 0,
|
|
||||||
"throttled_until": "0s",
|
|
||||||
"throttled_until_millis": 0,
|
|
||||||
"timed_out": false,
|
|
||||||
"took": 117,
|
|
||||||
"total": 11,
|
|
||||||
"updated": 0,
|
|
||||||
"version_conflicts": 0
|
|
||||||
},
|
|
||||||
"task": {
|
|
||||||
"action": "indices:data/write/reindex",
|
|
||||||
"cancellable": true,
|
|
||||||
"description": "reindex from [infini-test] to [infini-test8][_doc]",
|
|
||||||
"headers": {},
|
|
||||||
"id": 707730,
|
|
||||||
"node": "F0D6OfeVSzuMhf5528ANTw",
|
|
||||||
"running_time_in_nanos": 118081190,
|
|
||||||
"start_time_in_millis": 1609860324750,
|
|
||||||
"status": {
|
|
||||||
"batches": 1,
|
|
||||||
"created": 11,
|
|
||||||
"deleted": 0,
|
|
||||||
"noops": 0,
|
|
||||||
"requests_per_second": -1,
|
|
||||||
"retries": {
|
|
||||||
"bulk": 0,
|
|
||||||
"search": 0
|
|
||||||
},
|
|
||||||
"throttled_millis": 0,
|
|
||||||
"throttled_until_millis": 0,
|
|
||||||
"total": 11,
|
|
||||||
"updated": 0,
|
|
||||||
"version_conflicts": 0
|
|
||||||
},
|
|
||||||
"type": "transport"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"status": true
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
|
||||||
// 'get /_search-center/rebuild/_search': function(req, res){
|
|
||||||
// res.send(data)
|
|
||||||
// }
|
|
||||||
}
|
|
|
@ -1,129 +0,0 @@
|
||||||
export default {
|
|
||||||
'GET /elasticsearch/_search': function(req, res){
|
|
||||||
res.send({
|
|
||||||
"took": 0,
|
|
||||||
"timed_out": false,
|
|
||||||
"hits": {
|
|
||||||
"total": {
|
|
||||||
"relation": "eq",
|
|
||||||
"value": 1
|
|
||||||
},
|
|
||||||
"max_score": 1,
|
|
||||||
"hits": [
|
|
||||||
{
|
|
||||||
"_index": ".infini-search-center_cluster",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "c0oc4kkgq9s8qss2uk50",
|
|
||||||
"_source": {
|
|
||||||
"basic_auth": {
|
|
||||||
"password": "123",
|
|
||||||
"username": "medcl"
|
|
||||||
},
|
|
||||||
"created": "2021-02-20T16:03:30.867084+08:00",
|
|
||||||
"description": "xx业务集群1",
|
|
||||||
"enabled": true,
|
|
||||||
"monitored": true,
|
|
||||||
"endpoint": "http://localhost:9200",
|
|
||||||
"name": "cluster1",
|
|
||||||
"updated": "2021-02-20T16:03:30.867084+08:00"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"_index": ".infini-search-center_cluster",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "c0oc4kkgq9s8qss2uk51",
|
|
||||||
"_source": {
|
|
||||||
"basic_auth": {
|
|
||||||
"password": "123",
|
|
||||||
"username": "medcl"
|
|
||||||
},
|
|
||||||
"created": "2021-02-20T16:03:30.867084+08:00",
|
|
||||||
"description": "xx业务集群2",
|
|
||||||
"enabled": true,
|
|
||||||
"monitored": true,
|
|
||||||
"endpoint": "http://localhost:9201",
|
|
||||||
"name": "cluster2",
|
|
||||||
"updated": "2021-02-20T16:03:30.867084+08:00"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
'POST /elasticsearch/_search': function(req, res){
|
|
||||||
res.send({
|
|
||||||
"took": 0,
|
|
||||||
"timed_out": false,
|
|
||||||
"hits": {
|
|
||||||
"total": {
|
|
||||||
"relation": "eq",
|
|
||||||
"value": 1
|
|
||||||
},
|
|
||||||
"max_score": 1,
|
|
||||||
"hits": [
|
|
||||||
{
|
|
||||||
"_index": ".infini-search-center_cluster",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "c0oc4kkgq9s8qss2uk50",
|
|
||||||
"_source": {
|
|
||||||
"basic_auth": {
|
|
||||||
"password": "123",
|
|
||||||
"username": "medcl"
|
|
||||||
},
|
|
||||||
"created": "2021-02-20T16:03:30.867084+08:00",
|
|
||||||
"description": "xx业务集群1",
|
|
||||||
"enabled": false,
|
|
||||||
"monitored": true,
|
|
||||||
"endpoint": "http://localhost:9200",
|
|
||||||
"name": "cluster1",
|
|
||||||
"updated": "2021-02-20T16:03:30.867084+08:00"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
'POST /elasticsearch': function(req, res){
|
|
||||||
res.send({
|
|
||||||
"_id": "c0oc4kkgq9s8qss2uk50",
|
|
||||||
"_source": {
|
|
||||||
"name": "cluster1",
|
|
||||||
"endpoint": "http://localhost:9200",
|
|
||||||
"basic_auth": {
|
|
||||||
"username": "medcl",
|
|
||||||
"password": "123"
|
|
||||||
},
|
|
||||||
"description": "xx业务集群1",
|
|
||||||
"enabled": false,
|
|
||||||
"monitored": true,
|
|
||||||
"created": "2021-02-20T15:12:50.984062+08:00",
|
|
||||||
"updated": "2021-02-20T15:12:50.984062+08:00"
|
|
||||||
},
|
|
||||||
"result": "created"
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'PUT /elasticsearch/:id': function(req, res){
|
|
||||||
res.send({
|
|
||||||
"_id": "c0oc4kkgq9s8qss2uk50",
|
|
||||||
"_source": {
|
|
||||||
"basic_auth": {
|
|
||||||
"password": "456",
|
|
||||||
"username": "medcl"
|
|
||||||
},
|
|
||||||
"description": "xx业务集群2",
|
|
||||||
"endpoint": "http://localhost:9201",
|
|
||||||
"name": "cluster2",
|
|
||||||
"enabled": true,
|
|
||||||
"monitored": true,
|
|
||||||
"updated": "2021-02-20T15:25:12.159789+08:00"
|
|
||||||
},
|
|
||||||
"result": "updated"
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'DELETE /elasticsearch/:id': function(req, res){
|
|
||||||
res.send({
|
|
||||||
"_id": "c0oc4kkgq9s8qss2uk50",
|
|
||||||
"result": "deleted"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,233 +0,0 @@
|
||||||
export default {
|
|
||||||
// 'POST /elasticsearch/:id/_proxy': function(req, res){
|
|
||||||
// res.set('content-type', 'content-type: text/plain; charset=UTF-8');
|
|
||||||
// res.send('.security .security-7 - - - -\n' +
|
|
||||||
// 'ilm-history-2 ilm-history-2-000002 - - - true\n' +
|
|
||||||
// '.kibana-event-log-7.9.2 .kibana-event-log-7.9.2-000002 - - - true\n' +
|
|
||||||
// '.kibana_task_manager .kibana_task_manager_1 - - - -\n' +
|
|
||||||
// '.kibana .kibana_1 - - - -\n' +
|
|
||||||
// '.kibana-event-log-7.9.2 .kibana-event-log-7.9.2-000001 - - - false\n' +
|
|
||||||
// 'ilm-history-2 ilm-history-2-000001 - - - false');
|
|
||||||
// },
|
|
||||||
|
|
||||||
// curl -XPOST http://localhost:8000/elasticsearch/uuid/_proxy\?path=%2F_search&method=GET?pretty -d '{ "size": 1 }'
|
|
||||||
'POST /elasticsearch/:id/_proxy': function(req, res){
|
|
||||||
const {path} = req.query;
|
|
||||||
switch(path){
|
|
||||||
case '_mapping':
|
|
||||||
return res.send({"test-custom9":{"mappings":{"properties":{"address":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"age":{"type":"long"},"created_at":{"type":"date"},"email":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"hobbies":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"id":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"name":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}}},"test-custom1":{"mappings":{"properties":{"address":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"age":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"created_at":{"type":"date"},"email":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"hobbies":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"id":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"name":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}}},"test-custom":{"mappings":{"properties":{"address":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"age":{"type":"long"},"created_at":{"type":"date"},"email":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"hobbies":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"id":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"name":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}}},"test-custom8":{"mappings":{"properties":{"address":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"age":{"type":"long"},"created_at":{"type":"date"},"email":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"hobbies":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"id":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"name":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}}}});
|
|
||||||
case '_aliases':
|
|
||||||
return res.send({"test-custom8":{"aliases":{"custom":{"filter":{"match":{"name":"test"}},"index_routing":"1","search_routing":"1"}}},"test-custom9":{"aliases":{"custom":{"filter":{"match":{"name":"test"}},"index_routing":"1","search_routing":"1"}}},"test-custom1":{"aliases":{"custom":{"filter":{"match":{"name":"test"}},"index_routing":"1","search_routing":"1"}}},"test-custom":{"aliases":{"custom":{"filter":{"match":{"name":"test"}},"index_routing":"1","search_routing":"1","is_write_index":true}}}});
|
|
||||||
case 'template':
|
|
||||||
return res.send({"search-center":{"order":0,"index_patterns":["infini-*"],"settings":{"index":{"max_result_window":"10000000","number_of_shards":"1"}},"mappings":{"dynamic_templates":[{"strings":{"mapping":{"ignore_above":256,"type":"keyword"},"match_mapping_type":"string"}}]},"aliases":{}}});
|
|
||||||
}
|
|
||||||
res.send({
|
|
||||||
"took" : 1055,
|
|
||||||
"timed_out" : false,
|
|
||||||
"_shards" : {
|
|
||||||
"total" : 37,
|
|
||||||
"successful" : 37,
|
|
||||||
"skipped" : 0,
|
|
||||||
"failed" : 0
|
|
||||||
},
|
|
||||||
"hits" : {
|
|
||||||
"total" : {
|
|
||||||
"value" : 10000,
|
|
||||||
"relation" : "gte"
|
|
||||||
},
|
|
||||||
"max_score" : 1.0,
|
|
||||||
"hits" : [
|
|
||||||
{
|
|
||||||
"_index" : ".kibana-event-log-7.9.2-000001",
|
|
||||||
"_type" : "_doc",
|
|
||||||
"_id" : "VLvqYncBwyX1iJ4H4cBA",
|
|
||||||
"_score" : 1.0,
|
|
||||||
"_source" : {
|
|
||||||
"event" : {
|
|
||||||
"provider" : "eventLog",
|
|
||||||
"action" : "starting"
|
|
||||||
},
|
|
||||||
"message" : "eventLog starting",
|
|
||||||
"@timestamp" : "2021-02-02T13:23:16.799Z",
|
|
||||||
"ecs" : {
|
|
||||||
"version" : "1.5.0"
|
|
||||||
},
|
|
||||||
"kibana" : {
|
|
||||||
"server_uuid" : "d9f160b3-97c4-4aa9-928f-209d481b6e83"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
//查看 proxy 请求历史记录
|
|
||||||
'GET /elasticsearch/:id/proxy_history/_search': function(req, res){
|
|
||||||
res.send({
|
|
||||||
"took" : 1055,
|
|
||||||
"timed_out" : false,
|
|
||||||
"_shards" : {
|
|
||||||
"total" : 37,
|
|
||||||
"successful" : 37,
|
|
||||||
"skipped" : 0,
|
|
||||||
"failed" : 0
|
|
||||||
},
|
|
||||||
"hits" : {
|
|
||||||
"total" : {
|
|
||||||
"value" : 10000,
|
|
||||||
"relation" : "gte"
|
|
||||||
},
|
|
||||||
"max_score" : 1.0,
|
|
||||||
"hits" : [
|
|
||||||
{
|
|
||||||
"_index" : "gateway-command-history-7.9.2-000001",
|
|
||||||
"_type" : "_doc",
|
|
||||||
"_id" : "VLvqYncBwyX1iJ4H4cBA",
|
|
||||||
"_score" : 1.0,
|
|
||||||
"_source" : {
|
|
||||||
"created" : "2021-02-02T13:23:16.799Z",
|
|
||||||
"request" : {
|
|
||||||
"method" : "POST",
|
|
||||||
"path" : "/myindex/_search",
|
|
||||||
"body" : "{ \"query\": { \"match\": { \"name\": \"medcl\" } } }"
|
|
||||||
},
|
|
||||||
"status":200
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
//新增/修改常用命令, id 可选
|
|
||||||
//curl -XPOST /elasticsearch/:id/command/:id -d'
|
|
||||||
// {
|
|
||||||
// "request" : {
|
|
||||||
// "method" : "POST",
|
|
||||||
// "path" : "/myindex/_search",
|
|
||||||
// "body" : "{ \"query\": { \"match\": { \"name\": \"medcl\" } } }"
|
|
||||||
// },
|
|
||||||
// "title":"一个常用查询的例子",
|
|
||||||
// "tag":["example","search"]
|
|
||||||
// }'
|
|
||||||
'POST /elasticsearch/:id/command': function(req, res){
|
|
||||||
res.send({
|
|
||||||
"_id": "c0oc4kkgq9s8qss2uk50",
|
|
||||||
"_source": {
|
|
||||||
"created" : "2021-02-02T13:23:16.799Z",
|
|
||||||
"request" : {
|
|
||||||
"method" : "POST",
|
|
||||||
"path" : "/myindex/_search",
|
|
||||||
"body" : "{ \"query\": { \"match\": { \"name\": \"medcl\" } } }"
|
|
||||||
},
|
|
||||||
"title":"一个常用查询的例子",
|
|
||||||
"tag":["example","search"]
|
|
||||||
},
|
|
||||||
"result": "created"
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'POST /elasticsearch/:id/command/:id': function(req, res){
|
|
||||||
res.send({
|
|
||||||
"_id": "c0oc4kkgq9s8qss2uk50",
|
|
||||||
"_source": {
|
|
||||||
"created" : "2021-02-02T13:23:16.799Z",
|
|
||||||
"request" : {
|
|
||||||
"method" : "POST",
|
|
||||||
"path" : "/myindex/_search",
|
|
||||||
"body" : "{ \"query\": { \"match\": { \"name\": \"medcl\" } } }"
|
|
||||||
},
|
|
||||||
"title":"一个常用查询的例子",
|
|
||||||
"tag":["example","search"]
|
|
||||||
},
|
|
||||||
"result": "created"
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
//加载常用命令
|
|
||||||
// 'GET /elasticsearch/:id/command/:id': function(req, res){
|
|
||||||
// res.send({
|
|
||||||
// "_id": "c0oc4kkgq9s8qss2uk50",
|
|
||||||
// "_source": {
|
|
||||||
// "created" : "2021-02-02T13:23:16.799Z",
|
|
||||||
// "request" : {
|
|
||||||
// "method" : "POST",
|
|
||||||
// "path" : "/myindex/_search",
|
|
||||||
// "body" : "{ \"query\": { \"match\": { \"name\": \"medcl\" } } }"
|
|
||||||
// },
|
|
||||||
// "status":200,
|
|
||||||
// "title":"一个常用查询的例子",
|
|
||||||
// "tag":["example","search"]
|
|
||||||
// },
|
|
||||||
// "found": true
|
|
||||||
// });
|
|
||||||
// },
|
|
||||||
|
|
||||||
//删除常用命令
|
|
||||||
'DELETE /elasticsearch/:id/command/:id': function(req, res){
|
|
||||||
res.send({
|
|
||||||
"_id": "c0oc4kkgq9s8qss2uk50",
|
|
||||||
"result": "deleted"
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
//搜索常用命令
|
|
||||||
'GET /elasticsearch/:id/command/_search': function(req, res){
|
|
||||||
res.send({
|
|
||||||
"took" : 1055,
|
|
||||||
"timed_out" : false,
|
|
||||||
"_shards" : {
|
|
||||||
"total" : 37,
|
|
||||||
"successful" : 37,
|
|
||||||
"skipped" : 0,
|
|
||||||
"failed" : 0
|
|
||||||
},
|
|
||||||
"hits" : {
|
|
||||||
"total" : {
|
|
||||||
"value" : 10000,
|
|
||||||
"relation" : "gte"
|
|
||||||
},
|
|
||||||
"max_score" : 1.0,
|
|
||||||
"hits" : [
|
|
||||||
{
|
|
||||||
"_index" : "gateway-command-7.9.2-000001",
|
|
||||||
"_type" : "_doc",
|
|
||||||
"_id" : "VLvqYncBwyX1iJ4H4cBA",
|
|
||||||
"_score" : 1.0,
|
|
||||||
"_source" : {
|
|
||||||
"created" : "2021-02-02T13:23:16.799Z",
|
|
||||||
"request" : {
|
|
||||||
"method" : "POST",
|
|
||||||
"path" : "/myindex/_search",
|
|
||||||
"body" : "{ \"query\": { \"match\": { \"name\": \"medcl\" } } }"
|
|
||||||
},
|
|
||||||
"title":"command1",
|
|
||||||
"tag":["example","search"]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"_index" : "gateway-command-7.9.2-000001",
|
|
||||||
"_type" : "_doc",
|
|
||||||
"_id" : "VLvqYncBwyX1iJ4H4cBA",
|
|
||||||
"_score" : 1.0,
|
|
||||||
"_source" : {
|
|
||||||
"created" : "2021-02-02T13:23:16.799Z",
|
|
||||||
"request" : {
|
|
||||||
"method" : "GET",
|
|
||||||
"path" : "/myindex/_search",
|
|
||||||
"body" : "{ \"query\": { \"match\": { \"name\": \"medcl\" } } }"
|
|
||||||
},
|
|
||||||
"title":"command2",
|
|
||||||
"tag":["example","search"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
var Mock = require('mockjs')
|
|
||||||
var data = Mock.mock({
|
|
||||||
// 属性 list 的值是一个数组,其中含有 1 到 10 个元素
|
|
||||||
'list|1-10': [{
|
|
||||||
// 属性 id 是一个自增数,起始值为 1,每次增 1
|
|
||||||
'id|+1': 1
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
const random_endpoints = [
|
|
||||||
{
|
|
||||||
os: 'Windows',
|
|
||||||
name: "LENOVO",
|
|
||||||
ip: '192.168.3.1',
|
|
||||||
status: "active", //active/inactive/unmonitored
|
|
||||||
last_active: "2020-03-21 11:12:33",
|
|
||||||
tag: ["win10"],
|
|
||||||
test: data
|
|
||||||
},
|
|
||||||
{
|
|
||||||
os: "Linux",
|
|
||||||
name: 'RaspberryPi',
|
|
||||||
ip: '192.168.3.81',
|
|
||||||
last_active: "2020-03-21 11:12:33",
|
|
||||||
tag: ["win10"],
|
|
||||||
credentials:{
|
|
||||||
user: "pi",
|
|
||||||
password: "elastic"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
let random_endpoint_pick = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default {
|
|
||||||
'get /endpoints/get_endpoints': function (req, res) {
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
res.json(random_endpoints);
|
|
||||||
}, 3000);
|
|
||||||
},
|
|
||||||
|
|
||||||
'get /endpoints/get_endpoint/1': function (req, res) {
|
|
||||||
const responseObj = random_endpoints[random_endpoint_pick % random_endpoints.length];
|
|
||||||
random_endpoint_pick += 1;
|
|
||||||
setTimeout(() => {
|
|
||||||
res.json(responseObj);
|
|
||||||
}, 3000);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
import city from './geographic/city.json';
|
|
||||||
import province from './geographic/province.json';
|
|
||||||
|
|
||||||
function getProvince(req, res) {
|
|
||||||
return res.json(province);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getCity(req, res) {
|
|
||||||
return res.json(city[req.params.province]);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
'GET /api/geographic/province': getProvince,
|
|
||||||
'GET /api/geographic/city/:province': getCity,
|
|
||||||
};
|
|
|
@ -1,138 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": "北京市",
|
|
||||||
"id": "110000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "天津市",
|
|
||||||
"id": "120000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "河北省",
|
|
||||||
"id": "130000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "山西省",
|
|
||||||
"id": "140000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "内蒙古自治区",
|
|
||||||
"id": "150000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "辽宁省",
|
|
||||||
"id": "210000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "吉林省",
|
|
||||||
"id": "220000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "黑龙江省",
|
|
||||||
"id": "230000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "上海市",
|
|
||||||
"id": "310000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "江苏省",
|
|
||||||
"id": "320000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "浙江省",
|
|
||||||
"id": "330000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "安徽省",
|
|
||||||
"id": "340000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "福建省",
|
|
||||||
"id": "350000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "江西省",
|
|
||||||
"id": "360000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "山东省",
|
|
||||||
"id": "370000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "河南省",
|
|
||||||
"id": "410000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "湖北省",
|
|
||||||
"id": "420000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "湖南省",
|
|
||||||
"id": "430000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "广东省",
|
|
||||||
"id": "440000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "广西壮族自治区",
|
|
||||||
"id": "450000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "海南省",
|
|
||||||
"id": "460000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "重庆市",
|
|
||||||
"id": "500000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "四川省",
|
|
||||||
"id": "510000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "贵州省",
|
|
||||||
"id": "520000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "云南省",
|
|
||||||
"id": "530000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "西藏自治区",
|
|
||||||
"id": "540000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "陕西省",
|
|
||||||
"id": "610000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "甘肃省",
|
|
||||||
"id": "620000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "青海省",
|
|
||||||
"id": "630000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "宁夏回族自治区",
|
|
||||||
"id": "640000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "新疆维吾尔自治区",
|
|
||||||
"id": "650000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "台湾省",
|
|
||||||
"id": "710000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "香港特别行政区",
|
|
||||||
"id": "810000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "澳门特别行政区",
|
|
||||||
"id": "820000"
|
|
||||||
}
|
|
||||||
]
|
|
|
@ -1,99 +0,0 @@
|
||||||
const getNotices = (req, res) =>
|
|
||||||
res.json([
|
|
||||||
{
|
|
||||||
id: '000000001',
|
|
||||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
|
|
||||||
title: '你收到了 14 份新周报',
|
|
||||||
datetime: '2017-08-09',
|
|
||||||
type: 'notification',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '000000002',
|
|
||||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/OKJXDXrmkNshAMvwtvhu.png',
|
|
||||||
title: '你推荐的 曲妮妮 已通过第三轮面试',
|
|
||||||
datetime: '2017-08-08',
|
|
||||||
type: 'notification',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '000000003',
|
|
||||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/kISTdvpyTAhtGxpovNWd.png',
|
|
||||||
title: '这种模板可以区分多种通知类型',
|
|
||||||
datetime: '2017-08-07',
|
|
||||||
read: true,
|
|
||||||
type: 'notification',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '000000004',
|
|
||||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/GvqBnKhFgObvnSGkDsje.png',
|
|
||||||
title: '左侧图标用于区分不同的类型',
|
|
||||||
datetime: '2017-08-07',
|
|
||||||
type: 'notification',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '000000005',
|
|
||||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
|
|
||||||
title: '内容不要超过两行字,超出时自动截断',
|
|
||||||
datetime: '2017-08-07',
|
|
||||||
type: 'notification',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '000000006',
|
|
||||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
|
|
||||||
title: '曲丽丽 评论了你',
|
|
||||||
description: '描述信息描述信息描述信息',
|
|
||||||
datetime: '2017-08-07',
|
|
||||||
type: 'message',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '000000007',
|
|
||||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
|
|
||||||
title: '朱偏右 回复了你',
|
|
||||||
description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像',
|
|
||||||
datetime: '2017-08-07',
|
|
||||||
type: 'message',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '000000008',
|
|
||||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
|
|
||||||
title: '标题',
|
|
||||||
description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像',
|
|
||||||
datetime: '2017-08-07',
|
|
||||||
type: 'message',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '000000009',
|
|
||||||
title: '任务名称',
|
|
||||||
description: '任务需要在 2017-01-12 20:00 前启动',
|
|
||||||
extra: '未开始',
|
|
||||||
status: 'todo',
|
|
||||||
type: 'event',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '000000010',
|
|
||||||
title: '第三方紧急代码变更',
|
|
||||||
description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务',
|
|
||||||
extra: '马上到期',
|
|
||||||
status: 'urgent',
|
|
||||||
type: 'event',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '000000011',
|
|
||||||
title: '信息安全考试',
|
|
||||||
description: '指派竹尔于 2017-01-09 前完成更新并发布',
|
|
||||||
extra: '已耗时 8 天',
|
|
||||||
status: 'doing',
|
|
||||||
type: 'event',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '000000012',
|
|
||||||
title: 'ABCD 版本发布',
|
|
||||||
description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务',
|
|
||||||
extra: '进行中',
|
|
||||||
status: 'processing',
|
|
||||||
type: 'event',
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
export default {
|
|
||||||
'GET /api/notices': getNotices,
|
|
||||||
};
|
|
|
@ -1,158 +0,0 @@
|
||||||
const basicGoods = [
|
|
||||||
{
|
|
||||||
id: '1234561',
|
|
||||||
name: '矿泉水 550ml',
|
|
||||||
barcode: '12421432143214321',
|
|
||||||
price: '2.00',
|
|
||||||
num: '1',
|
|
||||||
amount: '2.00',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '1234562',
|
|
||||||
name: '凉茶 300ml',
|
|
||||||
barcode: '12421432143214322',
|
|
||||||
price: '3.00',
|
|
||||||
num: '2',
|
|
||||||
amount: '6.00',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '1234563',
|
|
||||||
name: '好吃的薯片',
|
|
||||||
barcode: '12421432143214323',
|
|
||||||
price: '7.00',
|
|
||||||
num: '4',
|
|
||||||
amount: '28.00',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '1234564',
|
|
||||||
name: '特别好吃的蛋卷',
|
|
||||||
barcode: '12421432143214324',
|
|
||||||
price: '8.50',
|
|
||||||
num: '3',
|
|
||||||
amount: '25.50',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const basicProgress = [
|
|
||||||
{
|
|
||||||
key: '1',
|
|
||||||
time: '2017-10-01 14:10',
|
|
||||||
rate: '联系客户',
|
|
||||||
status: 'processing',
|
|
||||||
operator: '取货员 ID1234',
|
|
||||||
cost: '5mins',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: '2',
|
|
||||||
time: '2017-10-01 14:05',
|
|
||||||
rate: '取货员出发',
|
|
||||||
status: 'success',
|
|
||||||
operator: '取货员 ID1234',
|
|
||||||
cost: '1h',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: '3',
|
|
||||||
time: '2017-10-01 13:05',
|
|
||||||
rate: '取货员接单',
|
|
||||||
status: 'success',
|
|
||||||
operator: '取货员 ID1234',
|
|
||||||
cost: '5mins',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: '4',
|
|
||||||
time: '2017-10-01 13:00',
|
|
||||||
rate: '申请审批通过',
|
|
||||||
status: 'success',
|
|
||||||
operator: '系统',
|
|
||||||
cost: '1h',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: '5',
|
|
||||||
time: '2017-10-01 12:00',
|
|
||||||
rate: '发起退货申请',
|
|
||||||
status: 'success',
|
|
||||||
operator: '用户',
|
|
||||||
cost: '5mins',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const advancedOperation1 = [
|
|
||||||
{
|
|
||||||
key: 'op1',
|
|
||||||
type: '订购关系生效',
|
|
||||||
name: '曲丽丽',
|
|
||||||
status: 'agree',
|
|
||||||
updatedAt: '2017-10-03 19:23:12',
|
|
||||||
memo: '-',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'op2',
|
|
||||||
type: '财务复审',
|
|
||||||
name: '付小小',
|
|
||||||
status: 'reject',
|
|
||||||
updatedAt: '2017-10-03 19:23:12',
|
|
||||||
memo: '不通过原因',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'op3',
|
|
||||||
type: '部门初审',
|
|
||||||
name: '周毛毛',
|
|
||||||
status: 'agree',
|
|
||||||
updatedAt: '2017-10-03 19:23:12',
|
|
||||||
memo: '-',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'op4',
|
|
||||||
type: '提交订单',
|
|
||||||
name: '林东东',
|
|
||||||
status: 'agree',
|
|
||||||
updatedAt: '2017-10-03 19:23:12',
|
|
||||||
memo: '很棒',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'op5',
|
|
||||||
type: '创建订单',
|
|
||||||
name: '汗牙牙',
|
|
||||||
status: 'agree',
|
|
||||||
updatedAt: '2017-10-03 19:23:12',
|
|
||||||
memo: '-',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const advancedOperation2 = [
|
|
||||||
{
|
|
||||||
key: 'op1',
|
|
||||||
type: '订购关系生效',
|
|
||||||
name: '曲丽丽',
|
|
||||||
status: 'agree',
|
|
||||||
updatedAt: '2017-10-03 19:23:12',
|
|
||||||
memo: '-',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const advancedOperation3 = [
|
|
||||||
{
|
|
||||||
key: 'op1',
|
|
||||||
type: '创建订单',
|
|
||||||
name: '汗牙牙',
|
|
||||||
status: 'agree',
|
|
||||||
updatedAt: '2017-10-03 19:23:12',
|
|
||||||
memo: '-',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const getProfileBasicData = {
|
|
||||||
basicGoods,
|
|
||||||
basicProgress,
|
|
||||||
};
|
|
||||||
|
|
||||||
const getProfileAdvancedData = {
|
|
||||||
advancedOperation1,
|
|
||||||
advancedOperation2,
|
|
||||||
advancedOperation3,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
|
||||||
'GET /api/profile/advanced': getProfileAdvancedData,
|
|
||||||
'GET /api/profile/basic': getProfileBasicData,
|
|
||||||
};
|
|
138
web/mock/rule.js
|
@ -1,138 +0,0 @@
|
||||||
import { parse } from 'url';
|
|
||||||
|
|
||||||
// mock tableListDataSource
|
|
||||||
let tableListDataSource = [];
|
|
||||||
for (let i = 0; i < 46; i += 1) {
|
|
||||||
tableListDataSource.push({
|
|
||||||
key: i,
|
|
||||||
disabled: i % 6 === 0,
|
|
||||||
href: 'https://ant.design',
|
|
||||||
avatar: [
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
|
|
||||||
][i % 2],
|
|
||||||
name: `TradeCode ${i}`,
|
|
||||||
title: `一个任务名称 ${i}`,
|
|
||||||
owner: '曲丽丽',
|
|
||||||
desc: '这是一段描述',
|
|
||||||
callNo: Math.floor(Math.random() * 1000),
|
|
||||||
status: Math.floor(Math.random() * 10) % 4,
|
|
||||||
updatedAt: new Date(`2017-07-${Math.floor(i / 2) + 1}`),
|
|
||||||
createdAt: new Date(`2017-07-${Math.floor(i / 2) + 1}`),
|
|
||||||
progress: Math.ceil(Math.random() * 100),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getRule(req, res, u) {
|
|
||||||
let url = u;
|
|
||||||
if (!url || Object.prototype.toString.call(url) !== '[object String]') {
|
|
||||||
url = req.url; // eslint-disable-line
|
|
||||||
}
|
|
||||||
|
|
||||||
const params = parse(url, true).query;
|
|
||||||
|
|
||||||
let dataSource = tableListDataSource;
|
|
||||||
|
|
||||||
if (params.sorter) {
|
|
||||||
const s = params.sorter.split('_');
|
|
||||||
dataSource = dataSource.sort((prev, next) => {
|
|
||||||
if (s[1] === 'descend') {
|
|
||||||
return next[s[0]] - prev[s[0]];
|
|
||||||
}
|
|
||||||
return prev[s[0]] - next[s[0]];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params.status) {
|
|
||||||
const status = params.status.split(',');
|
|
||||||
let filterDataSource = [];
|
|
||||||
status.forEach(s => {
|
|
||||||
filterDataSource = filterDataSource.concat(
|
|
||||||
dataSource.filter(data => parseInt(data.status, 10) === parseInt(s[0], 10))
|
|
||||||
);
|
|
||||||
});
|
|
||||||
dataSource = filterDataSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params.name) {
|
|
||||||
dataSource = dataSource.filter(data => data.name.indexOf(params.name) > -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
let pageSize = 10;
|
|
||||||
if (params.pageSize) {
|
|
||||||
pageSize = params.pageSize * 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = {
|
|
||||||
list: dataSource,
|
|
||||||
pagination: {
|
|
||||||
total: dataSource.length,
|
|
||||||
pageSize,
|
|
||||||
current: parseInt(params.currentPage, 10) || 1,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
return res.json(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function postRule(req, res, u, b) {
|
|
||||||
let url = u;
|
|
||||||
if (!url || Object.prototype.toString.call(url) !== '[object String]') {
|
|
||||||
url = req.url; // eslint-disable-line
|
|
||||||
}
|
|
||||||
|
|
||||||
const body = (b && b.body) || req.body;
|
|
||||||
const { method, name, desc, key } = body;
|
|
||||||
|
|
||||||
switch (method) {
|
|
||||||
/* eslint no-case-declarations:0 */
|
|
||||||
case 'delete':
|
|
||||||
tableListDataSource = tableListDataSource.filter(item => key.indexOf(item.key) === -1);
|
|
||||||
break;
|
|
||||||
case 'post':
|
|
||||||
const i = Math.ceil(Math.random() * 10000);
|
|
||||||
tableListDataSource.unshift({
|
|
||||||
key: i,
|
|
||||||
href: 'https://ant.design',
|
|
||||||
avatar: [
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
|
|
||||||
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
|
|
||||||
][i % 2],
|
|
||||||
name: `TradeCode ${i}`,
|
|
||||||
title: `一个任务名称 ${i}`,
|
|
||||||
owner: '曲丽丽',
|
|
||||||
desc,
|
|
||||||
callNo: Math.floor(Math.random() * 1000),
|
|
||||||
status: Math.floor(Math.random() * 10) % 2,
|
|
||||||
updatedAt: new Date(),
|
|
||||||
createdAt: new Date(),
|
|
||||||
progress: Math.ceil(Math.random() * 100),
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case 'update':
|
|
||||||
tableListDataSource = tableListDataSource.map(item => {
|
|
||||||
if (item.key === key) {
|
|
||||||
Object.assign(item, { desc, name });
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
return item;
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = {
|
|
||||||
list: tableListDataSource,
|
|
||||||
pagination: {
|
|
||||||
total: tableListDataSource.length,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
return res.json(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
'GET /api/rule': getRule,
|
|
||||||
'POST /api/rule': postRule,
|
|
||||||
};
|
|
|
@ -1,177 +0,0 @@
|
||||||
export default {
|
|
||||||
'GET /elasticsearch/:id/alias': function (req, res) {
|
|
||||||
res.send({
|
|
||||||
".kibana": {
|
|
||||||
"alias": ".kibana",
|
|
||||||
"indexes": [
|
|
||||||
{
|
|
||||||
"index": ".kibana_1",
|
|
||||||
"filter": null,
|
|
||||||
"index_routing": "",
|
|
||||||
"search_routing": "",
|
|
||||||
"is_hidden": false,
|
|
||||||
"is_write_index": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
".kibana-event-log-7.10.0": {
|
|
||||||
"alias": ".kibana-event-log-7.10.0",
|
|
||||||
"indexes": [
|
|
||||||
{
|
|
||||||
"index": ".kibana-event-log-7.10.0-000006",
|
|
||||||
"filter": null,
|
|
||||||
"index_routing": "",
|
|
||||||
"search_routing": "",
|
|
||||||
"is_hidden": false,
|
|
||||||
"is_write_index": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"index": ".kibana-event-log-7.10.0-000004",
|
|
||||||
"filter": null,
|
|
||||||
"index_routing": "",
|
|
||||||
"search_routing": "",
|
|
||||||
"is_hidden": false,
|
|
||||||
"is_write_index": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"index": ".kibana-event-log-7.10.0-000003",
|
|
||||||
"filter": null,
|
|
||||||
"index_routing": "",
|
|
||||||
"search_routing": "",
|
|
||||||
"is_hidden": false,
|
|
||||||
"is_write_index": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"index": ".kibana-event-log-7.10.0-000005",
|
|
||||||
"filter": null,
|
|
||||||
"index_routing": "",
|
|
||||||
"search_routing": "",
|
|
||||||
"is_hidden": false,
|
|
||||||
"is_write_index": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"write_index": ".kibana-event-log-7.10.0-000006"
|
|
||||||
},
|
|
||||||
".kibana_task_manager": {
|
|
||||||
"alias": ".kibana_task_manager",
|
|
||||||
"indexes": [
|
|
||||||
{
|
|
||||||
"index": ".kibana_task_manager_1",
|
|
||||||
"filter": null,
|
|
||||||
"index_routing": "",
|
|
||||||
"search_routing": "",
|
|
||||||
"is_hidden": false,
|
|
||||||
"is_write_index": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"custom": {
|
|
||||||
"alias": "custom",
|
|
||||||
"indexes": [
|
|
||||||
{
|
|
||||||
"index": "test-custom",
|
|
||||||
"filter": {
|
|
||||||
"match": {
|
|
||||||
"name": "test"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"index_routing": "1",
|
|
||||||
"search_routing": "1",
|
|
||||||
"is_hidden": false,
|
|
||||||
"is_write_index": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"index": "test-custom8",
|
|
||||||
"filter": {
|
|
||||||
"match": {
|
|
||||||
"name": "test"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"index_routing": "1",
|
|
||||||
"search_routing": "1",
|
|
||||||
"is_hidden": false,
|
|
||||||
"is_write_index": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ilm-history-3": {
|
|
||||||
"alias": "ilm-history-3",
|
|
||||||
"indexes": [
|
|
||||||
{
|
|
||||||
"index": "ilm-history-3-000004",
|
|
||||||
"filter": null,
|
|
||||||
"index_routing": "",
|
|
||||||
"search_routing": "",
|
|
||||||
"is_hidden": true,
|
|
||||||
"is_write_index": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"index": "ilm-history-3-000006",
|
|
||||||
"filter": null,
|
|
||||||
"index_routing": "",
|
|
||||||
"search_routing": "",
|
|
||||||
"is_hidden": true,
|
|
||||||
"is_write_index": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"index": "ilm-history-3-000003",
|
|
||||||
"filter": null,
|
|
||||||
"index_routing": "",
|
|
||||||
"search_routing": "",
|
|
||||||
"is_hidden": true,
|
|
||||||
"is_write_index": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"index": "ilm-history-3-000005",
|
|
||||||
"filter": null,
|
|
||||||
"index_routing": "",
|
|
||||||
"search_routing": "",
|
|
||||||
"is_hidden": true,
|
|
||||||
"is_write_index": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"write_index": "ilm-history-3-000006"
|
|
||||||
},
|
|
||||||
"metricbeat-7.10.0": {
|
|
||||||
"alias": "metricbeat-7.10.0",
|
|
||||||
"indexes": [
|
|
||||||
{
|
|
||||||
"index": "metricbeat-7.10.0-2021.04.07-000003",
|
|
||||||
"filter": null,
|
|
||||||
"index_routing": "",
|
|
||||||
"search_routing": "",
|
|
||||||
"is_hidden": false,
|
|
||||||
"is_write_index": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"index": "metricbeat-7.10.0-2021.02.03-000001",
|
|
||||||
"filter": null,
|
|
||||||
"index_routing": "",
|
|
||||||
"search_routing": "",
|
|
||||||
"is_hidden": false,
|
|
||||||
"is_write_index": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"index": "metricbeat-7.10.0-2021.03.06-000002",
|
|
||||||
"filter": null,
|
|
||||||
"index_routing": "",
|
|
||||||
"search_routing": "",
|
|
||||||
"is_hidden": false,
|
|
||||||
"is_write_index": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"write_index": "metricbeat-7.10.0-2021.04.07-000003"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
'POST /elasticsearch/:id/alias': function (req, res) {
|
|
||||||
//curl add example
|
|
||||||
// curl -X POST -d '{ "actions" : [{ "add": { "index" : "test-custom", "alias" : "custom" } }]}'
|
|
||||||
//curl delete example
|
|
||||||
// curl -X POST -d '{ "actions" : [{ "remove": { "index" : "test-custom", "alias" : "custom" } }]}'
|
|
||||||
|
|
||||||
res.send({
|
|
||||||
"acknowledged": true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,108 +0,0 @@
|
||||||
export default {
|
|
||||||
'GET /elasticsearch/:id/search_template/_search': function(req, res){
|
|
||||||
res.send({
|
|
||||||
"took": 0,
|
|
||||||
"timed_out": false,
|
|
||||||
"hits": {
|
|
||||||
"total": {
|
|
||||||
"relation": "eq",
|
|
||||||
"value": 1
|
|
||||||
},
|
|
||||||
"max_score": 0.2876821,
|
|
||||||
"hits": [
|
|
||||||
{
|
|
||||||
"_index": ".infini-search-center_searchtemplate",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "c1nc0dkagrh0jobkn6s0",
|
|
||||||
"_source": {
|
|
||||||
"created": "2021-04-08T15:54:06.675249+08:00",
|
|
||||||
"name": "test_search_template",
|
|
||||||
"source": "{\"query\":{\"match\":{\"{{my_field}}\":\"{{my_value}}\"}},\"size\":\"{{my_size}}\"}",
|
|
||||||
"updated": "2021-04-08T15:54:06.675249+08:00"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
'PUT /elasticsearch/:id/search_template/:template_id': function(req, res){
|
|
||||||
res.send({
|
|
||||||
"_id": "c1nc0dkagrh0jobkn6s0",
|
|
||||||
"_source": {
|
|
||||||
"cluster_id": "c0octmtath23m973pf4g",
|
|
||||||
"created": "2021-04-08T16:35:02.746223+08:00",
|
|
||||||
"name": "test_search_template1",
|
|
||||||
"source": "{\"query\":{\"match\":{\"{{my_field}}\":\"{{my_value}}\"}},\"size\":\"{{my_size}}\"}",
|
|
||||||
"updated": "2021-04-08T22:03:25.987193+08:00"
|
|
||||||
},
|
|
||||||
"result": "updated"
|
|
||||||
})
|
|
||||||
},
|
|
||||||
'POST /elasticsearch/:id/search_template': function(req, res){
|
|
||||||
res.send({
|
|
||||||
"_id": "c1nc0dkagrh0jobkn6s0",
|
|
||||||
"_source": {
|
|
||||||
"name": "test_search_template_new",
|
|
||||||
"source": "{\"query\":{\"match\":{\"{{my_field}}\":\"{{my_value}}\"}},\"size\":\"{{my_size}}\"}",
|
|
||||||
"cluster_id": "c0octmtath23m973pf4g",
|
|
||||||
"created": "2021-04-08T16:35:02.746223+08:00",
|
|
||||||
"updated": "2021-04-08T16:35:02.746223+08:00"
|
|
||||||
},
|
|
||||||
"result": "created"
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'GET /elasticsearch/:id/search_template/_get/:template_id': function(req, res){
|
|
||||||
res.send({
|
|
||||||
"found": true,
|
|
||||||
"_index": ".infini-search-center_searchtemplate",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "c1nc0dkagrh0jobkn6s0",
|
|
||||||
"_version": 1,
|
|
||||||
"_source": {
|
|
||||||
"cluster_id": "c0octmtath23m973pf4g",
|
|
||||||
"created": "2021-04-08T16:35:02.746223+08:00",
|
|
||||||
"name": "test_search_template",
|
|
||||||
"source": "{\"query\":{\"match\":{\"{{my_field}}\":\"{{my_value}}\"}},\"size\":\"{{my_size}}\"}",
|
|
||||||
"updated": "2021-04-08T16:35:02.746223+08:00"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'DELETE /elasticsearch/:id/search_template/:template_id': function(req, res){
|
|
||||||
res.send({
|
|
||||||
"_id": "c1nc0dkagrh0jobkn6s0",
|
|
||||||
"result": "deleted"
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'GET /elasticsearch/:id/search_template_history/_search': function(req, res){
|
|
||||||
res.send({
|
|
||||||
"took": 0,
|
|
||||||
"timed_out": false,
|
|
||||||
"hits": {
|
|
||||||
"total": {
|
|
||||||
"relation": "eq",
|
|
||||||
"value": 1
|
|
||||||
},
|
|
||||||
"max_score": 0.5753642,
|
|
||||||
"hits": [
|
|
||||||
{
|
|
||||||
"_index": ".infini-search-center_searchtemplatehistory",
|
|
||||||
"_type": "_doc",
|
|
||||||
"_id": "c1o5k3kagrh1tfml0qfg",
|
|
||||||
"_source": {
|
|
||||||
"action": "update",
|
|
||||||
"content": {
|
|
||||||
"cluster_id": "c0octmtath23m973pf4g",
|
|
||||||
"created": "2021-04-08T16:35:02.746223+08:00",
|
|
||||||
"name": "test_search_template",
|
|
||||||
"source": "{\"query\":{\"match\":{\"{{my_field}}\":\"{{my_value}}\"}},\"size\":\"{{my_size}}\"}",
|
|
||||||
"updated": "2021-04-08T22:03:25.987193+08:00"
|
|
||||||
},
|
|
||||||
"created": "2021-04-09T21:43:42.611027+08:00",
|
|
||||||
"template_id": "c1nc0dkagrh0jobkn6s0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
137
web/mock/user.js
|
@ -1,137 +0,0 @@
|
||||||
// 代码中会兼容本地 service mock 以及部署站点的静态数据
|
|
||||||
export default {
|
|
||||||
// 支持值为 Object 和 Array
|
|
||||||
'GET /api/currentUser': {
|
|
||||||
name: 'Serati Ma',
|
|
||||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png',
|
|
||||||
userid: '00000001',
|
|
||||||
email: 'antdesign@alipay.com',
|
|
||||||
signature: '海纳百川,有容乃大',
|
|
||||||
title: '交互专家',
|
|
||||||
group: '蚂蚁金服-某某某事业群-某某平台部-某某技术部-UED',
|
|
||||||
tags: [
|
|
||||||
{
|
|
||||||
key: '0',
|
|
||||||
label: '很有想法的',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: '1',
|
|
||||||
label: '专注设计',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: '2',
|
|
||||||
label: '辣~',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: '3',
|
|
||||||
label: '大长腿',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: '4',
|
|
||||||
label: '川妹子',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: '5',
|
|
||||||
label: '海纳百川',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
notifyCount: 12,
|
|
||||||
country: 'China',
|
|
||||||
geographic: {
|
|
||||||
province: {
|
|
||||||
label: '浙江省',
|
|
||||||
key: '330000',
|
|
||||||
},
|
|
||||||
city: {
|
|
||||||
label: '杭州市',
|
|
||||||
key: '330100',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
address: '西湖区工专路 77 号',
|
|
||||||
phone: '0752-268888888',
|
|
||||||
},
|
|
||||||
// GET POST 可省略
|
|
||||||
'GET /api/users': [
|
|
||||||
{
|
|
||||||
key: '1',
|
|
||||||
name: 'John Brown',
|
|
||||||
age: 32,
|
|
||||||
address: 'New York No. 1 Lake Park',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: '2',
|
|
||||||
name: 'Jim Green',
|
|
||||||
age: 42,
|
|
||||||
address: 'London No. 1 Lake Park',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: '3',
|
|
||||||
name: 'Joe Black',
|
|
||||||
age: 32,
|
|
||||||
address: 'Sidney No. 1 Lake Park',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
'POST /api/login/account': (req, res) => {
|
|
||||||
const { password, userName, type } = req.body;
|
|
||||||
if (password === '888888' && userName === 'admin') {
|
|
||||||
res.send({
|
|
||||||
status: 'ok',
|
|
||||||
type,
|
|
||||||
currentAuthority: 'admin',
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (password === '123456' && userName === 'user') {
|
|
||||||
res.send({
|
|
||||||
status: 'ok',
|
|
||||||
type,
|
|
||||||
currentAuthority: 'user',
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
res.send({
|
|
||||||
status: 'error',
|
|
||||||
type,
|
|
||||||
currentAuthority: 'guest',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'POST /api/register': (req, res) => {
|
|
||||||
res.send({ status: 'ok', currentAuthority: 'user' });
|
|
||||||
},
|
|
||||||
'GET /api/500': (req, res) => {
|
|
||||||
res.status(500).send({
|
|
||||||
timestamp: 1513932555104,
|
|
||||||
status: 500,
|
|
||||||
error: 'error',
|
|
||||||
message: 'error',
|
|
||||||
path: '/base/category/list',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'GET /api/404': (req, res) => {
|
|
||||||
res.status(404).send({
|
|
||||||
timestamp: 1513932643431,
|
|
||||||
status: 404,
|
|
||||||
error: 'Not Found',
|
|
||||||
message: 'No message available',
|
|
||||||
path: '/base/category/list/2121212',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'GET /api/403': (req, res) => {
|
|
||||||
res.status(403).send({
|
|
||||||
timestamp: 1513932555104,
|
|
||||||
status: 403,
|
|
||||||
error: 'Unauthorized',
|
|
||||||
message: 'Unauthorized',
|
|
||||||
path: '/base/category/list',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'GET /api/401': (req, res) => {
|
|
||||||
res.status(401).send({
|
|
||||||
timestamp: 1513932555104,
|
|
||||||
status: 401,
|
|
||||||
error: 'Unauthorized',
|
|
||||||
message: 'Unauthorized',
|
|
||||||
path: '/base/category/list',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
};
|
|
145
web/package.json
|
@ -1,145 +0,0 @@
|
||||||
{
|
|
||||||
"name": "search-center",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "极限搜索,致力于简单易用。",
|
|
||||||
"dependencies": {
|
|
||||||
"@ant-design/charts": "^1.0.4",
|
|
||||||
"@ant-design/icons": "^4.0.0",
|
|
||||||
"@antv/data-set": "^0.9.6",
|
|
||||||
"@antv/g2-brush": "^0.0.2",
|
|
||||||
"@babel/runtime": "^7.1.2",
|
|
||||||
"@elastic/charts": "^25.0.1",
|
|
||||||
"@elastic/datemath": "^5.0.3",
|
|
||||||
"@elastic/eui": "34.4.0",
|
|
||||||
"@elastic/numeral": "^2.5.1",
|
|
||||||
"@hapi/boom": "^9.1.3",
|
|
||||||
"@monaco-editor/react": "^4.2.2",
|
|
||||||
"@svgdotjs/svg.js": "^3.0.16",
|
|
||||||
"antd": "^3.26.18",
|
|
||||||
"antd-table-infinity": "^1.1.6",
|
|
||||||
"bizcharts": "^3.2.2",
|
|
||||||
"bizcharts-plugin-slider": "^2.0.3",
|
|
||||||
"brace": "^0.11.1",
|
|
||||||
"classnames": "^2.2.6",
|
|
||||||
"cluster": "^0.7.7",
|
|
||||||
"console": "^0.7.2",
|
|
||||||
"deep-freeze-strict": "^1.1.1",
|
|
||||||
"dns": "^0.2.2",
|
|
||||||
"dva": "^2.4.0",
|
|
||||||
"enquire-js": "^0.2.1",
|
|
||||||
"formik": "^2.2.9",
|
|
||||||
"fp-ts": "^2.10.5",
|
|
||||||
"hash.js": "^1.1.5",
|
|
||||||
"honeycomb-grid": "^3.1.7",
|
|
||||||
"jquery": "^3.6.0",
|
|
||||||
"lodash": "^4.17.10",
|
|
||||||
"lodash-decorators": "^6.0.0",
|
|
||||||
"luxon": "^1.26.0",
|
|
||||||
"memoize-one": "^4.0.0",
|
|
||||||
"module": "^1.2.5",
|
|
||||||
"moment": "^2.29.1",
|
|
||||||
"moment-timezone": "^0.5.32",
|
|
||||||
"nano-css": "^5.3.1",
|
|
||||||
"node-ssh": "^8.0.0",
|
|
||||||
"numeral": "^2.0.6",
|
|
||||||
"nzh": "^1.0.3",
|
|
||||||
"omit.js": "^1.0.0",
|
|
||||||
"path-to-regexp": "^2.4.0",
|
|
||||||
"prop-types": "^15.5.10",
|
|
||||||
"qs": "^6.5.2",
|
|
||||||
"raw-loader": "^4.0.2",
|
|
||||||
"rc-animate": "^2.4.4",
|
|
||||||
"re-resizable": "^6.9.1",
|
|
||||||
"react": "^16.5.1",
|
|
||||||
"react-calendar-heatmap": "^1.8.1",
|
|
||||||
"react-container-query": "^0.11.0",
|
|
||||||
"react-copy-to-clipboard": "^5.0.1",
|
|
||||||
"react-dnd": "^14.0.4",
|
|
||||||
"react-dnd-html5-backend": "^14.0.2",
|
|
||||||
"react-document-title": "^2.0.3",
|
|
||||||
"react-dom": "^16.5.1",
|
|
||||||
"react-fittext": "^1.0.0",
|
|
||||||
"react-ga": "^3.3.0",
|
|
||||||
"react-grid-layout": "^1.2.0",
|
|
||||||
"react-highlight-words": "^0.16.0",
|
|
||||||
"react-infinite-scroll-component": "^6.1.0",
|
|
||||||
"react-infinite-scroller": "^1.2.4",
|
|
||||||
"react-json-prettify": "^0.2.0",
|
|
||||||
"react-json-view": "^1.19.1",
|
|
||||||
"react-router-dom": "^4.3.1",
|
|
||||||
"react-use": "^17.2.4",
|
|
||||||
"react-vis": "^1.11.7",
|
|
||||||
"readline": "^1.3.0",
|
|
||||||
"repl": "^0.1.3",
|
|
||||||
"reqwest": "^2.0.5",
|
|
||||||
"rison-node": "^2.1.1",
|
|
||||||
"rxjs": "^7.2.0",
|
|
||||||
"sass-loader": "^8.0.2",
|
|
||||||
"use-query-params": "^1.2.3",
|
|
||||||
"uuid-v4": "^0.1.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"antd-pro-merge-less": "^0.1.0",
|
|
||||||
"antd-theme-webpack-plugin": "^1.1.8",
|
|
||||||
"autod": "^3.0.1",
|
|
||||||
"autod-egg": "^1.1.0",
|
|
||||||
"babel-eslint": "^8.1.2",
|
|
||||||
"babel-plugin-dva-hmr": "^0.4.1",
|
|
||||||
"babel-plugin-import": "^1.6.3",
|
|
||||||
"babel-plugin-transform-decorators-legacy": "^1.3.4",
|
|
||||||
"cross-env": "^7.0.3",
|
|
||||||
"egg": "^2.4.1",
|
|
||||||
"egg-bin": "^4.3.7",
|
|
||||||
"egg-ci": "^1.8.0",
|
|
||||||
"egg-mock": "^3.15.0",
|
|
||||||
"egg-scripts": "^2.5.1",
|
|
||||||
"egg-validate": "^2.0.2",
|
|
||||||
"egg-view-assets": "^1.6.1",
|
|
||||||
"egg-view-nunjucks": "^2.2.0",
|
|
||||||
"enzyme": "^3.9.0",
|
|
||||||
"eslint": "^4.18.2",
|
|
||||||
"eslint-config-airbnb": "^17.0.0",
|
|
||||||
"eslint-config-egg": "^7.0.0",
|
|
||||||
"eslint-config-prettier": "^6.0.0",
|
|
||||||
"eslint-plugin-babel": "^5.1.0",
|
|
||||||
"eslint-plugin-compat": "^2.6.2",
|
|
||||||
"eslint-plugin-import": "^2.8.0",
|
|
||||||
"eslint-plugin-jsx-a11y": "^6.1.2",
|
|
||||||
"eslint-plugin-markdown": "^1.0.0-beta.6",
|
|
||||||
"eslint-plugin-react": "^7.11.1",
|
|
||||||
"mockjs": "^1.0.1-beta3",
|
|
||||||
"moment-duration-format": "^2.3.2",
|
|
||||||
"node-fetch": "^2.6.1",
|
|
||||||
"raw-loader": "^4.0.2",
|
|
||||||
"redbox-react": "^1.5.0",
|
|
||||||
"sass": "^1.35.1",
|
|
||||||
"sass-loader": "^10.1.1",
|
|
||||||
"ts-loader": "^8.0.2",
|
|
||||||
"umi": "^2.1.2",
|
|
||||||
"umi-plugin-ga": "^1.1.3",
|
|
||||||
"umi-plugin-react": "^1.1.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8.9.0"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"dev": "umi dev",
|
|
||||||
"build": "NODE_OPTIONS=--max_old_space_size=4096 umi build",
|
|
||||||
"autod": "autod",
|
|
||||||
"docker:dev": "docker-compose -f ./docker/docker-compose.dev.yml up --remove-orphans -d",
|
|
||||||
"docker:stop-dev": "docker-compose -f ./docker/docker-compose.dev.yml down",
|
|
||||||
"docker:build": "docker-compose -f ./docker/docker-compose.build.yml up --remove-orphans",
|
|
||||||
"docker:start-mysql": "docker-compose -f ./docker/docker-compose-mysql.dev.yml up --remove-orphans -d",
|
|
||||||
"postinstall": "rm -rf ./node_modules/_ts-loader@6.0.3@ts-loader"
|
|
||||||
},
|
|
||||||
"ci": {
|
|
||||||
"version": "8",
|
|
||||||
"license": true
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "ssh://git@git.infini.ltd:64221/infini/search-center.git"
|
|
||||||
},
|
|
||||||
"author": "INFINI.LTD",
|
|
||||||
"license": "INFINI-EULA"
|
|
||||||
}
|
|
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 1.5 KiB |
|
@ -1 +0,0 @@
|
||||||
<svg width="2500" height="2500" viewBox="0 0 256 256" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin meet"><path d="M255.96 134.393c0-21.521-13.373-40.117-33.223-47.43a75.239 75.239 0 0 0 1.253-13.791c0-39.909-32.386-72.295-72.295-72.295-23.193 0-44.923 11.074-58.505 30.088-6.686-5.224-14.835-7.94-23.402-7.94-21.104 0-38.446 17.133-38.446 38.446 0 4.597.836 9.194 2.298 13.373C13.582 81.739 0 100.962 0 122.274c0 21.522 13.373 40.327 33.431 47.64-.835 4.388-1.253 8.985-1.253 13.79 0 39.7 32.386 72.087 72.086 72.087 23.402 0 44.924-11.283 58.505-30.088 6.686 5.223 15.044 8.149 23.611 8.149 21.104 0 38.446-17.134 38.446-38.446 0-4.597-.836-9.194-2.298-13.373 19.64-7.104 33.431-26.327 33.431-47.64z" fill="#FFF"/><path d="M100.085 110.364l57.043 26.119 57.669-50.565a64.312 64.312 0 0 0 1.253-12.746c0-35.52-28.834-64.355-64.355-64.355-21.313 0-41.162 10.447-53.072 27.998l-9.612 49.73 11.074 23.82z" fill="#F4BD19"/><path d="M40.953 170.75c-.835 4.179-1.253 8.567-1.253 12.955 0 35.52 29.043 64.564 64.564 64.564 21.522 0 41.372-10.656 53.49-28.208l9.403-49.729-12.746-24.238-57.251-26.118-56.207 50.774z" fill="#3CBEB1"/><path d="M40.536 71.918l39.073 9.194 8.775-44.506c-5.432-4.179-11.91-6.268-18.805-6.268-16.925 0-30.924 13.79-30.924 30.924 0 3.552.627 7.313 1.88 10.656z" fill="#E9478C"/><path d="M37.192 81.32c-17.551 5.642-29.67 22.567-29.67 40.954 0 17.97 11.074 34.059 27.79 40.327l54.953-49.73-10.03-21.52-43.043-10.03z" fill="#2C458F"/><path d="M167.784 219.852c5.432 4.18 11.91 6.478 18.596 6.478 16.925 0 30.924-13.79 30.924-30.924 0-3.761-.627-7.314-1.88-10.657l-39.073-9.193-8.567 44.296z" fill="#95C63D"/><path d="M175.724 165.317l43.043 10.03c17.551-5.85 29.67-22.566 29.67-40.954 0-17.97-11.074-33.849-27.79-40.326l-56.415 49.311 11.492 21.94z" fill="#176655"/></svg>
|
|
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 112 KiB |
Before Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 8.0 KiB |
Before Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 50 KiB |
|
@ -1,26 +0,0 @@
|
||||||
.fullscreen{
|
|
||||||
position: fixed;
|
|
||||||
width: 100%;
|
|
||||||
left: 0;
|
|
||||||
top: 0;
|
|
||||||
height: 100vh;
|
|
||||||
z-index: 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes slideInUp {
|
|
||||||
from {
|
|
||||||
transform: translate3d(0, 100%, 0);
|
|
||||||
visibility: visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
to {
|
|
||||||
transform: translate3d(0, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.slideInUp {
|
|
||||||
animation-name: slideInUp;
|
|
||||||
animation-duration: .2s;
|
|
||||||
animation-fill-mode: both;
|
|
||||||
animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2);
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
<svg width="24px" height="24px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M21,2H3A1,1,0,0,0,2,3V21a1,1,0,0,0,1,1H21a1,1,0,0,0,1-1V3A1,1,0,0,0,21,2ZM20,20H4V10H20ZM20,8H4V4H20Z"/></svg>
|
|
Before Width: | Height: | Size: 206 B |
|
@ -1,4 +0,0 @@
|
||||||
<svg width="512px" height="512px" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<path fill="var(--ci-primary-color, currentColor)" d="M352,153H40.247a24.028,24.028,0,0,0-24,24V458a24.028,24.028,0,0,0,24,24H352a24.028,24.028,0,0,0,24-24V177A24.028,24.028,0,0,0,352,153Zm-8,32v45.22H48.247V185ZM48.247,450V262.22H344V450Z" class="ci-primary"/>
|
|
||||||
<path fill="var(--ci-primary-color, currentColor)" d="M472,32H152a24.028,24.028,0,0,0-24,24v65h32V64H464V339.143H408v32h64a24.028,24.028,0,0,0,24-24V56A24.028,24.028,0,0,0,472,32Z" class="ci-primary"/>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 567 B |
|
@ -1,93 +0,0 @@
|
||||||
import React, { Component } from 'react';
|
|
||||||
import { MiniArea } from '../Charts';
|
|
||||||
import NumberInfo from '../NumberInfo';
|
|
||||||
|
|
||||||
import styles from './index.less';
|
|
||||||
|
|
||||||
function fixedZero(val) {
|
|
||||||
return val * 1 < 10 ? `0${val}` : val;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getActiveData() {
|
|
||||||
const activeData = [];
|
|
||||||
for (let i = 0; i < 24; i += 1) {
|
|
||||||
activeData.push({
|
|
||||||
x: `${fixedZero(i)}:00`,
|
|
||||||
y: Math.floor(Math.random() * 200) + i * 50,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return activeData;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class ActiveChart extends Component {
|
|
||||||
state = {
|
|
||||||
activeData: getActiveData(),
|
|
||||||
};
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
this.loopData();
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
clearTimeout(this.timer);
|
|
||||||
cancelAnimationFrame(this.requestRef);
|
|
||||||
}
|
|
||||||
|
|
||||||
loopData = () => {
|
|
||||||
this.requestRef = requestAnimationFrame(() => {
|
|
||||||
this.timer = setTimeout(() => {
|
|
||||||
this.setState(
|
|
||||||
{
|
|
||||||
activeData: getActiveData(),
|
|
||||||
},
|
|
||||||
() => {
|
|
||||||
this.loopData();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}, 1000);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const { activeData = [] } = this.state;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={styles.activeChart}>
|
|
||||||
<NumberInfo subTitle="目标评估" total="有望达到预期" />
|
|
||||||
<div style={{ marginTop: 32 }}>
|
|
||||||
<MiniArea
|
|
||||||
animate={false}
|
|
||||||
line
|
|
||||||
borderWidth={2}
|
|
||||||
height={84}
|
|
||||||
scale={{
|
|
||||||
y: {
|
|
||||||
tickCount: 3,
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
yAxis={{
|
|
||||||
tickLine: false,
|
|
||||||
label: false,
|
|
||||||
title: false,
|
|
||||||
line: false,
|
|
||||||
}}
|
|
||||||
data={activeData}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{activeData && (
|
|
||||||
<div className={styles.activeChartGrid}>
|
|
||||||
<p>{[...activeData].sort()[activeData.length - 1].y + 200} 亿元</p>
|
|
||||||
<p>{[...activeData].sort()[Math.floor(activeData.length / 2)].y} 亿元</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{activeData && (
|
|
||||||
<div className={styles.activeChartLegend}>
|
|
||||||
<span>00:00</span>
|
|
||||||
<span>{activeData[Math.floor(activeData.length / 2)].x}</span>
|
|
||||||
<span>{activeData[activeData.length - 1].x}</span>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
.activeChart {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.activeChartGrid {
|
|
||||||
p {
|
|
||||||
position: absolute;
|
|
||||||
top: 80px;
|
|
||||||
}
|
|
||||||
p:last-child {
|
|
||||||
top: 115px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.activeChartLegend {
|
|
||||||
position: relative;
|
|
||||||
font-size: 0;
|
|
||||||
margin-top: 8px;
|
|
||||||
height: 20px;
|
|
||||||
line-height: 20px;
|
|
||||||
span {
|
|
||||||
display: inline-block;
|
|
||||||
font-size: 12px;
|
|
||||||
text-align: center;
|
|
||||||
width: 33.33%;
|
|
||||||
}
|
|
||||||
span:first-child {
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
span:last-child {
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import moment from 'moment';
|
|
||||||
import { Avatar } from 'antd';
|
|
||||||
import styles from './index.less';
|
|
||||||
|
|
||||||
const ArticleListContent = ({ data: { content, updatedAt, avatar, owner, href } }) => (
|
|
||||||
<div className={styles.listContent}>
|
|
||||||
<div className={styles.description}>{content}</div>
|
|
||||||
<div className={styles.extra}>
|
|
||||||
<Avatar src={avatar} size="small" />
|
|
||||||
<a href={href}>{owner}</a> 发布在 <a href={href}>{href}</a>
|
|
||||||
<em>{moment(updatedAt).format('YYYY-MM-DD HH:mm')}</em>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
export default ArticleListContent;
|
|
|
@ -1,38 +0,0 @@
|
||||||
@import '~antd/lib/style/themes/default.less';
|
|
||||||
|
|
||||||
.listContent {
|
|
||||||
.description {
|
|
||||||
line-height: 22px;
|
|
||||||
max-width: 720px;
|
|
||||||
}
|
|
||||||
.extra {
|
|
||||||
color: @text-color-secondary;
|
|
||||||
margin-top: 16px;
|
|
||||||
line-height: 22px;
|
|
||||||
& > :global(.ant-avatar) {
|
|
||||||
vertical-align: top;
|
|
||||||
margin-right: 8px;
|
|
||||||
width: 20px;
|
|
||||||
height: 20px;
|
|
||||||
position: relative;
|
|
||||||
top: 1px;
|
|
||||||
}
|
|
||||||
& > em {
|
|
||||||
color: @disabled-color;
|
|
||||||
font-style: normal;
|
|
||||||
margin-left: 16px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (max-width: @screen-xs) {
|
|
||||||
.listContent {
|
|
||||||
.extra {
|
|
||||||
& > em {
|
|
||||||
display: block;
|
|
||||||
margin-left: 0;
|
|
||||||
margin-top: 8px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
import CheckPermissions from './CheckPermissions';
|
|
||||||
|
|
||||||
const Authorized = ({ children, authority, noMatch = null }) => {
|
|
||||||
const childrenRender = typeof children === 'undefined' ? null : children;
|
|
||||||
return CheckPermissions(authority, childrenRender, noMatch);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Authorized;
|
|
|
@ -1,15 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import { Route, Redirect } from 'react-router-dom';
|
|
||||||
import Authorized from './Authorized';
|
|
||||||
|
|
||||||
// TODO: umi只会返回render和rest
|
|
||||||
const AuthorizedRoute = ({ component: Component, render, authority, redirectPath, ...rest }) => (
|
|
||||||
<Authorized
|
|
||||||
authority={authority}
|
|
||||||
noMatch={<Route {...rest} render={() => <Redirect to={{ pathname: redirectPath }} />} />}
|
|
||||||
>
|
|
||||||
<Route {...rest} render={props => (Component ? <Component {...props} /> : render(props))} />
|
|
||||||
</Authorized>
|
|
||||||
);
|
|
||||||
|
|
||||||
export default AuthorizedRoute;
|
|
|
@ -1,88 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import PromiseRender from './PromiseRender';
|
|
||||||
import { CURRENT } from './renderAuthorize';
|
|
||||||
|
|
||||||
function isPromise(obj) {
|
|
||||||
return (
|
|
||||||
!!obj &&
|
|
||||||
(typeof obj === 'object' || typeof obj === 'function') &&
|
|
||||||
typeof obj.then === 'function'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通用权限检查方法
|
|
||||||
* Common check permissions method
|
|
||||||
* @param { 权限判定 Permission judgment type string |array | Promise | Function } authority
|
|
||||||
* @param { 你的权限 Your permission description type:string} currentAuthority
|
|
||||||
* @param { 通过的组件 Passing components } target
|
|
||||||
* @param { 未通过的组件 no pass components } Exception
|
|
||||||
*/
|
|
||||||
const checkPermissions = (authority, currentAuthority, target, Exception) => {
|
|
||||||
// 没有判定权限.默认查看所有
|
|
||||||
// Retirement authority, return target;
|
|
||||||
if (!authority) {
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
// 数组处理
|
|
||||||
if (Array.isArray(authority)) {
|
|
||||||
if (authority.indexOf(currentAuthority) >= 0) {
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
if (Array.isArray(currentAuthority)) {
|
|
||||||
for (let i = 0; i < currentAuthority.length; i += 1) {
|
|
||||||
const element = currentAuthority[i];
|
|
||||||
if (authority.indexOf(element) >= 0) {
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
// string 处理
|
|
||||||
if (typeof authority === 'string') {
|
|
||||||
if (authority === currentAuthority) {
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
if (Array.isArray(currentAuthority)) {
|
|
||||||
for (let i = 0; i < currentAuthority.length; i += 1) {
|
|
||||||
const element = currentAuthority[i];
|
|
||||||
if (authority === element) {
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Promise 处理
|
|
||||||
if (isPromise(authority)) {
|
|
||||||
return <PromiseRender ok={target} error={Exception} promise={authority} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function 处理
|
|
||||||
if (typeof authority === 'function') {
|
|
||||||
try {
|
|
||||||
const bool = authority(currentAuthority);
|
|
||||||
// 函数执行后返回值是 Promise
|
|
||||||
if (isPromise(bool)) {
|
|
||||||
return <PromiseRender ok={target} error={Exception} promise={bool} />;
|
|
||||||
}
|
|
||||||
if (bool) {
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
return Exception;
|
|
||||||
} catch (error) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new Error('unsupported parameters');
|
|
||||||
};
|
|
||||||
|
|
||||||
export { checkPermissions };
|
|
||||||
|
|
||||||
const check = (authority, target, Exception) =>
|
|
||||||
checkPermissions(authority, CURRENT, target, Exception);
|
|
||||||
|
|
||||||
export default check;
|
|
|
@ -1,55 +0,0 @@
|
||||||
import { checkPermissions } from './CheckPermissions';
|
|
||||||
|
|
||||||
const target = 'ok';
|
|
||||||
const error = 'error';
|
|
||||||
|
|
||||||
describe('test CheckPermissions', () => {
|
|
||||||
it('Correct string permission authentication', () => {
|
|
||||||
expect(checkPermissions('user', 'user', target, error)).toEqual('ok');
|
|
||||||
});
|
|
||||||
it('Correct string permission authentication', () => {
|
|
||||||
expect(checkPermissions('user', 'NULL', target, error)).toEqual('error');
|
|
||||||
});
|
|
||||||
it('authority is undefined , return ok', () => {
|
|
||||||
expect(checkPermissions(null, 'NULL', target, error)).toEqual('ok');
|
|
||||||
});
|
|
||||||
it('currentAuthority is undefined , return error', () => {
|
|
||||||
expect(checkPermissions('admin', null, target, error)).toEqual('error');
|
|
||||||
});
|
|
||||||
it('Wrong string permission authentication', () => {
|
|
||||||
expect(checkPermissions('admin', 'user', target, error)).toEqual('error');
|
|
||||||
});
|
|
||||||
it('Correct Array permission authentication', () => {
|
|
||||||
expect(checkPermissions(['user', 'admin'], 'user', target, error)).toEqual('ok');
|
|
||||||
});
|
|
||||||
it('Wrong Array permission authentication,currentAuthority error', () => {
|
|
||||||
expect(checkPermissions(['user', 'admin'], 'user,admin', target, error)).toEqual('error');
|
|
||||||
});
|
|
||||||
it('Wrong Array permission authentication', () => {
|
|
||||||
expect(checkPermissions(['user', 'admin'], 'guest', target, error)).toEqual('error');
|
|
||||||
});
|
|
||||||
it('Wrong Function permission authentication', () => {
|
|
||||||
expect(checkPermissions(() => false, 'guest', target, error)).toEqual('error');
|
|
||||||
});
|
|
||||||
it('Correct Function permission authentication', () => {
|
|
||||||
expect(checkPermissions(() => true, 'guest', target, error)).toEqual('ok');
|
|
||||||
});
|
|
||||||
it('authority is string, currentAuthority is array, return ok', () => {
|
|
||||||
expect(checkPermissions('user', ['user'], target, error)).toEqual('ok');
|
|
||||||
});
|
|
||||||
it('authority is string, currentAuthority is array, return ok', () => {
|
|
||||||
expect(checkPermissions('user', ['user', 'admin'], target, error)).toEqual('ok');
|
|
||||||
});
|
|
||||||
it('authority is array, currentAuthority is array, return ok', () => {
|
|
||||||
expect(checkPermissions(['user', 'admin'], ['user', 'admin'], target, error)).toEqual('ok');
|
|
||||||
});
|
|
||||||
it('Wrong Function permission authentication', () => {
|
|
||||||
expect(checkPermissions(() => false, ['user'], target, error)).toEqual('error');
|
|
||||||
});
|
|
||||||
it('Correct Function permission authentication', () => {
|
|
||||||
expect(checkPermissions(() => true, ['user'], target, error)).toEqual('ok');
|
|
||||||
});
|
|
||||||
it('authority is undefined , return ok', () => {
|
|
||||||
expect(checkPermissions(null, ['user'], target, error)).toEqual('ok');
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,65 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import { Spin } from 'antd';
|
|
||||||
|
|
||||||
export default class PromiseRender extends React.PureComponent {
|
|
||||||
state = {
|
|
||||||
component: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
this.setRenderComponent(this.props);
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidUpdate(nextProps) {
|
|
||||||
// new Props enter
|
|
||||||
this.setRenderComponent(nextProps);
|
|
||||||
}
|
|
||||||
|
|
||||||
// set render Component : ok or error
|
|
||||||
setRenderComponent(props) {
|
|
||||||
const ok = this.checkIsInstantiation(props.ok);
|
|
||||||
const error = this.checkIsInstantiation(props.error);
|
|
||||||
props.promise
|
|
||||||
.then(() => {
|
|
||||||
this.setState({
|
|
||||||
component: ok,
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
this.setState({
|
|
||||||
component: error,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine whether the incoming component has been instantiated
|
|
||||||
// AuthorizedRoute is already instantiated
|
|
||||||
// Authorized render is already instantiated, children is no instantiated
|
|
||||||
// Secured is not instantiated
|
|
||||||
checkIsInstantiation = target => {
|
|
||||||
if (!React.isValidElement(target)) {
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
return () => target;
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const { component: Component } = this.state;
|
|
||||||
const { ok, error, promise, ...rest } = this.props;
|
|
||||||
return Component ? (
|
|
||||||
<Component {...rest} />
|
|
||||||
) : (
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
width: '100%',
|
|
||||||
height: '100%',
|
|
||||||
margin: 'auto',
|
|
||||||
paddingTop: 50,
|
|
||||||
textAlign: 'center',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Spin size="large" />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import Exception from '../Exception';
|
|
||||||
import CheckPermissions from './CheckPermissions';
|
|
||||||
/**
|
|
||||||
* 默认不能访问任何页面
|
|
||||||
* default is "NULL"
|
|
||||||
*/
|
|
||||||
const Exception403 = () => <Exception type="403" />;
|
|
||||||
|
|
||||||
// Determine whether the incoming component has been instantiated
|
|
||||||
// AuthorizedRoute is already instantiated
|
|
||||||
// Authorized render is already instantiated, children is no instantiated
|
|
||||||
// Secured is not instantiated
|
|
||||||
const checkIsInstantiation = target => {
|
|
||||||
if (!React.isValidElement(target)) {
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
return () => target;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用于判断是否拥有权限访问此view权限
|
|
||||||
* authority 支持传入 string, function:()=>boolean|Promise
|
|
||||||
* e.g. 'user' 只有user用户能访问
|
|
||||||
* e.g. 'user,admin' user和 admin 都能访问
|
|
||||||
* e.g. ()=>boolean 返回true能访问,返回false不能访问
|
|
||||||
* e.g. Promise then 能访问 catch不能访问
|
|
||||||
* e.g. authority support incoming string, function: () => boolean | Promise
|
|
||||||
* e.g. 'user' only user user can access
|
|
||||||
* e.g. 'user, admin' user and admin can access
|
|
||||||
* e.g. () => boolean true to be able to visit, return false can not be accessed
|
|
||||||
* e.g. Promise then can not access the visit to catch
|
|
||||||
* @param {string | function | Promise} authority
|
|
||||||
* @param {ReactNode} error 非必需参数
|
|
||||||
*/
|
|
||||||
const authorize = (authority, error) => {
|
|
||||||
/**
|
|
||||||
* conversion into a class
|
|
||||||
* 防止传入字符串时找不到staticContext造成报错
|
|
||||||
* String parameters can cause staticContext not found error
|
|
||||||
*/
|
|
||||||
let classError = false;
|
|
||||||
if (error) {
|
|
||||||
classError = () => error;
|
|
||||||
}
|
|
||||||
if (!authority) {
|
|
||||||
throw new Error('authority is required');
|
|
||||||
}
|
|
||||||
return function decideAuthority(target) {
|
|
||||||
const component = CheckPermissions(authority, target, classError || Exception403);
|
|
||||||
return checkIsInstantiation(component);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export default authorize;
|
|
|
@ -1,23 +0,0 @@
|
||||||
---
|
|
||||||
order: 1
|
|
||||||
title:
|
|
||||||
zh-CN: 使用数组作为参数
|
|
||||||
en-US: Use Array as a parameter
|
|
||||||
---
|
|
||||||
|
|
||||||
Use Array as a parameter
|
|
||||||
|
|
||||||
```jsx
|
|
||||||
import RenderAuthorized from 'ant-design-pro/lib/Authorized';
|
|
||||||
import { Alert } from 'antd';
|
|
||||||
|
|
||||||
const Authorized = RenderAuthorized('user');
|
|
||||||
const noMatch = <Alert message="No permission." type="error" showIcon />;
|
|
||||||
|
|
||||||
ReactDOM.render(
|
|
||||||
<Authorized authority={['user', 'admin']} noMatch={noMatch}>
|
|
||||||
<Alert message="Use Array as a parameter passed!" type="success" showIcon />
|
|
||||||
</Authorized>,
|
|
||||||
mountNode,
|
|
||||||
);
|
|
||||||
```
|
|
|
@ -1,31 +0,0 @@
|
||||||
---
|
|
||||||
order: 2
|
|
||||||
title:
|
|
||||||
zh-CN: 使用方法作为参数
|
|
||||||
en-US: Use function as a parameter
|
|
||||||
---
|
|
||||||
|
|
||||||
Use Function as a parameter
|
|
||||||
|
|
||||||
```jsx
|
|
||||||
import RenderAuthorized from 'ant-design-pro/lib/Authorized';
|
|
||||||
import { Alert } from 'antd';
|
|
||||||
|
|
||||||
const Authorized = RenderAuthorized('user');
|
|
||||||
const noMatch = <Alert message="No permission." type="error" showIcon />;
|
|
||||||
|
|
||||||
const havePermission = () => {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
ReactDOM.render(
|
|
||||||
<Authorized authority={havePermission} noMatch={noMatch}>
|
|
||||||
<Alert
|
|
||||||
message="Use Function as a parameter passed!"
|
|
||||||
type="success"
|
|
||||||
showIcon
|
|
||||||
/>
|
|
||||||
</Authorized>,
|
|
||||||
mountNode,
|
|
||||||
);
|
|
||||||
```
|
|
|
@ -1,25 +0,0 @@
|
||||||
---
|
|
||||||
order: 0
|
|
||||||
title:
|
|
||||||
zh-CN: 基本使用
|
|
||||||
en-US: Basic use
|
|
||||||
---
|
|
||||||
|
|
||||||
Basic use
|
|
||||||
|
|
||||||
```jsx
|
|
||||||
import RenderAuthorized from 'ant-design-pro/lib/Authorized';
|
|
||||||
import { Alert } from 'antd';
|
|
||||||
|
|
||||||
const Authorized = RenderAuthorized('user');
|
|
||||||
const noMatch = <Alert message="No permission." type="error" showIcon />;
|
|
||||||
|
|
||||||
ReactDOM.render(
|
|
||||||
<div>
|
|
||||||
<Authorized authority="admin" noMatch={noMatch}>
|
|
||||||
<Alert message="user Passed!" type="success" showIcon />
|
|
||||||
</Authorized>
|
|
||||||
</div>,
|
|
||||||
mountNode,
|
|
||||||
);
|
|
||||||
```
|
|
|
@ -1,28 +0,0 @@
|
||||||
---
|
|
||||||
order: 3
|
|
||||||
title:
|
|
||||||
zh-CN: 注解基本使用
|
|
||||||
en-US: Basic use secured
|
|
||||||
---
|
|
||||||
|
|
||||||
secured demo used
|
|
||||||
|
|
||||||
```jsx
|
|
||||||
import RenderAuthorized from 'ant-design-pro/lib/Authorized';
|
|
||||||
import { Alert } from 'antd';
|
|
||||||
|
|
||||||
const { Secured } = RenderAuthorized('user');
|
|
||||||
|
|
||||||
@Secured('admin')
|
|
||||||
class TestSecuredString extends React.Component {
|
|
||||||
render() {
|
|
||||||
<Alert message="user Passed!" type="success" showIcon />;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ReactDOM.render(
|
|
||||||
<div>
|
|
||||||
<TestSecuredString />
|
|
||||||
</div>,
|
|
||||||
mountNode,
|
|
||||||
);
|
|
||||||
```
|
|
|
@ -1,43 +0,0 @@
|
||||||
import * as React from 'react';
|
|
||||||
import { RouteProps } from 'react-router';
|
|
||||||
|
|
||||||
type authorityFN = (currentAuthority?: string) => boolean;
|
|
||||||
|
|
||||||
type authority = string | Array<string> | authorityFN | Promise<any>;
|
|
||||||
|
|
||||||
export type IReactComponent<P = any> =
|
|
||||||
| React.StatelessComponent<P>
|
|
||||||
| React.ComponentClass<P>
|
|
||||||
| React.ClassicComponentClass<P>;
|
|
||||||
|
|
||||||
interface Secured {
|
|
||||||
(authority: authority, error?: React.ReactNode): <T extends IReactComponent>(target: T) => T;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AuthorizedRouteProps extends RouteProps {
|
|
||||||
authority: authority;
|
|
||||||
}
|
|
||||||
export class AuthorizedRoute extends React.Component<AuthorizedRouteProps, any> {}
|
|
||||||
|
|
||||||
interface check {
|
|
||||||
<T extends IReactComponent, S extends IReactComponent>(
|
|
||||||
authority: authority,
|
|
||||||
target: T,
|
|
||||||
Exception: S
|
|
||||||
): T | S;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AuthorizedProps {
|
|
||||||
authority: authority;
|
|
||||||
noMatch?: React.ReactNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Authorized extends React.Component<AuthorizedProps, any> {
|
|
||||||
static Secured: Secured;
|
|
||||||
static AuthorizedRoute: typeof AuthorizedRoute;
|
|
||||||
static check: check;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare function renderAuthorize(currentAuthority: string): typeof Authorized;
|
|
||||||
|
|
||||||
export default renderAuthorize;
|
|
|
@ -1,11 +0,0 @@
|
||||||
import Authorized from './Authorized';
|
|
||||||
import AuthorizedRoute from './AuthorizedRoute';
|
|
||||||
import Secured from './Secured';
|
|
||||||
import check from './CheckPermissions';
|
|
||||||
import renderAuthorize from './renderAuthorize';
|
|
||||||
|
|
||||||
Authorized.Secured = Secured;
|
|
||||||
Authorized.AuthorizedRoute = AuthorizedRoute;
|
|
||||||
Authorized.check = check;
|
|
||||||
|
|
||||||
export default renderAuthorize(Authorized);
|
|
|
@ -1,58 +0,0 @@
|
||||||
---
|
|
||||||
title:
|
|
||||||
en-US: Authorized
|
|
||||||
zh-CN: Authorized
|
|
||||||
subtitle: 权限
|
|
||||||
cols: 1
|
|
||||||
order: 15
|
|
||||||
---
|
|
||||||
|
|
||||||
权限组件,通过比对现有权限与准入权限,决定相关元素的展示。
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
### RenderAuthorized
|
|
||||||
|
|
||||||
`RenderAuthorized: (currentAuthority: string | () => string) => Authorized`
|
|
||||||
|
|
||||||
权限组件默认 export RenderAuthorized 函数,它接收当前权限作为参数,返回一个权限对象,该对象提供以下几种使用方式。
|
|
||||||
|
|
||||||
|
|
||||||
### Authorized
|
|
||||||
|
|
||||||
最基础的权限控制。
|
|
||||||
|
|
||||||
| 参数 | 说明 | 类型 | 默认值 |
|
|
||||||
|----------|------------------------------------------|-------------|-------|
|
|
||||||
| children | 正常渲染的元素,权限判断通过时展示 | ReactNode | - |
|
|
||||||
| authority | 准入权限/权限判断 | `string | array | Promise | (currentAuthority) => boolean | Promise` | - |
|
|
||||||
| noMatch | 权限异常渲染元素,权限判断不通过时展示 | ReactNode | - |
|
|
||||||
|
|
||||||
### Authorized.AuthorizedRoute
|
|
||||||
|
|
||||||
| 参数 | 说明 | 类型 | 默认值 |
|
|
||||||
|----------|------------------------------------------|-------------|-------|
|
|
||||||
| authority | 准入权限/权限判断 | `string | array | Promise | (currentAuthority) => boolean | Promise` | - |
|
|
||||||
| redirectPath | 权限异常时重定向的页面路由 | string | - |
|
|
||||||
|
|
||||||
其余参数与 `Route` 相同。
|
|
||||||
|
|
||||||
### Authorized.Secured
|
|
||||||
|
|
||||||
注解方式,`@Authorized.Secured(authority, error)`
|
|
||||||
|
|
||||||
| 参数 | 说明 | 类型 | 默认值 |
|
|
||||||
|----------|------------------------------------------|-------------|-------|
|
|
||||||
| authority | 准入权限/权限判断 | `string | Promise | (currentAuthority) => boolean | Promise` | - |
|
|
||||||
| error | 权限异常时渲染元素 | ReactNode | <Exception type="403" /> |
|
|
||||||
|
|
||||||
### Authorized.check
|
|
||||||
|
|
||||||
函数形式的 Authorized,用于某些不能被 HOC 包裹的组件。 `Authorized.check(authority, target, Exception)`
|
|
||||||
注意:传入一个 Promise 时,无论正确还是错误返回的都是一个 ReactClass。
|
|
||||||
|
|
||||||
| 参数 | 说明 | 类型 | 默认值 |
|
|
||||||
|----------|------------------------------------------|-------------|-------|
|
|
||||||
| authority | 准入权限/权限判断 | `string | Promise | (currentAuthority) => boolean | Promise` | - |
|
|
||||||
| target | 权限判断通过时渲染的元素 | ReactNode | - |
|
|
||||||
| Exception | 权限异常时渲染元素 | ReactNode | - |
|
|
|
@ -1,25 +0,0 @@
|
||||||
/* eslint-disable import/no-mutable-exports */
|
|
||||||
let CURRENT = 'NULL';
|
|
||||||
/**
|
|
||||||
* use authority or getAuthority
|
|
||||||
* @param {string|()=>String} currentAuthority
|
|
||||||
*/
|
|
||||||
const renderAuthorize = Authorized => currentAuthority => {
|
|
||||||
if (currentAuthority) {
|
|
||||||
if (typeof currentAuthority === 'function') {
|
|
||||||
CURRENT = currentAuthority();
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
Object.prototype.toString.call(currentAuthority) === '[object String]' ||
|
|
||||||
Array.isArray(currentAuthority)
|
|
||||||
) {
|
|
||||||
CURRENT = currentAuthority;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
CURRENT = 'NULL';
|
|
||||||
}
|
|
||||||
return Authorized;
|
|
||||||
};
|
|
||||||
|
|
||||||
export { CURRENT };
|
|
||||||
export default Authorized => renderAuthorize(Authorized);
|
|
|
@ -1,10 +0,0 @@
|
||||||
import * as React from 'react';
|
|
||||||
export interface IAvatarItemProps {
|
|
||||||
tips: React.ReactNode;
|
|
||||||
src: string;
|
|
||||||
style?: React.CSSProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class AvatarItem extends React.Component<IAvatarItemProps, any> {
|
|
||||||
constructor(props: IAvatarItemProps);
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
---
|
|
||||||
order: 0
|
|
||||||
title:
|
|
||||||
zh-CN: 基础样例
|
|
||||||
en-US: Basic Usage
|
|
||||||
---
|
|
||||||
|
|
||||||
Simplest of usage.
|
|
||||||
|
|
||||||
````jsx
|
|
||||||
import AvatarList from 'ant-design-pro/lib/AvatarList';
|
|
||||||
|
|
||||||
ReactDOM.render(
|
|
||||||
<AvatarList size="mini">
|
|
||||||
<AvatarList.Item tips="Jake" src="https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png" />
|
|
||||||
<AvatarList.Item tips="Andy" src="https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png" />
|
|
||||||
<AvatarList.Item tips="Niko" src="https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png" />
|
|
||||||
</AvatarList>
|
|
||||||
, mountNode);
|
|
||||||
````
|
|
|
@ -1,12 +0,0 @@
|
||||||
import * as React from 'react';
|
|
||||||
import AvatarItem from './AvatarItem';
|
|
||||||
|
|
||||||
export interface IAvatarListProps {
|
|
||||||
size?: 'large' | 'small' | 'mini' | 'default';
|
|
||||||
style?: React.CSSProperties;
|
|
||||||
children: React.ReactElement<AvatarItem> | Array<React.ReactElement<AvatarItem>>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class AvatarList extends React.Component<IAvatarListProps, any> {
|
|
||||||
public static Item: typeof AvatarItem;
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
---
|
|
||||||
title: AvatarList
|
|
||||||
order: 1
|
|
||||||
cols: 1
|
|
||||||
---
|
|
||||||
|
|
||||||
A list of user's avatar for project or group member list frequently. If a large or small AvatarList is desired, set the `size` property to either `large` or `small` and `mini` respectively. Omit the `size` property for a AvatarList with the default size.
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
### AvatarList
|
|
||||||
|
|
||||||
| Property | Description | Type | Default |
|
|
||||||
|----------|------------------------------------------|-------------|-------|
|
|
||||||
| size | size of list | `large`、`small` 、`mini`, `default` | `default` |
|
|
||||||
|
|
||||||
### AvatarList.Item
|
|
||||||
|
|
||||||
| Property | Description | Type | Default |
|
|
||||||
|----------|------------------------------------------|-------------|-------|
|
|
||||||
| tips | title tips for avatar item | ReactNode | - |
|
|
||||||
| src | the address of the image for an image avatar | string | - |
|
|
|
@ -1,43 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import { Tooltip, Avatar } from 'antd';
|
|
||||||
import classNames from 'classnames';
|
|
||||||
|
|
||||||
import styles from './index.less';
|
|
||||||
|
|
||||||
const AvatarList = ({ children, size, ...other }) => {
|
|
||||||
const childrenWithProps = React.Children.map(children, child =>
|
|
||||||
React.cloneElement(child, {
|
|
||||||
size,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div {...other} className={styles.avatarList}>
|
|
||||||
<ul> {childrenWithProps} </ul>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const Item = ({ src, size, tips, onClick = () => {} }) => {
|
|
||||||
const cls = classNames(styles.avatarItem, {
|
|
||||||
[styles.avatarItemLarge]: size === 'large',
|
|
||||||
[styles.avatarItemSmall]: size === 'small',
|
|
||||||
[styles.avatarItemMini]: size === 'mini',
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<li className={cls} onClick={onClick}>
|
|
||||||
{tips ? (
|
|
||||||
<Tooltip title={tips}>
|
|
||||||
<Avatar src={src} size={size} style={{ cursor: 'pointer' }} />
|
|
||||||
</Tooltip>
|
|
||||||
) : (
|
|
||||||
<Avatar src={src} size={size} />
|
|
||||||
)}
|
|
||||||
</li>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
AvatarList.Item = Item;
|
|
||||||
|
|
||||||
export default AvatarList;
|
|
|
@ -1,45 +0,0 @@
|
||||||
@import '~antd/lib/style/themes/default.less';
|
|
||||||
|
|
||||||
.avatarList {
|
|
||||||
display: inline-block;
|
|
||||||
ul {
|
|
||||||
display: inline-block;
|
|
||||||
margin-left: 8px;
|
|
||||||
font-size: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatarItem {
|
|
||||||
display: inline-block;
|
|
||||||
font-size: @font-size-base;
|
|
||||||
margin-left: -8px;
|
|
||||||
width: @avatar-size-base;
|
|
||||||
height: @avatar-size-base;
|
|
||||||
:global {
|
|
||||||
.ant-avatar {
|
|
||||||
border: 1px solid #fff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatarItemLarge {
|
|
||||||
width: @avatar-size-lg;
|
|
||||||
height: @avatar-size-lg;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatarItemSmall {
|
|
||||||
width: @avatar-size-sm;
|
|
||||||
height: @avatar-size-sm;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatarItemMini {
|
|
||||||
width: 20px;
|
|
||||||
height: 20px;
|
|
||||||
:global {
|
|
||||||
.ant-avatar {
|
|
||||||
width: 20px;
|
|
||||||
height: 20px;
|
|
||||||
line-height: 20px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
---
|
|
||||||
title: AvatarList
|
|
||||||
subtitle: 用户头像列表
|
|
||||||
order: 1
|
|
||||||
cols: 1
|
|
||||||
---
|
|
||||||
|
|
||||||
一组用户头像,常用在项目/团队成员列表。可通过设置 `size` 属性来指定头像大小。
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
### AvatarList
|
|
||||||
|
|
||||||
| 参数 | 说明 | 类型 | 默认值 |
|
|
||||||
|----------|------------------------------------------|-------------|-------|
|
|
||||||
| size | 头像大小 | `large`、`small` 、`mini`, `default` | `default` |
|
|
||||||
|
|
||||||
### AvatarList.Item
|
|
||||||
|
|
||||||
| 参数 | 说明 | 类型 | 默认值 |
|
|
||||||
|----------|------------------------------------------|-------------|-------|
|
|
||||||
| tips | 头像展示文案 | ReactNode | - |
|
|
||||||
| src | 头像图片连接 | string | - |
|
|
|
@ -1,15 +0,0 @@
|
||||||
import * as React from 'react';
|
|
||||||
export interface IBarProps {
|
|
||||||
title: React.ReactNode;
|
|
||||||
color?: string;
|
|
||||||
padding?: [number, number, number, number];
|
|
||||||
height: number;
|
|
||||||
data: Array<{
|
|
||||||
x: string;
|
|
||||||
y: number;
|
|
||||||
}>;
|
|
||||||
autoLabel?: boolean;
|
|
||||||
style?: React.CSSProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class Bar extends React.Component<IBarProps, any> {}
|
|
|
@ -1,113 +0,0 @@
|
||||||
import React, { Component } from 'react';
|
|
||||||
import { Chart, Axis, Tooltip, Geom } from 'bizcharts';
|
|
||||||
import Debounce from 'lodash-decorators/debounce';
|
|
||||||
import Bind from 'lodash-decorators/bind';
|
|
||||||
import autoHeight from '../autoHeight';
|
|
||||||
import styles from '../index.less';
|
|
||||||
|
|
||||||
@autoHeight()
|
|
||||||
class Bar extends Component {
|
|
||||||
state = {
|
|
||||||
autoHideXLabels: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
window.addEventListener('resize', this.resize, { passive: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
window.removeEventListener('resize', this.resize);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleRoot = n => {
|
|
||||||
this.root = n;
|
|
||||||
};
|
|
||||||
|
|
||||||
handleRef = n => {
|
|
||||||
this.node = n;
|
|
||||||
};
|
|
||||||
|
|
||||||
@Bind()
|
|
||||||
@Debounce(400)
|
|
||||||
resize() {
|
|
||||||
if (!this.node) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const canvasWidth = this.node.parentNode.clientWidth;
|
|
||||||
const { data = [], autoLabel = true } = this.props;
|
|
||||||
if (!autoLabel) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const minWidth = data.length * 30;
|
|
||||||
const { autoHideXLabels } = this.state;
|
|
||||||
|
|
||||||
if (canvasWidth <= minWidth) {
|
|
||||||
if (!autoHideXLabels) {
|
|
||||||
this.setState({
|
|
||||||
autoHideXLabels: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (autoHideXLabels) {
|
|
||||||
this.setState({
|
|
||||||
autoHideXLabels: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const {
|
|
||||||
height,
|
|
||||||
title,
|
|
||||||
forceFit = true,
|
|
||||||
data,
|
|
||||||
color = 'rgba(24, 144, 255, 0.85)',
|
|
||||||
padding,
|
|
||||||
} = this.props;
|
|
||||||
|
|
||||||
const { autoHideXLabels } = this.state;
|
|
||||||
|
|
||||||
const scale = {
|
|
||||||
x: {
|
|
||||||
type: 'cat',
|
|
||||||
},
|
|
||||||
y: {
|
|
||||||
min: 0,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const tooltip = [
|
|
||||||
'x*y',
|
|
||||||
(x, y) => ({
|
|
||||||
name: x,
|
|
||||||
value: y,
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={styles.chart} style={{ height }} ref={this.handleRoot}>
|
|
||||||
<div ref={this.handleRef}>
|
|
||||||
{title && <h4 style={{ marginBottom: 20 }}>{title}</h4>}
|
|
||||||
<Chart
|
|
||||||
scale={scale}
|
|
||||||
height={title ? height - 41 : height}
|
|
||||||
forceFit={forceFit}
|
|
||||||
data={data}
|
|
||||||
padding={padding || 'auto'}
|
|
||||||
>
|
|
||||||
<Axis
|
|
||||||
name="x"
|
|
||||||
title={false}
|
|
||||||
label={autoHideXLabels ? false : {}}
|
|
||||||
tickLine={autoHideXLabels ? false : {}}
|
|
||||||
/>
|
|
||||||
<Axis name="y" min={0} />
|
|
||||||
<Tooltip showTitle={false} crosshairs={false} />
|
|
||||||
<Geom type="interval" position="x*y" color={color} tooltip={tooltip} />
|
|
||||||
</Chart>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Bar;
|
|
|
@ -1,14 +0,0 @@
|
||||||
import * as React from 'react';
|
|
||||||
import { CardProps } from 'antd/lib/card';
|
|
||||||
|
|
||||||
export interface IChartCardProps extends CardProps {
|
|
||||||
title: React.ReactNode;
|
|
||||||
action?: React.ReactNode;
|
|
||||||
total?: React.ReactNode | number | (() => React.ReactNode | number);
|
|
||||||
footer?: React.ReactNode;
|
|
||||||
contentHeight?: number;
|
|
||||||
avatar?: React.ReactNode;
|
|
||||||
style?: React.CSSProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class ChartCard extends React.Component<IChartCardProps, any> {}
|
|
|
@ -1,82 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import { Card } from 'antd';
|
|
||||||
import classNames from 'classnames';
|
|
||||||
|
|
||||||
import styles from './index.less';
|
|
||||||
|
|
||||||
const renderTotal = total => {
|
|
||||||
let totalDom;
|
|
||||||
switch (typeof total) {
|
|
||||||
case 'undefined':
|
|
||||||
totalDom = null;
|
|
||||||
break;
|
|
||||||
case 'function':
|
|
||||||
totalDom = <div className={styles.total}>{total()}</div>;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
totalDom = <div className={styles.total}>{total}</div>;
|
|
||||||
}
|
|
||||||
return totalDom;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ChartCard extends React.PureComponent {
|
|
||||||
renderConnet = () => {
|
|
||||||
const { contentHeight, title, avatar, action, total, footer, children, loading } = this.props;
|
|
||||||
if (loading) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<div className={styles.chartCard}>
|
|
||||||
<div
|
|
||||||
className={classNames(styles.chartTop, {
|
|
||||||
[styles.chartTopMargin]: !children && !footer,
|
|
||||||
})}
|
|
||||||
>
|
|
||||||
<div className={styles.avatar}>{avatar}</div>
|
|
||||||
<div className={styles.metaWrap}>
|
|
||||||
<div className={styles.meta}>
|
|
||||||
<span className={styles.title}>{title}</span>
|
|
||||||
<span className={styles.action}>{action}</span>
|
|
||||||
</div>
|
|
||||||
{renderTotal(total)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{children && (
|
|
||||||
<div className={styles.content} style={{ height: contentHeight || 'auto' }}>
|
|
||||||
<div className={contentHeight && styles.contentFixed}>{children}</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{footer && (
|
|
||||||
<div
|
|
||||||
className={classNames(styles.footer, {
|
|
||||||
[styles.footerMargin]: !children,
|
|
||||||
})}
|
|
||||||
>
|
|
||||||
{footer}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const {
|
|
||||||
loading = false,
|
|
||||||
contentHeight,
|
|
||||||
title,
|
|
||||||
avatar,
|
|
||||||
action,
|
|
||||||
total,
|
|
||||||
footer,
|
|
||||||
children,
|
|
||||||
...rest
|
|
||||||
} = this.props;
|
|
||||||
return (
|
|
||||||
<Card loading={loading} bodyStyle={{ padding: '20px 24px 8px 24px' }} {...rest}>
|
|
||||||
{this.renderConnet()}
|
|
||||||
</Card>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ChartCard;
|
|
|
@ -1,74 +0,0 @@
|
||||||
@import '~antd/lib/style/themes/default.less';
|
|
||||||
|
|
||||||
.chartCard {
|
|
||||||
position: relative;
|
|
||||||
.chartTop {
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.chartTopMargin {
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
.chartTopHasMargin {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
.metaWrap {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
.avatar {
|
|
||||||
position: relative;
|
|
||||||
top: 4px;
|
|
||||||
float: left;
|
|
||||||
margin-right: 20px;
|
|
||||||
img {
|
|
||||||
border-radius: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.meta {
|
|
||||||
color: @text-color-secondary;
|
|
||||||
font-size: @font-size-base;
|
|
||||||
line-height: 22px;
|
|
||||||
height: 22px;
|
|
||||||
}
|
|
||||||
.action {
|
|
||||||
cursor: pointer;
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
right: 0;
|
|
||||||
}
|
|
||||||
.total {
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
word-break: break-all;
|
|
||||||
white-space: nowrap;
|
|
||||||
color: @heading-color;
|
|
||||||
margin-top: 4px;
|
|
||||||
margin-bottom: 0;
|
|
||||||
font-size: 30px;
|
|
||||||
line-height: 38px;
|
|
||||||
height: 38px;
|
|
||||||
}
|
|
||||||
.content {
|
|
||||||
margin-bottom: 12px;
|
|
||||||
position: relative;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.contentFixed {
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
bottom: 0;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.footer {
|
|
||||||
border-top: 1px solid @border-color-split;
|
|
||||||
padding-top: 9px;
|
|
||||||
margin-top: 8px;
|
|
||||||
& > * {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.footerMargin {
|
|
||||||
margin-top: 20px;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
import * as React from 'react';
|
|
||||||
export interface IFieldProps {
|
|
||||||
label: React.ReactNode;
|
|
||||||
value: React.ReactNode;
|
|
||||||
style?: React.CSSProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class Field extends React.Component<IFieldProps, any> {}
|
|
|
@ -1,12 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
|
|
||||||
import styles from './index.less';
|
|
||||||
|
|
||||||
const Field = ({ label, value, ...rest }) => (
|
|
||||||
<div className={styles.field} {...rest}>
|
|
||||||
<span>{label}</span>
|
|
||||||
<span>{value}</span>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
export default Field;
|
|
|
@ -1,16 +0,0 @@
|
||||||
@import '~antd/lib/style/themes/default.less';
|
|
||||||
|
|
||||||
.field {
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
margin: 0;
|
|
||||||
span {
|
|
||||||
font-size: @font-size-base;
|
|
||||||
line-height: 22px;
|
|
||||||
}
|
|
||||||
span:last-child {
|
|
||||||
margin-left: 8px;
|
|
||||||
color: @heading-color;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
import * as React from 'react';
|
|
||||||
export interface IGaugeProps {
|
|
||||||
title: React.ReactNode;
|
|
||||||
color?: string;
|
|
||||||
height: number;
|
|
||||||
bgColor?: number;
|
|
||||||
percent: number;
|
|
||||||
style?: React.CSSProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class Gauge extends React.Component<IGaugeProps, any> {}
|
|
|
@ -1,167 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import { Chart, Geom, Axis, Coord, Guide, Shape } from 'bizcharts';
|
|
||||||
import autoHeight from '../autoHeight';
|
|
||||||
|
|
||||||
const { Arc, Html, Line } = Guide;
|
|
||||||
|
|
||||||
const defaultFormatter = val => {
|
|
||||||
switch (val) {
|
|
||||||
case '2':
|
|
||||||
return '差';
|
|
||||||
case '4':
|
|
||||||
return '中';
|
|
||||||
case '6':
|
|
||||||
return '良';
|
|
||||||
case '8':
|
|
||||||
return '优';
|
|
||||||
default:
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Shape.registerShape('point', 'pointer', {
|
|
||||||
drawShape(cfg, group) {
|
|
||||||
let point = cfg.points[0];
|
|
||||||
point = this.parsePoint(point);
|
|
||||||
const center = this.parsePoint({
|
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
});
|
|
||||||
group.addShape('line', {
|
|
||||||
attrs: {
|
|
||||||
x1: center.x,
|
|
||||||
y1: center.y,
|
|
||||||
x2: point.x,
|
|
||||||
y2: point.y,
|
|
||||||
stroke: cfg.color,
|
|
||||||
lineWidth: 2,
|
|
||||||
lineCap: 'round',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return group.addShape('circle', {
|
|
||||||
attrs: {
|
|
||||||
x: center.x,
|
|
||||||
y: center.y,
|
|
||||||
r: 6,
|
|
||||||
stroke: cfg.color,
|
|
||||||
lineWidth: 3,
|
|
||||||
fill: '#fff',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
@autoHeight()
|
|
||||||
class Gauge extends React.Component {
|
|
||||||
render() {
|
|
||||||
const {
|
|
||||||
title,
|
|
||||||
height,
|
|
||||||
percent,
|
|
||||||
forceFit = true,
|
|
||||||
formatter = defaultFormatter,
|
|
||||||
color = '#2F9CFF',
|
|
||||||
bgColor = '#F0F2F5',
|
|
||||||
} = this.props;
|
|
||||||
const cols = {
|
|
||||||
value: {
|
|
||||||
type: 'linear',
|
|
||||||
min: 0,
|
|
||||||
max: 10,
|
|
||||||
tickCount: 6,
|
|
||||||
nice: true,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const data = [{ value: percent / 10 }];
|
|
||||||
return (
|
|
||||||
<Chart height={height} data={data} scale={cols} padding={[-16, 0, 16, 0]} forceFit={forceFit}>
|
|
||||||
<Coord type="polar" startAngle={-1.25 * Math.PI} endAngle={0.25 * Math.PI} radius={0.8} />
|
|
||||||
<Axis name="1" line={null} />
|
|
||||||
<Axis
|
|
||||||
line={null}
|
|
||||||
tickLine={null}
|
|
||||||
subTickLine={null}
|
|
||||||
name="value"
|
|
||||||
zIndex={2}
|
|
||||||
gird={null}
|
|
||||||
label={{
|
|
||||||
offset: -12,
|
|
||||||
formatter,
|
|
||||||
textStyle: {
|
|
||||||
fontSize: 12,
|
|
||||||
fill: 'rgba(0, 0, 0, 0.65)',
|
|
||||||
textAlign: 'center',
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Guide>
|
|
||||||
<Line
|
|
||||||
start={[3, 0.905]}
|
|
||||||
end={[3, 0.85]}
|
|
||||||
lineStyle={{
|
|
||||||
stroke: color,
|
|
||||||
lineDash: null,
|
|
||||||
lineWidth: 2,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Line
|
|
||||||
start={[5, 0.905]}
|
|
||||||
end={[5, 0.85]}
|
|
||||||
lineStyle={{
|
|
||||||
stroke: color,
|
|
||||||
lineDash: null,
|
|
||||||
lineWidth: 3,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Line
|
|
||||||
start={[7, 0.905]}
|
|
||||||
end={[7, 0.85]}
|
|
||||||
lineStyle={{
|
|
||||||
stroke: color,
|
|
||||||
lineDash: null,
|
|
||||||
lineWidth: 3,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Arc
|
|
||||||
zIndex={0}
|
|
||||||
start={[0, 0.965]}
|
|
||||||
end={[10, 0.965]}
|
|
||||||
style={{
|
|
||||||
stroke: bgColor,
|
|
||||||
lineWidth: 10,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Arc
|
|
||||||
zIndex={1}
|
|
||||||
start={[0, 0.965]}
|
|
||||||
end={[data[0].value, 0.965]}
|
|
||||||
style={{
|
|
||||||
stroke: color,
|
|
||||||
lineWidth: 10,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Html
|
|
||||||
position={['50%', '95%']}
|
|
||||||
html={() => `
|
|
||||||
<div style="width: 300px;text-align: center;font-size: 12px!important;">
|
|
||||||
<p style="font-size: 14px; color: rgba(0,0,0,0.43);margin: 0;">${title}</p>
|
|
||||||
<p style="font-size: 24px;color: rgba(0,0,0,0.85);margin: 0;">
|
|
||||||
${data[0].value * 10}%
|
|
||||||
</p>
|
|
||||||
</div>`}
|
|
||||||
/>
|
|
||||||
</Guide>
|
|
||||||
<Geom
|
|
||||||
line={false}
|
|
||||||
type="point"
|
|
||||||
position="value*1"
|
|
||||||
shape="pointer"
|
|
||||||
color={color}
|
|
||||||
active={false}
|
|
||||||
/>
|
|
||||||
</Chart>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Gauge;
|
|
|
@ -1,29 +0,0 @@
|
||||||
import * as React from 'react';
|
|
||||||
|
|
||||||
// g2已经更新到3.0
|
|
||||||
// 不带的写了
|
|
||||||
|
|
||||||
export interface IAxis {
|
|
||||||
title: any;
|
|
||||||
line: any;
|
|
||||||
gridAlign: any;
|
|
||||||
labels: any;
|
|
||||||
tickLine: any;
|
|
||||||
grid: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IMiniAreaProps {
|
|
||||||
color?: string;
|
|
||||||
height: number;
|
|
||||||
borderColor?: string;
|
|
||||||
line?: boolean;
|
|
||||||
animate?: boolean;
|
|
||||||
xAxis?: IAxis;
|
|
||||||
yAxis?: IAxis;
|
|
||||||
data: Array<{
|
|
||||||
x: number | string;
|
|
||||||
y: number;
|
|
||||||
}>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class MiniArea extends React.Component<IMiniAreaProps, any> {}
|
|
|
@ -1,108 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import { Chart, Axis, Tooltip, Geom } from 'bizcharts';
|
|
||||||
import autoHeight from '../autoHeight';
|
|
||||||
import styles from '../index.less';
|
|
||||||
|
|
||||||
@autoHeight()
|
|
||||||
class MiniArea extends React.PureComponent {
|
|
||||||
render() {
|
|
||||||
const {
|
|
||||||
height,
|
|
||||||
data = [],
|
|
||||||
forceFit = true,
|
|
||||||
color = 'rgba(24, 144, 255, 0.2)',
|
|
||||||
borderColor = '#1089ff',
|
|
||||||
scale = {},
|
|
||||||
borderWidth = 2,
|
|
||||||
line,
|
|
||||||
xAxis,
|
|
||||||
yAxis,
|
|
||||||
animate = true,
|
|
||||||
} = this.props;
|
|
||||||
|
|
||||||
const padding = [36, 5, 30, 5];
|
|
||||||
|
|
||||||
const scaleProps = {
|
|
||||||
x: {
|
|
||||||
type: 'cat',
|
|
||||||
range: [0, 1],
|
|
||||||
...scale.x,
|
|
||||||
},
|
|
||||||
y: {
|
|
||||||
min: 0,
|
|
||||||
...scale.y,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const tooltip = [
|
|
||||||
'x*y',
|
|
||||||
(x, y) => ({
|
|
||||||
name: x,
|
|
||||||
value: y,
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
|
|
||||||
const chartHeight = height + 54;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={styles.miniChart} style={{ height }}>
|
|
||||||
<div className={styles.chartContent}>
|
|
||||||
{height > 0 && (
|
|
||||||
<Chart
|
|
||||||
animate={animate}
|
|
||||||
scale={scaleProps}
|
|
||||||
height={chartHeight}
|
|
||||||
forceFit={forceFit}
|
|
||||||
data={data}
|
|
||||||
padding={padding}
|
|
||||||
>
|
|
||||||
<Axis
|
|
||||||
key="axis-x"
|
|
||||||
name="x"
|
|
||||||
label={false}
|
|
||||||
line={false}
|
|
||||||
tickLine={false}
|
|
||||||
grid={false}
|
|
||||||
{...xAxis}
|
|
||||||
/>
|
|
||||||
<Axis
|
|
||||||
key="axis-y"
|
|
||||||
name="y"
|
|
||||||
label={false}
|
|
||||||
line={false}
|
|
||||||
tickLine={false}
|
|
||||||
grid={false}
|
|
||||||
{...yAxis}
|
|
||||||
/>
|
|
||||||
<Tooltip showTitle={false} crosshairs={false} />
|
|
||||||
<Geom
|
|
||||||
type="area"
|
|
||||||
position="x*y"
|
|
||||||
color={color}
|
|
||||||
tooltip={tooltip}
|
|
||||||
shape="smooth"
|
|
||||||
style={{
|
|
||||||
fillOpacity: 1,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{line ? (
|
|
||||||
<Geom
|
|
||||||
type="line"
|
|
||||||
position="x*y"
|
|
||||||
shape="smooth"
|
|
||||||
color={borderColor}
|
|
||||||
size={borderWidth}
|
|
||||||
tooltip={false}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<span style={{ display: 'none' }} />
|
|
||||||
)}
|
|
||||||
</Chart>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default MiniArea;
|
|
|
@ -1,12 +0,0 @@
|
||||||
import * as React from 'react';
|
|
||||||
export interface IMiniBarProps {
|
|
||||||
color?: string;
|
|
||||||
height: number;
|
|
||||||
data: Array<{
|
|
||||||
x: number | string;
|
|
||||||
y: number;
|
|
||||||
}>;
|
|
||||||
style?: React.CSSProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class MiniBar extends React.Component<IMiniBarProps, any> {}
|
|
|
@ -1,51 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import { Chart, Tooltip, Geom } from 'bizcharts';
|
|
||||||
import autoHeight from '../autoHeight';
|
|
||||||
import styles from '../index.less';
|
|
||||||
|
|
||||||
@autoHeight()
|
|
||||||
class MiniBar extends React.Component {
|
|
||||||
render() {
|
|
||||||
const { height, forceFit = true, color = '#1890FF', data = [] } = this.props;
|
|
||||||
|
|
||||||
const scale = {
|
|
||||||
x: {
|
|
||||||
type: 'cat',
|
|
||||||
},
|
|
||||||
y: {
|
|
||||||
min: 0,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const padding = [36, 5, 30, 5];
|
|
||||||
|
|
||||||
const tooltip = [
|
|
||||||
'x*y',
|
|
||||||
(x, y) => ({
|
|
||||||
name: x,
|
|
||||||
value: y,
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
|
|
||||||
// for tooltip not to be hide
|
|
||||||
const chartHeight = height + 54;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={styles.miniChart} style={{ height }}>
|
|
||||||
<div className={styles.chartContent}>
|
|
||||||
<Chart
|
|
||||||
scale={scale}
|
|
||||||
height={chartHeight}
|
|
||||||
forceFit={forceFit}
|
|
||||||
data={data}
|
|
||||||
padding={padding}
|
|
||||||
>
|
|
||||||
<Tooltip showTitle={false} crosshairs={false} />
|
|
||||||
<Geom type="interval" position="x*y" color={color} tooltip={tooltip} />
|
|
||||||
</Chart>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export default MiniBar;
|
|
|
@ -1,10 +0,0 @@
|
||||||
import * as React from 'react';
|
|
||||||
export interface IMiniProgressProps {
|
|
||||||
target: number;
|
|
||||||
color?: string;
|
|
||||||
strokeWidth?: number;
|
|
||||||
percent?: number;
|
|
||||||
style?: React.CSSProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class MiniProgress extends React.Component<IMiniProgressProps, any> {}
|
|
|
@ -1,27 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import { Tooltip } from 'antd';
|
|
||||||
|
|
||||||
import styles from './index.less';
|
|
||||||
|
|
||||||
const MiniProgress = ({ target, color = 'rgb(19, 194, 194)', strokeWidth, percent }) => (
|
|
||||||
<div className={styles.miniProgress}>
|
|
||||||
<Tooltip title={`目标值: ${target}%`}>
|
|
||||||
<div className={styles.target} style={{ left: target ? `${target}%` : null }}>
|
|
||||||
<span style={{ backgroundColor: color || null }} />
|
|
||||||
<span style={{ backgroundColor: color || null }} />
|
|
||||||
</div>
|
|
||||||
</Tooltip>
|
|
||||||
<div className={styles.progressWrap}>
|
|
||||||
<div
|
|
||||||
className={styles.progress}
|
|
||||||
style={{
|
|
||||||
backgroundColor: color || null,
|
|
||||||
width: percent ? `${percent}%` : null,
|
|
||||||
height: strokeWidth || null,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
export default MiniProgress;
|
|