Compare commits
No commits in common. "b1a6718e9df1ad5050bffc53fd53670525fc4eb0" and "8b8f5fc3c1543c2771f98fe1172ced102d19808d" have entirely different histories.
b1a6718e9d
...
8b8f5fc3c1
|
|
@ -1,72 +1,9 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<h1 class="page-title">Тренировки</h1>
|
<h1 class="page-title">Тренировки</h1>
|
||||||
<template v-if="!workoutItems">
|
<p>страница в разработке</p>
|
||||||
<div>Тренировки не найдены</div>
|
|
||||||
</template>
|
|
||||||
<template v-if="workoutItems" v-for="(item, index) in workoutItems" :key="item.id">
|
|
||||||
<div>
|
|
||||||
<h2>{{ item.name }}</h2>
|
|
||||||
<div>
|
|
||||||
<div>Скорость</div>
|
|
||||||
<div>{{ item.speed }}</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div>Каденс</div>
|
|
||||||
<div>{{ item.cadence }}</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div>Пульс</div>
|
|
||||||
<div>{{ item.heart_rate }}</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div>Продолжительность</div>
|
|
||||||
<div>{{ item.duraion_sec }}</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div>Мощность</div>
|
|
||||||
<div>{{ item.power }}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
|
||||||
|
|
||||||
import { AxiosResponse, AxiosInstance } from "axios";
|
|
||||||
import { ref, inject } from 'vue';
|
|
||||||
import { useToast } from "vuestic-ui/web-components";
|
|
||||||
|
|
||||||
|
|
||||||
type WorkoutItem = {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
created_by: string;
|
|
||||||
created_at: string;
|
|
||||||
updated_at: string;
|
|
||||||
description: string;
|
|
||||||
cadence: number;
|
|
||||||
heart_rate: number;
|
|
||||||
temperature: number;
|
|
||||||
speed: number;
|
|
||||||
power: number;
|
|
||||||
duraion_sec: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
const axiosAuth= inject('axiosAuth') as AxiosInstance;
|
|
||||||
let workoutItems = ref<Array<WorkoutItem>>([]);
|
|
||||||
const { init } = useToast();
|
|
||||||
|
|
||||||
axiosAuth
|
|
||||||
.get(`/api/v0/workouts`)
|
|
||||||
.then((response: AxiosResponse) => {
|
|
||||||
workoutItems.value = response.data.results;
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
console.log(error);
|
|
||||||
init({
|
|
||||||
message: "Что-то пошло не так.",
|
|
||||||
color: "error",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
|
||||||
|
|
@ -33,13 +33,18 @@ let file: {
|
||||||
function onFileChanged() {
|
function onFileChanged() {
|
||||||
var formData = new FormData();
|
var formData = new FormData();
|
||||||
formData.append("file", file);
|
formData.append("file", file);
|
||||||
axiosAuth.post(`/api/v0/attachment/upload`, formData).then(
|
axiosAuth.post(`/api/v0/attachment/upload`, formData, {
|
||||||
function (response: AxiosResponse) {
|
headers: {
|
||||||
axiosAuth
|
'Authorization': `Bearer ${localStorage.getItem("token")}`,
|
||||||
|
}
|
||||||
|
}).then(function (response: AxiosResponse) {
|
||||||
|
axiosAuth
|
||||||
.post(`/api/v0/workouts`, {
|
.post(`/api/v0/workouts`, {
|
||||||
"attachment_id": response.data.id,
|
"attachment_id": response.data.id,
|
||||||
"name": "Новая тренировка",
|
"name": "Новая тренировка",
|
||||||
})
|
}, {
|
||||||
|
headers: { Authorization: `Bearer ${localStorage.getItem("token")}` }
|
||||||
|
})
|
||||||
.then((response: AxiosResponse) => {
|
.then((response: AxiosResponse) => {
|
||||||
init({ message: "Тренировка успешно загружена!", color: "success" });
|
init({ message: "Тренировка успешно загружена!", color: "success" });
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue