Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spinner while loading data #346

Merged
merged 3 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/Graph/Download.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react'
import { Divider } from 'antd'
import { Divider, Spin } from 'antd'
import { api } from '../api'
import { formatNum } from '../utils'
import BarChart from './BarChart.js'
Expand Down Expand Up @@ -40,7 +40,15 @@ export default class DownloadTotal extends Component {

render () {
const { data, totalPieChartData } = this.state
if (!data) return null

if (!data) {
return (
<Spin tip='Loading' size='large'>
<div className='content' />
</Spin>
)
}

const total = formatNum(data.total_downloads.total)

return (
Expand Down
10 changes: 8 additions & 2 deletions src/Graph/Trends.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { get } from '../utils'
import LineChart from './LineChart'
import BarChart from './BarChart'
import moment from 'moment'
import { Radio, Slider, Checkbox } from 'antd'
import { Radio, Slider, Checkbox, Spin } from 'antd'
import './Trends.css'

const TypeFilter = ({ defaultValue, onChange, options }) => (
Expand Down Expand Up @@ -237,7 +237,13 @@ export default class Trends extends Component {
render () {
const state = this.state

if (!state.series || !state.series2 || !state.monthlyData) return null
if (!state.series || !state.series2 || !state.monthlyData) {
return (
<Spin tip='Loading' size='large'>
<div className='content' />
</Spin>
)
}

return (
<>
Expand Down