start work list
This commit is contained in:
parent
8b8f5fc3c1
commit
752e558843
|
|
@ -4,6 +4,72 @@
|
|||
|
||||
<template>
|
||||
<h1 class="page-title">Тренировки</h1>
|
||||
<p>страница в разработке</p>
|
||||
|
||||
<template v-if="!workoutItems">
|
||||
<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>
|
||||
<script setup lang="ts">
|
||||
|
||||
import { AxiosResponse, AxiosInstance } from "axios";
|
||||
import { computed, 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: float;
|
||||
heart_rate: float;
|
||||
temperature: float;
|
||||
speed: float;
|
||||
power: float;
|
||||
duraion_sec: int;
|
||||
};
|
||||
|
||||
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,18 +33,13 @@ let file: {
|
|||
function onFileChanged() {
|
||||
var formData = new FormData();
|
||||
formData.append("file", file);
|
||||
axiosAuth.post(`/api/v0/attachment/upload`, formData, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${localStorage.getItem("token")}`,
|
||||
}
|
||||
}).then(function (response: AxiosResponse) {
|
||||
axiosAuth
|
||||
axiosAuth.post(`/api/v0/attachment/upload`, formData).then(
|
||||
function (response: AxiosResponse) {
|
||||
axiosAuth
|
||||
.post(`/api/v0/workouts`, {
|
||||
"attachment_id": response.data.id,
|
||||
"name": "Новая тренировка",
|
||||
}, {
|
||||
headers: { Authorization: `Bearer ${localStorage.getItem("token")}` }
|
||||
})
|
||||
})
|
||||
.then((response: AxiosResponse) => {
|
||||
init({ message: "Тренировка успешно загружена!", color: "success" });
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue