From f76a0f4b0e488530c1e715ecaa824fca7790dddd Mon Sep 17 00:00:00 2001 From: Eug-VS Date: Mon, 6 Jan 2020 01:53:47 +0300 Subject: Delay scoreboard update, add progress indicator Wait for the Header>Tabs>Indicator to get into place so it doesn't freeze when it comes to rendering new massive frame. --- src/components/Scoreboard/Scoreboard.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/components/Scoreboard/Scoreboard.js b/src/components/Scoreboard/Scoreboard.js index 47e306e..93ec2f0 100644 --- a/src/components/Scoreboard/Scoreboard.js +++ b/src/components/Scoreboard/Scoreboard.js @@ -6,25 +6,30 @@ import { Grid, } from "@material-ui/core"; +import { makeStyles } from "@material-ui/core/styles"; +import LinearProgress from '@material-ui/core/LinearProgress'; + import { get } from "../../requests"; import SolutionCard from "../SolutionCard/SolutionCard"; -import { makeStyles } from "@material-ui/core/styles"; const useStyles = makeStyles(theme => ({ pageHeader: { textAlign: 'center', margin: theme.spacing(2), - } + }, })); const Scoreboard = () => { const classes = useStyles(); const [solutions, setSolutions] = useState([]); - const updateSolutions = async () => { - const response = await get('solutions/'); - await setSolutions(response.data); + const updateSolutions = () => { + get('solutions/').then(response => { + setTimeout(() => { + setSolutions(response.data); + }, 250); + }); }; const removeSolution = (id) => { @@ -40,6 +45,7 @@ const Scoreboard = () => { Scoreboard + {(solutions.length === 0) && } {solutions.map(solution => ( -- cgit v1.2.3 From a12e47a66fc24a9259a79df27130230d587821c1 Mon Sep 17 00:00:00 2001 From: Eug-VS Date: Mon, 6 Jan 2020 02:30:39 +0300 Subject: Implement Loading component (circular progress) --- src/components/Loading/Loading.js | 32 ++++++++++++++++++++++++++++++++ src/components/Scoreboard/Scoreboard.js | 6 +++--- 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 src/components/Loading/Loading.js (limited to 'src') diff --git a/src/components/Loading/Loading.js b/src/components/Loading/Loading.js new file mode 100644 index 0000000..632142b --- /dev/null +++ b/src/components/Loading/Loading.js @@ -0,0 +1,32 @@ +import React from 'react'; + +import { + Card, + CardHeader, +} from "@material-ui/core"; + +import { makeStyles } from "@material-ui/core/styles"; +import CircularProgress from '@material-ui/core/CircularProgress'; + + +const useStyles = makeStyles(theme => ({ + root: { + padding: theme.spacing(1), + }, +})); + +const Loading = () => { + const classes = useStyles(); + + return ( + + )} + title="Loading" + subheader="Please, wait." + /> + + ) +}; + +export default Loading; diff --git a/src/components/Scoreboard/Scoreboard.js b/src/components/Scoreboard/Scoreboard.js index 93ec2f0..96a8543 100644 --- a/src/components/Scoreboard/Scoreboard.js +++ b/src/components/Scoreboard/Scoreboard.js @@ -7,10 +7,10 @@ import { } from "@material-ui/core"; import { makeStyles } from "@material-ui/core/styles"; -import LinearProgress from '@material-ui/core/LinearProgress'; import { get } from "../../requests"; import SolutionCard from "../SolutionCard/SolutionCard"; +import Loading from "../Loading/Loading"; const useStyles = makeStyles(theme => ({ @@ -28,7 +28,7 @@ const Scoreboard = () => { get('solutions/').then(response => { setTimeout(() => { setSolutions(response.data); - }, 250); + }, 300); }); }; @@ -45,7 +45,7 @@ const Scoreboard = () => { Scoreboard - {(solutions.length === 0) && } + {(solutions.length === 0) && } {solutions.map(solution => ( -- cgit v1.2.3 From 24e4834ba333cba4adaa79bd2af01773d5825c75 Mon Sep 17 00:00:00 2001 From: Eug-VS Date: Mon, 6 Jan 2020 02:32:57 +0300 Subject: Use appropriate API for scoreboard --- src/components/Scoreboard/Scoreboard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/components/Scoreboard/Scoreboard.js b/src/components/Scoreboard/Scoreboard.js index 96a8543..e4849ec 100644 --- a/src/components/Scoreboard/Scoreboard.js +++ b/src/components/Scoreboard/Scoreboard.js @@ -25,7 +25,7 @@ const Scoreboard = () => { const [solutions, setSolutions] = useState([]); const updateSolutions = () => { - get('solutions/').then(response => { + get('scoreboard/').then(response => { setTimeout(() => { setSolutions(response.data); }, 300); -- cgit v1.2.3 From 644bb29f796372860c57bf6c7fc8f3f5be51d1e8 Mon Sep 17 00:00:00 2001 From: Eug-VS Date: Mon, 6 Jan 2020 02:34:59 +0300 Subject: Set a scoreboard boundary of 30 SolutionCards --- src/components/Scoreboard/Scoreboard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/components/Scoreboard/Scoreboard.js b/src/components/Scoreboard/Scoreboard.js index e4849ec..c7bc6d8 100644 --- a/src/components/Scoreboard/Scoreboard.js +++ b/src/components/Scoreboard/Scoreboard.js @@ -47,7 +47,7 @@ const Scoreboard = () => { {(solutions.length === 0) && } - {solutions.map(solution => ( + {solutions.slice(0, 30).map(solution => ( -- cgit v1.2.3