From 1c6b70d454c2444cd9bb70f9480f44b3e6f397f8 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 14 Nov 2021 12:12:21 +0100 Subject: [PATCH] Client - display converted distance/speed in workouts (wip) --- .../src/components/Common/Distance.vue | 55 ++++ .../src/components/Dashboard/Timeline.vue | 2 + .../Dashboard/UserRecords/index.vue | 4 +- .../Dashboard/UserStatsCards/index.vue | 15 +- .../src/components/Workout/WorkoutCard.vue | 41 ++- .../Workout/WorkoutDetail/WorkoutData.vue | 60 ++++- .../Workout/WorkoutDetail/index.vue | 7 +- .../components/Workout/WorkoutSegments.vue | 12 +- .../src/components/Workouts/WorkoutsList.vue | 34 ++- fittrackee_client/src/custom-components.ts | 2 + fittrackee_client/src/types/units.ts | 1 + fittrackee_client/src/utils/records.ts | 25 +- fittrackee_client/src/utils/units.ts | 4 + .../src/views/workouts/Workout.vue | 1 + .../tests/unit/utils/records.spec.ts | 244 +++++++++++++++++- 15 files changed, 467 insertions(+), 40 deletions(-) create mode 100644 fittrackee_client/src/components/Common/Distance.vue diff --git a/fittrackee_client/src/components/Common/Distance.vue b/fittrackee_client/src/components/Common/Distance.vue new file mode 100644 index 00000000..54e50e48 --- /dev/null +++ b/fittrackee_client/src/components/Common/Distance.vue @@ -0,0 +1,55 @@ + + + + + diff --git a/fittrackee_client/src/components/Dashboard/Timeline.vue b/fittrackee_client/src/components/Dashboard/Timeline.vue index dab4b582..1109c80e 100644 --- a/fittrackee_client/src/components/Dashboard/Timeline.vue +++ b/fittrackee_client/src/components/Dashboard/Timeline.vue @@ -5,6 +5,7 @@ @@ -18,6 +19,7 @@ : null " :user="user" + :useImperialUnits="user.imperial_units" :key="workout.id" /> diff --git a/fittrackee_client/src/components/Dashboard/UserRecords/index.vue b/fittrackee_client/src/components/Dashboard/UserRecords/index.vue index f8bee650..015dc312 100644 --- a/fittrackee_client/src/components/Dashboard/UserRecords/index.vue +++ b/fittrackee_client/src/components/Dashboard/UserRecords/index.vue @@ -13,6 +13,7 @@ :sportTranslatedLabel="sportTranslatedLabel" :records="recordsBySport[sportTranslatedLabel]" :key="sportTranslatedLabel" + :useImperialUnits="user.imperial_units" /> @@ -40,7 +41,8 @@ getRecordsBySports( props.user.records, translateSports(props.sports, t), - props.user.timezone + props.user.timezone, + props.user.imperial_units ) ) diff --git a/fittrackee_client/src/components/Dashboard/UserStatsCards/index.vue b/fittrackee_client/src/components/Dashboard/UserStatsCards/index.vue index c655223a..6fabf6cc 100644 --- a/fittrackee_client/src/components/Dashboard/UserStatsCards/index.vue +++ b/fittrackee_client/src/components/Dashboard/UserStatsCards/index.vue @@ -5,11 +5,7 @@ :value="user.nb_workouts" :text="$t('workouts.WORKOUT', user.nb_workouts)" /> - + props.user.total_duration ) const totalDuration = computed(() => get_duration(userTotalDuration)) + const defaultUnitFrom: TUnit = 'km' + const unitTo: TUnit = user.value.imperial_units + ? units[defaultUnitFrom].defaultTarget + : defaultUnitFrom + const totalDistance = user.value.imperial_units + ? convertDistance(user.value.total_distance, defaultUnitFrom, unitTo, 2) + : user.value.total_distance function get_duration(total_duration: ComputedRef) { const duration = total_duration.value.match(/day/g) diff --git a/fittrackee_client/src/components/Workout/WorkoutCard.vue b/fittrackee_client/src/components/Workout/WorkoutCard.vue index 628349bd..2bb0bafe 100644 --- a/fittrackee_client/src/components/Workout/WorkoutCard.vue +++ b/fittrackee_client/src/components/Workout/WorkoutCard.vue @@ -87,7 +87,13 @@