2021-09-20 12:18:40 +02:00
|
|
|
<template>
|
|
|
|
<div class="timeline-workout">
|
2021-10-05 19:02:08 +02:00
|
|
|
<div class="box">
|
|
|
|
<div class="workout-user-date">
|
|
|
|
<div class="workout-user">
|
2021-11-01 20:48:22 +01:00
|
|
|
<UserPicture :user="user" />
|
2021-11-01 17:45:43 +01:00
|
|
|
<router-link
|
|
|
|
v-if="user.username"
|
|
|
|
class="workout-user-name"
|
|
|
|
:to="{
|
|
|
|
name: 'User',
|
|
|
|
params: { username: user.username },
|
|
|
|
}"
|
|
|
|
>
|
2021-10-05 19:02:08 +02:00
|
|
|
{{ user.username }}
|
2021-11-01 17:45:43 +01:00
|
|
|
</router-link>
|
2021-09-20 12:18:40 +02:00
|
|
|
</div>
|
2021-11-01 17:45:43 +01:00
|
|
|
<router-link
|
|
|
|
class="workout-title"
|
2021-11-10 21:19:27 +01:00
|
|
|
v-if="workout.id"
|
2021-11-01 17:45:43 +01:00
|
|
|
:to="{
|
|
|
|
name: 'Workout',
|
|
|
|
params: { workoutId: workout.id },
|
|
|
|
}"
|
|
|
|
>
|
|
|
|
{{ workout.title }}
|
|
|
|
</router-link>
|
2021-09-24 15:01:59 +02:00
|
|
|
<div
|
2021-10-05 19:02:08 +02:00
|
|
|
class="workout-date"
|
2021-11-10 21:19:27 +01:00
|
|
|
v-if="workout.workout_date && user"
|
2021-10-05 19:02:08 +02:00
|
|
|
:title="
|
|
|
|
format(
|
|
|
|
getDateWithTZ(workout.workout_date, user.timezone),
|
|
|
|
'dd/MM/yyyy HH:mm'
|
|
|
|
)
|
2021-09-24 15:01:59 +02:00
|
|
|
"
|
|
|
|
>
|
2021-10-05 19:02:08 +02:00
|
|
|
{{
|
|
|
|
formatDistance(new Date(workout.workout_date), new Date(), {
|
|
|
|
addSuffix: true,
|
|
|
|
locale,
|
|
|
|
})
|
|
|
|
}}
|
2021-09-20 12:18:40 +02:00
|
|
|
</div>
|
2021-10-05 19:02:08 +02:00
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
class="workout-map"
|
|
|
|
:class="{ 'no-cursor': !workout }"
|
|
|
|
@click="
|
2021-11-10 21:19:27 +01:00
|
|
|
workout.id
|
2021-10-05 19:02:08 +02:00
|
|
|
? $router.push({
|
|
|
|
name: 'Workout',
|
|
|
|
params: { workoutId: workout.id },
|
|
|
|
})
|
|
|
|
: null
|
|
|
|
"
|
|
|
|
>
|
|
|
|
<div v-if="workout">
|
|
|
|
<StaticMap v-if="workout.with_gpx" :workout="workout" />
|
|
|
|
<div v-else class="no-map">
|
2021-10-20 17:38:25 +02:00
|
|
|
{{ $t('workouts.NO_MAP') }}
|
2021-09-20 12:18:40 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-10-05 19:02:08 +02:00
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
class="workout-data"
|
2021-11-03 19:59:13 +01:00
|
|
|
:class="{ 'without-gpx': workout && !workout.with_gpx }"
|
2021-10-05 19:02:08 +02:00
|
|
|
@click="
|
2021-11-10 21:19:27 +01:00
|
|
|
workout.id
|
|
|
|
? $router.push({
|
|
|
|
name: 'Workout',
|
|
|
|
params: { workoutId: workout.id },
|
|
|
|
})
|
|
|
|
: null
|
2021-10-05 19:02:08 +02:00
|
|
|
"
|
|
|
|
>
|
2021-11-03 19:59:13 +01:00
|
|
|
<div class="img">
|
2021-11-12 18:52:08 +01:00
|
|
|
<SportImage
|
|
|
|
v-if="sport.label"
|
|
|
|
:sport-label="sport.label"
|
|
|
|
:color="sport.color"
|
|
|
|
/>
|
2021-10-05 19:02:08 +02:00
|
|
|
</div>
|
2021-11-03 19:59:13 +01:00
|
|
|
<div class="data">
|
2021-10-05 19:02:08 +02:00
|
|
|
<i class="fa fa-clock-o" aria-hidden="true" />
|
|
|
|
<span v-if="workout">{{ workout.moving }}</span>
|
|
|
|
</div>
|
2021-11-03 19:59:13 +01:00
|
|
|
<div class="data">
|
2021-10-05 19:02:08 +02:00
|
|
|
<i class="fa fa-road" aria-hidden="true" />
|
|
|
|
<span v-if="workout">{{ workout.distance }} km</span>
|
|
|
|
</div>
|
2021-11-03 19:59:13 +01:00
|
|
|
<div class="data elevation" v-if="workout && workout.with_gpx">
|
|
|
|
<img
|
|
|
|
class="mountains"
|
|
|
|
src="/img/workouts/mountains.svg"
|
|
|
|
:alt="$t('workouts.ELEVATION')"
|
|
|
|
/>
|
2021-11-06 18:08:32 +01:00
|
|
|
<div class="data-values">
|
|
|
|
<span>{{ workout.min_alt }}/</span>
|
|
|
|
<span>{{ workout.max_alt }} m </span>
|
|
|
|
</div>
|
2021-11-03 19:59:13 +01:00
|
|
|
</div>
|
|
|
|
<div class="data altitude" v-if="workout && workout.with_gpx">
|
|
|
|
<i class="fa fa-location-arrow" aria-hidden="true" />
|
2021-11-06 18:08:32 +01:00
|
|
|
<div class="data-values">
|
|
|
|
<span>+ {{ workout.ascent }}/</span>
|
|
|
|
<span>- {{ workout.descent }} m </span>
|
|
|
|
</div>
|
2021-11-03 19:59:13 +01:00
|
|
|
</div>
|
2021-10-05 19:02:08 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-09-20 12:18:40 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2021-11-10 21:19:27 +01:00
|
|
|
<script setup lang="ts">
|
2021-09-20 12:18:40 +02:00
|
|
|
import { Locale, format, formatDistance } from 'date-fns'
|
2021-11-10 21:19:27 +01:00
|
|
|
import { ComputedRef, computed, toRefs, withDefaults } from 'vue'
|
2021-09-20 12:18:40 +02:00
|
|
|
|
|
|
|
import StaticMap from '@/components/Common/StaticMap.vue'
|
2021-11-01 20:48:22 +01:00
|
|
|
import UserPicture from '@/components/User/UserPicture.vue'
|
2021-09-20 12:18:40 +02:00
|
|
|
import { ROOT_STORE } from '@/store/constants'
|
|
|
|
import { ISport } from '@/types/sports'
|
2021-10-30 12:01:55 +02:00
|
|
|
import { IUserProfile } from '@/types/user'
|
2021-09-20 12:18:40 +02:00
|
|
|
import { IWorkout } from '@/types/workouts'
|
|
|
|
import { useStore } from '@/use/useStore'
|
|
|
|
import { getDateWithTZ } from '@/utils/dates'
|
|
|
|
|
2021-11-10 21:19:27 +01:00
|
|
|
interface Props {
|
|
|
|
user: IUserProfile
|
|
|
|
workout?: IWorkout
|
|
|
|
sport?: ISport
|
|
|
|
}
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
|
|
|
workout: () => ({} as IWorkout),
|
|
|
|
sport: () => ({} as ISport),
|
2021-09-20 12:18:40 +02:00
|
|
|
})
|
2021-11-10 21:19:27 +01:00
|
|
|
|
|
|
|
const store = useStore()
|
|
|
|
|
|
|
|
const { user, workout, sport } = toRefs(props)
|
|
|
|
const locale: ComputedRef<Locale> = computed(
|
|
|
|
() => store.getters[ROOT_STORE.GETTERS.LOCALE]
|
|
|
|
)
|
2021-09-20 12:18:40 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import '~@/scss/base';
|
|
|
|
|
2021-11-03 19:59:13 +01:00
|
|
|
.mountains {
|
|
|
|
padding-right: $default-padding * 0.5;
|
|
|
|
}
|
|
|
|
|
2021-09-20 12:18:40 +02:00
|
|
|
.timeline-workout {
|
|
|
|
margin-bottom: $default-margin * 2;
|
|
|
|
|
2021-10-05 19:02:08 +02:00
|
|
|
.box {
|
|
|
|
flex-direction: column;
|
|
|
|
padding: 0;
|
|
|
|
.workout-user-date {
|
2021-09-20 12:18:40 +02:00
|
|
|
display: flex;
|
2021-10-05 19:02:08 +02:00
|
|
|
justify-content: space-between;
|
|
|
|
padding: $default-padding * 0.5 $default-padding;
|
|
|
|
.workout-user {
|
2021-09-20 12:18:40 +02:00
|
|
|
display: flex;
|
2021-11-01 20:48:22 +01:00
|
|
|
::v-deep(.user-picture) {
|
|
|
|
img {
|
|
|
|
height: 25px;
|
|
|
|
width: 25px;
|
|
|
|
}
|
|
|
|
.no-picture {
|
|
|
|
font-size: 1.5em;
|
|
|
|
}
|
2021-09-27 15:34:36 +02:00
|
|
|
}
|
2021-10-05 19:02:08 +02:00
|
|
|
.workout-user-name {
|
|
|
|
padding-left: 5px;
|
2021-09-27 15:34:36 +02:00
|
|
|
}
|
|
|
|
}
|
2021-10-05 19:02:08 +02:00
|
|
|
.workout-date {
|
|
|
|
font-size: 0.85em;
|
|
|
|
font-style: italic;
|
|
|
|
}
|
2021-11-03 11:12:53 +01:00
|
|
|
.workout-title {
|
|
|
|
display: block;
|
|
|
|
padding: 0 $default-padding;
|
|
|
|
@media screen and (max-width: $x-small-limit) {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
2021-10-05 19:02:08 +02:00
|
|
|
}
|
2021-09-27 15:34:36 +02:00
|
|
|
|
2021-10-05 19:02:08 +02:00
|
|
|
.workout-map {
|
|
|
|
background-color: var(--workout-no-map-bg-color);
|
|
|
|
height: 150px;
|
|
|
|
.no-map {
|
|
|
|
line-height: 150px;
|
2021-09-20 12:18:40 +02:00
|
|
|
}
|
2021-10-05 19:02:08 +02:00
|
|
|
::v-deep(.bg-map-image) {
|
|
|
|
height: 150px;
|
2021-09-24 15:01:59 +02:00
|
|
|
}
|
2021-10-05 19:02:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.workout-data {
|
|
|
|
display: flex;
|
2021-10-13 09:38:52 +02:00
|
|
|
padding: $default-padding * 0.5;
|
|
|
|
font-size: 0.9em;
|
2021-10-05 19:02:08 +02:00
|
|
|
.sport-img {
|
2021-10-13 09:38:52 +02:00
|
|
|
height: 25px;
|
|
|
|
width: 25px;
|
2021-09-27 15:34:36 +02:00
|
|
|
}
|
2021-11-03 19:59:13 +01:00
|
|
|
.img,
|
|
|
|
.data {
|
2021-10-05 19:02:08 +02:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2021-11-06 18:08:32 +01:00
|
|
|
.data-values {
|
|
|
|
display: flex;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
}
|
2021-11-03 19:59:13 +01:00
|
|
|
}
|
|
|
|
.img {
|
|
|
|
justify-content: flex-end;
|
|
|
|
width: 10%;
|
|
|
|
}
|
|
|
|
.data {
|
|
|
|
justify-content: center;
|
|
|
|
width: 22%;
|
|
|
|
}
|
|
|
|
@media screen and (max-width: $x-small-limit) {
|
|
|
|
.img {
|
|
|
|
justify-content: center;
|
|
|
|
width: 20%;
|
|
|
|
}
|
|
|
|
.data {
|
|
|
|
justify-content: center;
|
|
|
|
width: 40%;
|
|
|
|
}
|
|
|
|
.altitude,
|
|
|
|
.elevation {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.without-gpx {
|
|
|
|
.img,
|
|
|
|
.data {
|
|
|
|
justify-content: center;
|
|
|
|
width: 33%;
|
|
|
|
}
|
2021-09-27 15:34:36 +02:00
|
|
|
}
|
2021-09-20 12:18:40 +02:00
|
|
|
}
|
2021-10-05 19:02:08 +02:00
|
|
|
|
|
|
|
.workout-map,
|
|
|
|
.workout-data {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
.no-cursor {
|
|
|
|
cursor: default;
|
|
|
|
}
|
|
|
|
.fa {
|
|
|
|
padding-right: $default-padding;
|
|
|
|
}
|
2021-09-20 12:18:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|