From ffe2e35b6e67eb3ac18a7f7402f96fba42900486 Mon Sep 17 00:00:00 2001 From: bayang Date: Mon, 16 May 2022 11:52:44 +0200 Subject: [PATCH] fix: add loading indicator when loading stats --- src/jelu-ui/src/components/UserStats.vue | 62 ++++++++++++++++-------- 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/src/jelu-ui/src/components/UserStats.vue b/src/jelu-ui/src/components/UserStats.vue index b1e76925..f94ce037 100644 --- a/src/jelu-ui/src/components/UserStats.vue +++ b/src/jelu-ui/src/components/UserStats.vue @@ -30,6 +30,7 @@ const getYears = () => { } const getAllStats = () => { + loading.value = true dataService.yearStats() .then(res => { let labels = res.map(r => r.year) @@ -50,14 +51,17 @@ const getAllStats = () => { ] } chartData.value = { ...updatedChartData } + loading.value = false }) .catch(e => { console.log(e) + loading.value = false }) } const getYearStats = () => { if (currentYear.value != null) { + loading.value = true dataService.monthStatsForYear(currentYear.value) .then(res => { let labels = res.map(r => r.month).map(m => dayjs(`2020-${m}-1`).format('MMMM')) @@ -78,14 +82,16 @@ const getYearStats = () => { ] } yearChartData.value = { ...updatedChartData } + loading.value = false }) .catch(e => { + loading.value = false console.log(e) }) } } -const loaded = ref(false) +const loading = ref(false) const chartData = ref>({ datasets: [] }) @@ -102,6 +108,8 @@ watch(currentYear, (newVal, oldVal) => { }) +const loaderFullPage = ref(false) + getAllStats() getYears() @@ -112,38 +120,52 @@ getYears()

{{ t('stats.all_time') }}

-
+
-

+

{{ t('stats.yearly_stats') }}

-
- + + +
+