diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bbfb430f..f9a0f52d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,7 @@ stages: - bundle variables: - VERSION: 0.0.3 + VERSION: 0.0.4 build-go: image: golang:1.16.2 diff --git a/internal/goscrobble/stats.go b/internal/goscrobble/stats.go index 94524ef7..a4e3a287 100644 --- a/internal/goscrobble/stats.go +++ b/internal/goscrobble/stats.go @@ -10,7 +10,7 @@ import ( type StatsRequest struct { Users int `json:"users"` Scrobbles int `json:"scrobbles"` - Tracks int `json:"songs"` + Tracks int `json:"tracks"` Artists int `json:"artists"` LastUpdated time.Time `json:"last_updated"` } diff --git a/web/src/Actions/api.js b/web/src/Actions/api.js index 572e9126..b2deb75d 100644 --- a/web/src/Actions/api.js +++ b/web/src/Actions/api.js @@ -1,28 +1,9 @@ -import { toast } from 'react-toastify'; import ApiService from "../Services/api.service"; -export const getStats = () => () => { +export const getStats = () => { return ApiService.getStats().then( (data) => { - console.log(data); - if (data.error) { - toast.error(data.error) - return Promise.reject(); - } - - return Promise.resolve(); - }, - (error) => { - const message = - (error.response && - error.response.data && - error.response.data.message) || - error.message || - error.toString(); - console.log(message); - - toast.error(message); - return Promise.reject(); + return data.data; } ); }; diff --git a/web/src/Components/HomeBanner.css b/web/src/Components/HomeBanner.css index e69de29b..cbed0d78 100644 --- a/web/src/Components/HomeBanner.css +++ b/web/src/Components/HomeBanner.css @@ -0,0 +1,14 @@ +.homeBanner { + margin-top: 30px; + width: 100%; +} + +.homeBannerItem { + float: left; + text-align: center; + width: 25%; +} + +.homeBannerItemCount { + font-size: 22pt; +} \ No newline at end of file diff --git a/web/src/Components/HomeBanner.js b/web/src/Components/HomeBanner.js index 39f751df..00fa4886 100644 --- a/web/src/Components/HomeBanner.js +++ b/web/src/Components/HomeBanner.js @@ -2,6 +2,7 @@ import React from 'react'; import '../App.css'; import './HomeBanner.css'; import { getStats } from '../Actions/api'; +import ClipLoader from 'react-spinners/ClipLoader' class HomeBanner extends React.Component { constructor(props) { @@ -17,25 +18,45 @@ class HomeBanner extends React.Component { componentDidMount() { getStats() - // .then((data) => { - // this.setState({ - // loading: false, - // userCount: data.users, - // scrobbleCount: data.scrobbles, - // trackCount: data.tracks, - // artistCount: data.artists, - // }); - // }) - // .catch(() => { - // this.setState({ - // loading: false - // }); - // }); + .then((data) => { + this.setState({ + isLoading: false, + userCount: data.users, + scrobbleCount: data.scrobbles, + trackCount: data.tracks, + artistCount: data.artists, + }); + }) + .catch(() => { + this.setState({ + isLoading: false + }); + }); } render() { return ( -
+
+
+ {this.state.isLoading + ? + : {this.state.scrobbleCount}}
Scrobbles +
+
+ {this.state.isLoading + ? + : {this.state.userCount}}
Users +
+
+ {this.state.isLoading + ? + : {this.state.trackCount}}
Tracks +
+
+ {this.state.isLoading + ? + : {this.state.artistCount}}
Artists +
); } diff --git a/web/src/Services/api.service.js b/web/src/Services/api.service.js index 35887fe0..65dd6931 100644 --- a/web/src/Services/api.service.js +++ b/web/src/Services/api.service.js @@ -2,11 +2,7 @@ import axios from "axios"; class ApiService { async getStats() { - return axios.get(process.env.REACT_APP_API_URL + "stats") - .then((response) => { - return response.data; - } - ); + return axios.get(process.env.REACT_APP_API_URL + "stats"); } }