From 688005a8a7b445dcf3c6dddf55c18885e45b2279 Mon Sep 17 00:00:00 2001 From: shiyang Date: Wed, 25 Nov 2020 01:06:19 +0800 Subject: [PATCH] update SearchMonitor --- web/config/router.config.js | 10 + web/mock/chart.js | 128 +++++++ web/src/pages/Dashboard/GatewayMonitor.js | 8 +- web/src/pages/Dashboard/Search/TagCloud.js | 4 +- web/src/pages/Dashboard/SearchMonitor.js | 393 ++++++++++++++++++++- 5 files changed, 518 insertions(+), 25 deletions(-) diff --git a/web/config/router.config.js b/web/config/router.config.js index 08f6a880..cb623a39 100644 --- a/web/config/router.config.js +++ b/web/config/router.config.js @@ -42,6 +42,16 @@ export default [ name: 'search', component: './Dashboard/SearchMonitor', }, + // { + // path: '/platform/analysis', + // name: 'analysis', + // component: './Dashboard/Analysis', + // }, + // { + // path: '/platform/monitor', + // name: 'monitor', + // component: './Dashboard/Monitor', + // }, ] }, diff --git a/web/mock/chart.js b/web/mock/chart.js index 65037758..b5104991 100644 --- a/web/mock/chart.js +++ b/web/mock/chart.js @@ -38,6 +38,132 @@ for (let i = 0; i < 50; i += 1) { 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: '家用电器', @@ -189,6 +315,8 @@ const getFakeChartData = { salesTypeDataOnline, salesTypeDataOffline, radarData, + searchDataInfini, + docTypeDataInfini, }; export default { diff --git a/web/src/pages/Dashboard/GatewayMonitor.js b/web/src/pages/Dashboard/GatewayMonitor.js index 4ddf83ff..d560ddb7 100644 --- a/web/src/pages/Dashboard/GatewayMonitor.js +++ b/web/src/pages/Dashboard/GatewayMonitor.js @@ -112,7 +112,7 @@ class GatewayMonitor extends PureComponent { bodyStyle={{ padding: '30px 0 10px' }} style={{ marginTop: 32 }} > - +

索引QPS

@@ -146,7 +146,7 @@ class GatewayMonitor extends PureComponent { style={{ marginTop: 32 }} >
- +

查询QPS

@@ -183,7 +183,7 @@ class GatewayMonitor extends PureComponent { bodyStyle={{ padding: '30px 0 10px' }} style={{ marginTop: 32 }} > - +

网关写入QPS

@@ -217,7 +217,7 @@ class GatewayMonitor extends PureComponent { style={{ marginTop: 32 }} >
- +

Top用户统计

diff --git a/web/src/pages/Dashboard/Search/TagCloud.js b/web/src/pages/Dashboard/Search/TagCloud.js index ea0af81b..8ea30816 100644 --- a/web/src/pages/Dashboard/Search/TagCloud.js +++ b/web/src/pages/Dashboard/Search/TagCloud.js @@ -143,7 +143,7 @@ class TagCloud extends PureComponent { dv.transform({ type: "tag-cloud", fields: ["name", "value"], - size: [300, 200], + size: [400, 300], font: "Verdana", padding: 0, timeInterval: 5000,// max execute time @@ -176,7 +176,7 @@ class TagCloud extends PureComponent { ({ + chart, + loading: loading.effects['chart/fetch'], +})) +class SearchMonitor extends Component { + constructor(props) { + super(props); + this.rankingListData = []; + for (let i = 0; i < 7; i += 1) { + this.rankingListData.push({ + title: formatMessage({ id: 'app.analysis.test' }, { no: i }), + total: 323234, + }); + } + } + + state = { + salesType: 'all', + currentTabKey: '', + rangePickerValue: getTimeDistance('year'), + loading: true, + }; + + componentDidMount() { + const { dispatch } = this.props; + this.reqRef = requestAnimationFrame(() => { + dispatch({ + type: 'chart/fetch', + }); + this.timeoutId = setTimeout(() => { + this.setState({ + loading: false, + }); + }, 600); + }); + } + + componentWillUnmount() { + const { dispatch } = this.props; + dispatch({ + type: 'chart/clear', + }); + cancelAnimationFrame(this.reqRef); + clearTimeout(this.timeoutId); + } + + handleChangeSalesType = e => { + this.setState({ + salesType: e.target.value, + }); + }; + + handleTabChange = key => { + this.setState({ + currentTabKey: key, + }); + }; + + handleRangePickerChange = rangePickerValue => { + const { dispatch } = this.props; + this.setState({ + rangePickerValue, + }); + + dispatch({ + type: 'chart/fetchSalesData', + }); + }; + + selectDate = type => { + const { dispatch } = this.props; + this.setState({ + rangePickerValue: getTimeDistance(type), + }); + + dispatch({ + type: 'chart/fetchSalesData', + }); + }; + + isActive(type) { + const { rangePickerValue } = this.state; + const value = getTimeDistance(type); + if (!rangePickerValue[0] || !rangePickerValue[1]) { + return ''; + } + if ( + rangePickerValue[0].isSame(value[0], 'day') && + rangePickerValue[1].isSame(value[1], 'day') + ) { + return styles.currentDate; + } + return ''; + } render() { + const { rangePickerValue, salesType, loading: propsLoding, currentTabKey } = this.state; + const { chart, loading: stateLoading } = this.props; + const { + visitData, + visitData2, + salesData, + searchData, + searchDataInfini, + offlineData, + offlineChartData, + salesTypeData, + docTypeDataInfini, + salesTypeDataOnline, + salesTypeDataOffline, + } = chart; + const loading = propsLoding || stateLoading; + let salesPieData = docTypeDataInfini; + + const menu = ( + + 操作一 + 操作二 + + ); + + const iconGroup = ( + + + + + + ); + + const salesExtra = ( + + ); + + const columns = [ + { + title: , + dataIndex: 'index', + key: 'index', + }, + { + title: ( + + ), + dataIndex: 'keyword', + key: 'keyword', + render: text => {text}, + }, + { + title: , + dataIndex: 'count', + key: 'count', + sorter: (a, b) => a.count - b.count, + className: styles.alignRight, + }, + { + title: ( + + ), + dataIndex: 'range', + key: 'range', + sorter: (a, b) => a.range - b.range, + render: (text, record) => ( + + {text}% + + ), + align: 'right', + }, + ]; + + const activeKey = currentTabKey || (offlineData[0] && offlineData[0].name); + + const CustomTab = ({ data, currentTabKey: currentKey }) => ( + + + + } + gap={2} + total={`${data.cvr * 100}%`} + theme={currentKey !== data.name && 'light'} + /> + + + + + + ); + + const topColResponsiveProps = { + xs: 24, + sm: 12, + md: 12, + lg: 12, + xl: 6, + style: { marginBottom: 24 }, + }; return ( + - + + + + + + + + } + > + + + + } + gap={8} + total={numeral(8371).format('0,0')} + status="up" + subTotal={17.1} + /> + + + + + + + } + > + + + + } + total={2.7} + status="down" + subTotal={26.2} + gap={8} + /> + + + + record.index} + size="small" + columns={columns} + dataSource={searchDataInfini} + pagination={{ + style: { marginBottom: 0 }, + pageSize: 5, + }} + /> + + + - - - + + + {/**/} + {/* */} + {/* */} - - - - + {/* */} + {/* */} + {/**/} + + + + {salesPieData.reduce((pre, now) => now.y + pre, 0)}} + data={salesPieData} + valueFormat={value => {value}} + height={248} + lineWidth={4} + /> + + + ); }