fix some bgus
Gitea Actions Demo / build_and_push (push) Successful in 1m9s Details

This commit is contained in:
artem 2024-12-31 10:38:39 +03:00
parent b1a3e481f9
commit 0e91273725
7 changed files with 80 additions and 21 deletions

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="profile-dropdown-wrapper"> <div class="profile-dropdown-wrapper" v-if="isAuth">
<VaDropdown <VaDropdown
v-model="isShown" v-model="isShown"
:offset="[9, 0]" :offset="[9, 0]"
@ -44,6 +44,9 @@
</VaDropdownContent> </VaDropdownContent>
</VaDropdown> </VaDropdown>
</div> </div>
<div class="profile-dropdown-link" v-else>
<RouterLink to="/auth">Войти</RouterLink>
</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -57,7 +60,7 @@ const store = useUserStore();
const hoverColor = computed(() => setHSLAColor(colors.focus, { a: 0.1 })); const hoverColor = computed(() => setHSLAColor(colors.focus, { a: 0.1 }));
const { t } = useI18n(); const { t } = useI18n();
const isAuth = true ? localStorage.getItem('token') : false;
type ProfileListItem = { type ProfileListItem = {
name: string; name: string;
to?: string; to?: string;
@ -136,6 +139,15 @@ const resolveLinkAttribute = (item: ProfileListItem) => {
</script> </script>
<style lang="scss"> <style lang="scss">
.profile-dropdown-link {
a {
padding: 0 5px 0 0;
color: var(--va-primary);
font-weight: 600;
text-decoration: none;
}
}
.profile-dropdown { .profile-dropdown {
cursor: pointer; cursor: pointer;

View File

@ -103,4 +103,13 @@ if (import.meta.env.VITE_APP_GTM_ENABLED) {
); );
} }
if (localStorage.getItem('token')) {
axiosAuth.get("/api/v0/auth/check")
.then((response: AxiosResponse) => {
console.debug("authAuthenticated")
}).catch((error: any) => {
localStorage.clear();
});
}
app.mount("#app"); app.mount("#app");

View File

@ -32,6 +32,7 @@
latitude: number; latitude: number;
longitude: number; longitude: number;
is_public: boolean; is_public: boolean;
workouted_at: string;
external_links?: WorkoutLink; external_links?: WorkoutLink;
} }
export const secondsToDuration = (seconds: number) => { export const secondsToDuration = (seconds: number) => {
@ -40,6 +41,21 @@
return `${hours} ч. ${minutes} мин.`; return `${hours} ч. ${minutes} мин.`;
} }
export const formatTime = (isoString: string): string => {
const date = new Date(isoString);
if (Number.isNaN(date.valueOf())) {
throw new Error('Invalid date string');
}
const day = date.getDate();
const month = date.getMonth() + 1; // Months are 0-based
const year = date.getFullYear();
return `${pad(day)}.${pad(month)}.${year}`;
}
const pad = (n: number): string => {
return `${Math.floor(Math.abs(n))}`.padStart(2, '0');
}
export const distConvert = (speed: number) => { export const distConvert = (speed: number) => {
return Math.round(speed/1000) return Math.round(speed/1000)
} }

View File

@ -10,6 +10,7 @@
<h3>{{ item.name }}</h3> <h3>{{ item.name }}</h3>
</div> </div>
<ul class="metadata"> <ul class="metadata">
<li v-if="item.workouted_at"><span>Дата:</span> {{ formatTime(item.workouted_at) }}</li>
<li v-if="item.speed"><span>Скорость:</span> {{ speedConvert(item.speed) }} км/ч</li> <li v-if="item.speed"><span>Скорость:</span> {{ speedConvert(item.speed) }} км/ч</li>
<li v-if="item.heart_rate"><span>Пульс:</span> {{ item.heart_rate }} уд /мин</li> <li v-if="item.heart_rate"><span>Пульс:</span> {{ item.heart_rate }} уд /мин</li>
<li v-if="item.cadence"><span>Каденс:</span> {{ item.cadence }} об/мин</li> <li v-if="item.cadence"><span>Каденс:</span> {{ item.cadence }} об/мин</li>
@ -32,7 +33,7 @@
import { ref, inject } from 'vue'; import { ref, inject } from 'vue';
import { useToast } from "vuestic-ui/web-components"; import { useToast } from "vuestic-ui/web-components";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { WorkoutItem, secondsToDuration, distConvert, speedConvert } from "./Definitions.vue"; import { WorkoutItem, secondsToDuration, distConvert, formatTime, speedConvert } from "./Definitions.vue";
const { push } = useRouter(); const { push } = useRouter();

View File

