Skip to content

Commit

Permalink
feat(stats): super basic stats page (#54)
Browse files Browse the repository at this point in the history
Super basic /stats page
  • Loading branch information
raphodn authored Dec 22, 2023
1 parent 48f7d12 commit 0d61870
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</v-col>
<v-col cols="12" md="6" align="center">
<v-btn class="mx-2" variant="text" href="https://prices.openfoodfacts.org" target="_blank">About</v-btn>
<v-btn class="mx-2" variant="text" to="/stats">Stats</v-btn>
<v-btn class="mx-2" variant="text" href="https://github.com/openfoodfacts/open-prices-frontend" target="_blank">Github</v-btn>
</v-col>
</v-row>
Expand Down
2 changes: 2 additions & 0 deletions src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import SignIn from './views/SignIn.vue'
import AddPriceHome from './views/AddPriceHome.vue'
import AddPriceSingle from './views/AddPriceSingle.vue'
import PriceList from './views/PriceList.vue'
import Stats from './views/Stats.vue'
import NotFound from './views/NotFound.vue'

/** @type {import('vue-router').RouterOptions['routes']} */
Expand All @@ -12,5 +13,6 @@ export let routes = [
{ path: '/add', name: 'add-price', component: AddPriceHome, meta: { title: 'Add a price', icon: 'mdi-plus', drawerMenu: true, requiresAuth: true }},
{ path: '/add/single', name: 'add-price-single', component: AddPriceSingle, meta: { title: 'Add a single price', requiresAuth: true }},
{ path: '/prices', name: 'prices', component: PriceList, meta: { title: 'Last prices', icon: 'mdi-tag-multiple-outline', drawerMenu: true }},
{ path: '/stats', name: 'stats', component: Stats, meta: { title: 'Stats' }},
{ path: '/:path(.*)', component: NotFound },
]
38 changes: 38 additions & 0 deletions src/views/Stats.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<template>
<h1 class="mb-1">
Stats
<v-progress-circular v-if="loading" indeterminate :size="30"></v-progress-circular>
</h1>

<v-row>
<v-col cols="12" md="6" lg="4">
<v-card title="Price count" :text="priceCount"></v-card>
</v-col>
</v-row>
</template>

<script>
import api from '../services/api'
export default {
data() {
return {
priceCount: null,
loading: false,
}
},
mounted() {
this.getPrices()
},
methods: {
getPrices() {
this.loading = true
return api.getPrices()
.then((data) => {
this.priceCount = data.total
this.loading = false
})
}
}
}
</script>

0 comments on commit 0d61870

Please sign in to comment.