Client - add missing translations on chart + message when no workouts
This commit is contained in:
parent
795599ad46
commit
5dadbee29c
@ -9,6 +9,7 @@
|
|||||||
import ChartDataLabels from 'chartjs-plugin-datalabels'
|
import ChartDataLabels from 'chartjs-plugin-datalabels'
|
||||||
import { ComputedRef, PropType, computed, defineComponent } from 'vue'
|
import { ComputedRef, PropType, computed, defineComponent } from 'vue'
|
||||||
import { BarChart, useBarChart } from 'vue-chart-3'
|
import { BarChart, useBarChart } from 'vue-chart-3'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
|
||||||
import { IStatisticsChartDataset, TDatasetKeys } from '@/types/statistics'
|
import { IStatisticsChartDataset, TDatasetKeys } from '@/types/statistics'
|
||||||
import { formatTooltipValue } from '@/utils/tooltip'
|
import { formatTooltipValue } from '@/utils/tooltip'
|
||||||
@ -36,6 +37,7 @@
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
|
const { t } = useI18n()
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
function getNumber(value: any): number {
|
function getNumber(value: any): number {
|
||||||
return isNaN(value) ? 0 : +value
|
return isNaN(value) ? 0 : +value
|
||||||
@ -103,7 +105,7 @@
|
|||||||
},
|
},
|
||||||
callbacks: {
|
callbacks: {
|
||||||
label: function (context) {
|
label: function (context) {
|
||||||
let label = context.dataset.label || ''
|
let label = t(`sports.${context.dataset.label}.LABEL`) || ''
|
||||||
if (label) {
|
if (label) {
|
||||||
label += ': '
|
label += ': '
|
||||||
}
|
}
|
||||||
@ -120,7 +122,10 @@
|
|||||||
tooltipItems.map((tooltipItem) => {
|
tooltipItems.map((tooltipItem) => {
|
||||||
sum += tooltipItem.parsed.y
|
sum += tooltipItem.parsed.y
|
||||||
})
|
})
|
||||||
return 'Total: ' + formatTooltipValue(props.displayedData, sum)
|
return (
|
||||||
|
`${t('statistics.TOTAL')}: ` +
|
||||||
|
formatTooltipValue(props.displayedData, sum)
|
||||||
|
)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" scoped>
|
<script lang="ts">
|
||||||
import { ComputedRef, PropType, computed, defineComponent } from 'vue'
|
import { ComputedRef, PropType, computed, defineComponent } from 'vue'
|
||||||
|
|
||||||
import Chart from '@/components/Common/StatsChart/Chart.vue'
|
import Chart from '@/components/Common/StatsChart/Chart.vue'
|
||||||
@ -68,7 +68,7 @@
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss" scoped>
|
||||||
@import '~@/scss/base';
|
@import '~@/scss/base';
|
||||||
.stat-chart {
|
.stat-chart {
|
||||||
.chart {
|
.chart {
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
:user="user"
|
:user="user"
|
||||||
:key="workout.id"
|
:key="workout.id"
|
||||||
></WorkoutCard>
|
></WorkoutCard>
|
||||||
|
<Card v-if="workouts.length === 0" class="no-workouts">
|
||||||
|
<template #content>{{ t('workouts.NO_WORKOUTS') }}</template>
|
||||||
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -18,7 +21,9 @@
|
|||||||
onBeforeMount,
|
onBeforeMount,
|
||||||
PropType,
|
PropType,
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
|
||||||
|
import Card from '@/components/Common/Card.vue'
|
||||||
import WorkoutCard from '@/components/Dashboard/Timeline/WorkoutCard.vue'
|
import WorkoutCard from '@/components/Dashboard/Timeline/WorkoutCard.vue'
|
||||||
import { SPORTS_STORE, WORKOUTS_STORE } from '@/store/constants'
|
import { SPORTS_STORE, WORKOUTS_STORE } from '@/store/constants'
|
||||||
import { ISport } from '@/types/sports'
|
import { ISport } from '@/types/sports'
|
||||||
@ -29,6 +34,7 @@
|
|||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Timeline',
|
name: 'Timeline',
|
||||||
components: {
|
components: {
|
||||||
|
Card,
|
||||||
WorkoutCard,
|
WorkoutCard,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
@ -39,6 +45,7 @@
|
|||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
|
const { t } = useI18n()
|
||||||
onBeforeMount(() =>
|
onBeforeMount(() =>
|
||||||
store.dispatch(WORKOUTS_STORE.ACTIONS.GET_USER_WORKOUTS, { page: 1 })
|
store.dispatch(WORKOUTS_STORE.ACTIONS.GET_USER_WORKOUTS, { page: 1 })
|
||||||
)
|
)
|
||||||
@ -51,7 +58,15 @@
|
|||||||
() => store.getters[SPORTS_STORE.GETTERS.SPORTS]
|
() => store.getters[SPORTS_STORE.GETTERS.SPORTS]
|
||||||
)
|
)
|
||||||
|
|
||||||
return { workouts, sports }
|
return { workouts, sports, t }
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@import '~@/scss/base';
|
||||||
|
|
||||||
|
.no-workouts {
|
||||||
|
margin-bottom: $default-margin * 2;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@ -3,6 +3,10 @@
|
|||||||
<Card :without-title="false">
|
<Card :without-title="false">
|
||||||
<template #title>{{ $t('dashboard.THIS_MONTH') }}</template>
|
<template #title>{{ $t('dashboard.THIS_MONTH') }}</template>
|
||||||
<template #content>
|
<template #content>
|
||||||
|
<div v-if="Object.keys(statistics).length === 0">
|
||||||
|
{{ t('workouts.NO_WORKOUTS') }}
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
<div class="chart-radio">
|
<div class="chart-radio">
|
||||||
<label class="">
|
<label class="">
|
||||||
<input
|
<input
|
||||||
@ -39,7 +43,9 @@
|
|||||||
:sports="sports"
|
:sports="sports"
|
||||||
:week-starting-monday="weekStartingMonday"
|
:week-starting-monday="weekStartingMonday"
|
||||||
v-if="statistics && weekStartingMonday !== undefined"
|
v-if="statistics && weekStartingMonday !== undefined"
|
||||||
/></template>
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -4,6 +4,7 @@ import ButtonsTranslations from './buttons.json'
|
|||||||
import CommonTranslations from './common.json'
|
import CommonTranslations from './common.json'
|
||||||
import DashboardTranslations from './dashboard.json'
|
import DashboardTranslations from './dashboard.json'
|
||||||
import ErrorTranslations from './error.json'
|
import ErrorTranslations from './error.json'
|
||||||
|
import SportsTranslations from './sports.json'
|
||||||
import StatisticsTranslations from './statistics.json'
|
import StatisticsTranslations from './statistics.json'
|
||||||
import UserTranslations from './user.json'
|
import UserTranslations from './user.json'
|
||||||
import WorkoutsTranslations from './workouts.json'
|
import WorkoutsTranslations from './workouts.json'
|
||||||
@ -15,6 +16,7 @@ export default {
|
|||||||
common: CommonTranslations,
|
common: CommonTranslations,
|
||||||
dashboard: DashboardTranslations,
|
dashboard: DashboardTranslations,
|
||||||
error: ErrorTranslations,
|
error: ErrorTranslations,
|
||||||
|
sports: SportsTranslations,
|
||||||
statistics: StatisticsTranslations,
|
statistics: StatisticsTranslations,
|
||||||
user: UserTranslations,
|
user: UserTranslations,
|
||||||
workouts: WorkoutsTranslations,
|
workouts: WorkoutsTranslations,
|
||||||
|
20
fittrackee_client/src/locales/en/sports.json
Normal file
20
fittrackee_client/src/locales/en/sports.json
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"Cycling (Sport)": {
|
||||||
|
"LABEL": "Cycling (Sport)"
|
||||||
|
},
|
||||||
|
"Cycling (Transport)": {
|
||||||
|
"LABEL": "Cycling (Transport)"
|
||||||
|
},
|
||||||
|
"Hiking": {
|
||||||
|
"LABEL": "Hiking"
|
||||||
|
},
|
||||||
|
"Mountain Biking": {
|
||||||
|
"LABEL": "Mountain Biking"
|
||||||
|
},
|
||||||
|
"Running": {
|
||||||
|
"LABEL": "Running"
|
||||||
|
},
|
||||||
|
"Walking": {
|
||||||
|
"LABEL": "Walking"
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
{
|
{
|
||||||
"STATISTICS": "Statistics"
|
"STATISTICS": "Statistics",
|
||||||
|
"TOTAL": "Total"
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
"DISTANCE": "distance",
|
"DISTANCE": "distance",
|
||||||
"DURATION": "duration",
|
"DURATION": "duration",
|
||||||
"KM": "km",
|
"KM": "km",
|
||||||
|
"NO_WORKOUTS": "No workouts.",
|
||||||
"RECORD_AS": "Ave. speed",
|
"RECORD_AS": "Ave. speed",
|
||||||
"RECORD_FD": "Farest distance",
|
"RECORD_FD": "Farest distance",
|
||||||
"RECORD_LD": "Longest duration",
|
"RECORD_LD": "Longest duration",
|
||||||
|
@ -4,6 +4,7 @@ import ButtonsTranslations from './buttons.json'
|
|||||||
import CommonTranslations from './common.json'
|
import CommonTranslations from './common.json'
|
||||||
import DashboardTranslations from './dashboard.json'
|
import DashboardTranslations from './dashboard.json'
|
||||||
import ErrorTranslations from './error.json'
|
import ErrorTranslations from './error.json'
|
||||||
|
import SportsTranslations from './sports.json'
|
||||||
import StatisticsTranslations from './statistics.json'
|
import StatisticsTranslations from './statistics.json'
|
||||||
import UserTranslations from './user.json'
|
import UserTranslations from './user.json'
|
||||||
import WorkoutsTranslations from './workouts.json'
|
import WorkoutsTranslations from './workouts.json'
|
||||||
@ -15,6 +16,7 @@ export default {
|
|||||||
common: CommonTranslations,
|
common: CommonTranslations,
|
||||||
dashboard: DashboardTranslations,
|
dashboard: DashboardTranslations,
|
||||||
error: ErrorTranslations,
|
error: ErrorTranslations,
|
||||||
|
sports: SportsTranslations,
|
||||||
statistics: StatisticsTranslations,
|
statistics: StatisticsTranslations,
|
||||||
user: UserTranslations,
|
user: UserTranslations,
|
||||||
workouts: WorkoutsTranslations,
|
workouts: WorkoutsTranslations,
|
||||||
|
20
fittrackee_client/src/locales/fr/sports.json
Normal file
20
fittrackee_client/src/locales/fr/sports.json
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"Cycling (Sport)": {
|
||||||
|
"LABEL": "Vélo (Sport)"
|
||||||
|
},
|
||||||
|
"Cycling (Transport)": {
|
||||||
|
"LABEL": "Vélo (Transport)"
|
||||||
|
},
|
||||||
|
"Hiking": {
|
||||||
|
"LABEL": "Randonnée"
|
||||||
|
},
|
||||||
|
"Mountain Biking": {
|
||||||
|
"LABEL": "VTT"
|
||||||
|
},
|
||||||
|
"Running": {
|
||||||
|
"LABEL": "Course"
|
||||||
|
},
|
||||||
|
"Walking": {
|
||||||
|
"LABEL": "Marche"
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
{
|
{
|
||||||
"STATISTICS": "Statistiques"
|
"STATISTICS": "Statistiques",
|
||||||
|
"TOTAL": "Total"
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
"DISTANCE": "distance",
|
"DISTANCE": "distance",
|
||||||
"DURATION": "durée",
|
"DURATION": "durée",
|
||||||
"KM": "km",
|
"KM": "km",
|
||||||
|
"NO_WORKOUTS": "Pas de séances.",
|
||||||
"RECORD_AS": "Vitesse moy.",
|
"RECORD_AS": "Vitesse moy.",
|
||||||
"RECORD_FD": "Distance la + longue",
|
"RECORD_FD": "Distance la + longue",
|
||||||
"RECORD_LD": "Durée la + longue",
|
"RECORD_LD": "Durée la + longue",
|
||||||
|
Loading…
Reference in New Issue
Block a user