@ -30,6 +30,10 @@
<h3>{{ workoutItem.name }}</h3> <h3>{{ workoutItem.name }}</h3>
<VaIcon name="edit" @click="showModalTitle = !showModalTitle"/> <VaIcon name="edit" @click="showModalTitle = !showModalTitle"/>
</div> </div>
<div class="workout-item-params" v-if="workoutItem.workouted_at">
<div class="workout-item-params-name">Дата:</div>
<div class="workout-item-params-value">{{ formatTime(workoutItem.workouted_at) }}</div>
</div>
<div class="workout-item-params" v-if="workoutItem.power"> <div class="workout-item-params" v-if="workoutItem.power">
<div class="workout-item-params-name">Средняя мощность:</div> <div class="workout-item-params-name">Средняя мощность:</div>
<div class="workout-item-params-value">{{ Math.floor(workoutItem.power) }} Вт</div> <div class="workout-item-params-value">{{ Math.floor(workoutItem.power) }} Вт</div>
@ -138,7 +142,7 @@ import {
import LineWithLineChart from './components/LineWithLineChart.js' import LineWithLineChart from './components/LineWithLineChart.js'
import type { YMap } from '@yandex/ymaps3-types'; import type { YMap } from '@yandex/ymaps3-types';
import { YandexMap, YandexMapDefaultSchemeLayer, YandexMapFeature, YandexMapDefaultFeaturesLayer, YandexMapDefaultMarker } from 'vue-yandex-maps'; import { YandexMap, YandexMapDefaultSchemeLayer, YandexMapFeature, YandexMapDefaultFeaturesLayer, YandexMapDefaultMarker } from 'vue-yandex-maps';
import { WorkoutItem, distConvert, speedConvert, WorkoutLink } from "./Definitions.vue"; import { WorkoutItem, distConvert, speedConvert, formatTime } from "./Definitions.vue";
//Можно использовать для различных преобразований //Можно использовать для различных преобразований
@ -227,19 +231,24 @@ const chartOptions = {
displayColors: false, displayColors: false,
callbacks: { callbacks: {
label: function (context: any) { label: function (context: any) {
console.log(data.value.datasets)
currentCoordinates.value = lineCoordinates.value[context.dataIndex]; currentCoordinates.value = lineCoordinates.value[context.dataIndex];
let show_data = []; let show_data = [];
if (data.value.datasets[0].data[context.dataIndex]) { for (let i = 0; i < data.value.datasets.length; i++) {
show_data.push("Скорость: " + Math.floor(data.value.datasets[0].data[context.dataIndex])); let value = data.value.datasets[i].label + " :" + Math.floor(data.value.datasets[i].data[context.dataIndex])
} if (data.value.datasets[i].label == "Скорость") {
if (data.value.datasets[1].data[context.dataIndex]) { value = value + " км/ч";
show_data.push("Пульс: " + data.value.datasets[1].data[context.dataIndex]); }
} if (data.value.datasets[i].label == "Пульс") {
if (data.value.datasets[2].data[context.dataIndex]) { value = value + " уд/мин";
show_data.push("Мощность: " + data.value.datasets[2].data[context.dataIndex]); }
} if (data.value.datasets[i].label == "Мощность") {
if (Math.floor(data.value.datasets[3].data[context.dataIndex])) { value = value + " Ватт";
show_data.push("Подъем: " + Math.floor(data.value.datasets[3].data[context.dataIndex])); }
if (data.value.datasets[i].label == "Подъем") {
value = value + " м";
}
show_data.push(value);
} }
return show_data; return show_data;
} }
@ -281,6 +290,13 @@ const saveLink = (hide: any) => {
}); });
}; };
const saveName = (hide: any) => { const saveName = (hide: any) => {
if (workoutItem.value?.name.length == 0) {
init({
message: "Название не может быть пустым",
color: "error",
});
return;
}
axiosAuth axiosAuth
.patch(`/api/v0/workouts/${workoutItem.value?.id}`,{ name: workoutItem.value?.name }) .patch(`/api/v0/workouts/${workoutItem.value?.id}`,{ name: workoutItem.value?.name })
.then((response: AxiosResponse) => { .then((response: AxiosResponse) => {
@ -341,16 +357,16 @@ const initWorkout = (id: string) => {
lineCoordinates.value = coords lineCoordinates.value = coords
mapCenter.value = [coords[0][0], coords[0][1]]; mapCenter.value = [coords[0][0], coords[0][1]];
let datasets = []; let datasets = [];
if (speed) { if (speed.length > 0) {
datasets.push({ radius: 0, label: 'Скорость', borderColor: '#00aa00', backgroundColor: '#00aa00', data: speed }); datasets.push({ radius: 0, label: 'Скорость', borderColor: '#00aa00', backgroundColor: '#00aa00', data: speed });
} }
if (heart_rate) { if (heart_rate.length > 0) {
datasets.push({ radius: 0, label: 'Пульс', borderColor: '#990000', backgroundColor: '#990000', data: heart_rate, }); datasets.push({ radius: 0, label: 'Пульс', borderColor: '#990000', backgroundColor: '#990000', data: heart_rate, });
} }
if (power) { if (power.length > 0) {
datasets.push({ radius: 0, label: 'Мощность', borderColor: '#cccccc', backgroundColor: '#cccccc', data: power, }); datasets.push({ radius: 0, label: 'Мощность', borderColor: '#cccccc', backgroundColor: '#cccccc', data: power, });
} }
if (elevation) { if (elevation.length > 0) {
datasets.push( { radius: 0, label: 'Подъем', borderColor: '#000', backgroundColor: '#000', data: elevation, }); datasets.push( { radius: 0, label: 'Подъем', borderColor: '#000', backgroundColor: '#000', data: elevation, });
} }
data.value = { data.value = {

View File

@ -13,6 +13,7 @@
<VaIcon name="delete_forever" size="22px" color="#bbc1c3" class="news-item-icon" @click="(event: any) => deleteItem(item.id, event)"/> <VaIcon name="delete_forever" size="22px" color="#bbc1c3" class="news-item-icon" @click="(event: any) => deleteItem(item.id, event)"/>
</div> </div>
<ul class="metadata"> <ul class="metadata">
<li v-if="item.workouted_at"><span>Дата:</span> {{ formatTime(item.workouted_at) }}</li>
<li v-if="item.speed"><span>Скорость:</span> {{ speedConvert(item.speed) }} км/ч</li> <li v-if="item.speed"><span>Скорость:</span> {{ speedConvert(item.speed) }} км/ч</li>
<li v-if="item.heart_rate"><span>Пульс:</span> {{ item.heart_rate }} уд /мин</li> <li v-if="item.heart_rate"><span>Пульс:</span> {{ item.heart_rate }} уд /мин</li>
<li v-if="item.cadence"><span>Каденс:</span> {{ item.cadence }} об/мин</li> <li v-if="item.cadence"><span>Каденс:</span> {{ item.cadence }} об/мин</li>
@ -35,7 +36,7 @@ import { AxiosResponse, AxiosInstance } from "axios";
import { ref, inject } from 'vue'; import { ref, inject } from 'vue';
import { useToast } from "vuestic-ui/web-components"; import { useToast } from "vuestic-ui/web-components";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { WorkoutItem, Attachment, secondsToDuration, distConvert, speedConvert } from "./Definitions.vue"; import { WorkoutItem, formatTime, secondsToDuration, distConvert, speedConvert } from "./Definitions.vue";
const { push } = useRouter(); const { push } = useRouter();

View File

@ -27,6 +27,10 @@
</div> </div>
<div id="workout-short-data"> <div id="workout-short-data">
<h3>{{ workoutItem.name }}</h3> <h3>{{ workoutItem.name }}</h3>
<div class="workout-item-params" v-if="workoutItem.workouted_at">
<div class="workout-item-params-name">Дата:</div>
<div class="workout-item-params-value">{{ formatTime(workoutItem.workouted_at) }}</div>
</div>
<div class="workout-item-params" v-if="workoutItem.power"> <div class="workout-item-params" v-if="workoutItem.power">
<div class="workout-item-params-name">Средняя мощность:</div> <div class="workout-item-params-name">Средняя мощность:</div>
<div class="workout-item-params-value">{{ Math.floor(workoutItem.power) }} Вт</div> <div class="workout-item-params-value">{{ Math.floor(workoutItem.power) }} Вт</div>
@ -113,7 +117,7 @@ import {
import LineWithLineChart from './components/LineWithLineChart.js' import LineWithLineChart from './components/LineWithLineChart.js'
import type { YMap } from '@yandex/ymaps3-types'; import type { YMap } from '@yandex/ymaps3-types';
import { YandexMap, YandexMapDefaultSchemeLayer, YandexMapFeature, YandexMapDefaultFeaturesLayer, YandexMapDefaultMarker } from 'vue-yandex-maps'; import { YandexMap, YandexMapDefaultSchemeLayer, YandexMapFeature, YandexMapDefaultFeaturesLayer, YandexMapDefaultMarker } from 'vue-yandex-maps';
import { WorkoutItem, distConvert, speedConvert } from "./Definitions.vue"; import { WorkoutItem, distConvert, formatTime, speedConvert } from "./Definitions.vue";
//Можно использовать для различных преобразований //Можно использовать для различных преобразований
const map = shallowRef<null | YMap>(null); const map = shallowRef<null | YMap>(null);