Skip to content

Commit 8491686

Browse files
committed
feat: update top service
1 parent 8d09b57 commit 8491686

File tree

4 files changed

+74
-87
lines changed

4 files changed

+74
-87
lines changed

src/components/datav/RankingBoard.js

Lines changed: 74 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,88 @@
1-
import React from 'react'
1+
import React, { useEffect, useState } from 'react'
22

33
import { ScrollRankingBoard } from '@jiaminghi/data-view-react'
44

55
import './RankingBoard.less'
6+
import httpGet from '../../service/request'
67

7-
const config = {
8-
data: [
9-
{
10-
name: '日常养护',
11-
value: 55,
12-
},
13-
{
14-
name: '交通事故',
15-
value: 120,
16-
},
17-
{
18-
name: '路面',
19-
value: 78,
20-
},
21-
{
22-
name: '桥通',
23-
value: 66,
24-
},
25-
{
26-
name: '计日工',
27-
value: 80,
28-
},
29-
{
30-
name: '路基',
31-
value: 45,
32-
},
33-
{
34-
name: '交安设施',
35-
value: 29,
36-
},
37-
{
38-
name: '除雪',
39-
value: 29,
40-
},
41-
{
42-
name: '绿化',
43-
value: 29,
44-
},
45-
],
46-
rowNum: 9,
8+
let data = [
9+
{
10+
name: '日常养护',
11+
value: 55,
12+
},
13+
{
14+
name: '交通事故',
15+
value: 120,
16+
},
17+
{
18+
name: '路面',
19+
value: 78,
20+
},
21+
{
22+
name: '桥通',
23+
value: 66,
24+
},
25+
{
26+
name: '计日工',
27+
value: 80,
28+
},
29+
{
30+
name: '路基',
31+
value: 45,
32+
},
33+
{
34+
name: '交安设施',
35+
value: 29,
36+
},
37+
{
38+
name: '除雪',
39+
value: 29,
40+
},
41+
{
42+
name: '绿化',
43+
value: 20,
44+
},
45+
]
46+
function getConfig() {
47+
return {
48+
data: data,
49+
rowNum: data.length,
50+
}
4751
}
4852

4953
export default () => {
54+
const [config, setConfig] = useState({})
55+
useEffect(() => {
56+
createData()
57+
getServiceRank()
58+
59+
const timer = setInterval(createData, 3000)
60+
const availabilityTimer = setInterval(getServiceRank, 60000)
61+
62+
return () => {
63+
clearInterval(timer)
64+
clearInterval(availabilityTimer)
65+
}
66+
}, [])
67+
68+
function createData() {
69+
setConfig(getConfig())
70+
}
71+
5072
return (
5173
<div id="ranking-board">
52-
<div className="ranking-board-title">巡查上报记录数量</div>
74+
<div className="ranking-board-title">近24小时服务访问次数</div>
5375
<ScrollRankingBoard config={config} />
5476
</div>
5577
)
5678
}
79+
80+
function getServiceRank() {
81+
httpGet('https://api.hduhelp.com/aggregating/metric/cdn/top').then(
82+
r =>
83+
(data = r.map(({ Name, Value }) => ({
84+
name: Name,
85+
value: Value,
86+
})))
87+
)
88+
}

src/components/datav/ScrollBoard.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/components/datav/ScrollBoard.less

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/components/datav/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import DigitalFlop from './DigitalFlop'
77
import RankingBoard from './RankingBoard'
88
import RoseChart from './RoseChart'
99
import WaterLevelChart from './WaterLevelChart'
10-
import ScrollBoard from './ScrollBoard'
1110
import Cards from './Cards'
1211

1312
import './index.less'

0 commit comments

Comments
 (0)