Skip to content

Commit

Permalink
Add loadng spinner to dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Nov 6, 2018
1 parent 0871752 commit 6d96986
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions frontend/my/src/Dashboard.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import { Col, Row, notification, Card, Tooltip, Icon } from "antd"
import { Col, Row, notification, Card, Tooltip, Icon, Spin } from "antd"
import React from "react";
import { Chart, Axis, Geom, Tooltip as BizTooltip } from 'bizcharts';

import * as cs from "./constants"

class Dashboard extends React.PureComponent {
state = {
stats: null
stats: null,
loading: true
}

campaignTypes = ["running", "finished", "paused", "draft", "scheduled", "cancelled"]

componentDidMount = () => {
this.props.pageTitle("Dashboard")

this.props.request(cs.Routes.GetDashboarcStats, cs.MethodGet).then((resp) => {
this.setState({ stats: resp.data.data })
this.setState({ stats: resp.data.data, loading: false })
}).catch(e => {
notification["error"]({ message: "Error", description: e.message })
this.setState({ loading: false })
})
}

Expand All @@ -30,6 +31,7 @@ class Dashboard extends React.PureComponent {
<section className = "dashboard">
<h1>Welcome</h1>
<hr />
<Spin spinning={ this.state.loading }>
{ this.state.stats &&
<div className="stats">
<Row>
Expand Down Expand Up @@ -120,6 +122,7 @@ class Dashboard extends React.PureComponent {
</Row>
</div>
}
</Spin>
</section>
);
}
Expand Down

0 comments on commit 6d96986

Please sign in to comment.