Skip to content

Commit bb8043c

Browse files
committed
feat: fix DashboardDetailPage crash bug on empty data
1 parent 66add47 commit bb8043c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

web/src/DashboardPage.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ class DashboardDetailPage extends React.Component {
116116

117117
getIPAddresses(rangeType) {
118118
this.getMetric("ip", rangeType).then((res) => {
119+
if (!res.data) {
120+
return;
121+
}
122+
119123
this.setState({
120124
ipAddresses: res.data.slice(0, 10),
121125
uniqueIPCount: res.data.length,
@@ -207,6 +211,10 @@ class DashboardDetailPage extends React.Component {
207211
}
208212

209213
renderPieChart(title, data) {
214+
if (data === null) {
215+
data = [];
216+
}
217+
210218
const d = data.map((item) => {
211219
return {value: item.count, name: item.data};
212220
});
@@ -234,6 +242,10 @@ class DashboardDetailPage extends React.Component {
234242
}
235243

236244
renderBarChart(title, data) {
245+
if (data === null) {
246+
data = [];
247+
}
248+
237249
return (
238250
<div className="dashboard-card" >
239251
<BarChartCard title={title} data={data} className="dashboard-card" />

0 commit comments

Comments
 (0)