check if workout uploaded
Gitea Actions Demo / build_and_push (push) Successful in 2m47s Details

This commit is contained in:
artem 2025-02-08 10:34:08 +03:00
parent 74467d1c7b
commit 1d5676c58b
5 changed files with 33 additions and 20 deletions

View File

@ -50,8 +50,7 @@ const initWorkout = (id: string) => {
dzenLink.value = d.dzenLink; dzenLink.value = d.dzenLink;
} }
}) })
.catch((error: AxiosError) => { .catch((_error: AxiosError) => {
console.log(error);
init({ init({
message: "Что-то пошло не так.", message: "Что-то пошло не так.",
color: "error", color: "error",

View File

@ -50,8 +50,7 @@ const initWorkout = (id: string) => {
dzenLink.value = d.dzenLink; dzenLink.value = d.dzenLink;
} }
}) })
.catch((error: AxiosError) => { .catch((_error: AxiosError) => {
console.log(error);
init({ init({
message: "Что-то пошло не так.", message: "Что-то пошло не так.",
color: "error", color: "error",

View File

@ -10,7 +10,7 @@
/> />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { AxiosResponse, AxiosInstance } from "axios"; import { AxiosResponse, AxiosInstance, AxiosError } from "axios";
import { inject } from 'vue' import { inject } from 'vue'
import { VaFileUpload } from "vuestic-ui"; import { VaFileUpload } from "vuestic-ui";
import { useToast } from "vuestic-ui/web-components"; import { useToast } from "vuestic-ui/web-components";
@ -32,6 +32,14 @@ let file: {
text: () => Promise<string>, text: () => Promise<string>,
}; };
type ErrorItem = {
code_string: string;
}
type Error = {
detail: ErrorItem;
}
function onFileChanged() { function onFileChanged() {
var formData = new FormData(); var formData = new FormData();
formData.append("file", file); formData.append("file", file);
@ -47,7 +55,17 @@ function onFileChanged() {
init({ message: "Тренировка успешно загружена!", color: "success" }); init({ message: "Тренировка успешно загружена!", color: "success" });
router.push({ name: "workout_item", params: { id: response.data.id } }); router.push({ name: "workout_item", params: { id: response.data.id } });
}) })
.catch((error: any) => { .catch((error: AxiosError) => {
if (error.status == 400) {
let err = <Error>error.response?.data
if (err.detail.code_string == "ObjectExists") {
init({
message: "Такая тренировка уже загружена",
color: "error",
});
return
}
}
init({ init({
message: "Что-то пошло не так.", message: "Что-то пошло не так.",
color: "error", color: "error",

View File

@ -1,5 +1,5 @@
import { AxiosResponse, AxiosInstance, AxiosError } from "axios"; import { AxiosResponse, AxiosInstance } from "axios";
import { inject } from 'vue' import { inject } from 'vue'
import { WorkoutItem, ChartData } from "../Definitions.vue"; import { WorkoutItem, ChartData } from "../Definitions.vue";

View File

@ -327,10 +327,9 @@ const saveLink = (hide: any) => {
} }
axiosAuth axiosAuth
.patch(`/api/v0/workouts/${workoutItem.id}`,{ links: [{"value": dzenLink.value, "type": "dzen"}] }) .patch(`/api/v0/workouts/${workoutItem.id}`,{ links: [{"value": dzenLink.value, "type": "dzen"}] })
.then((response: AxiosResponse) => { .then((_response: AxiosResponse) => {
hide(); hide();
}).catch((error: AxiosError) => { }).catch((_error: AxiosError) => {
console.log(error);
init({ init({
message: "Что-то пошло не так.", message: "Что-то пошло не так.",
color: "error", color: "error",
@ -350,10 +349,9 @@ const saveName = (hide: any) => {
} }
axiosAuth axiosAuth
.patch(`/api/v0/workouts/${workoutItem.id}`,{ name: workoutItem.name }) .patch(`/api/v0/workouts/${workoutItem.id}`,{ name: workoutItem.name })
.then((response: AxiosResponse) => { .then((_response: AxiosResponse) => {
hide(); hide();
}).catch((error: AxiosError) => { }).catch((_error: AxiosError) => {
console.log(error);
init({ init({
message: "Что-то пошло не так.", message: "Что-то пошло не так.",
color: "error", color: "error",
@ -366,10 +364,9 @@ const changePublic = (value: boolean) => {
} }
axiosAuth axiosAuth
.patch(`/api/v0/workouts/${workoutItem.id}`,{ is_public: value }) .patch(`/api/v0/workouts/${workoutItem.id}`,{ is_public: value })
.then((response: AxiosResponse) => { .then((_response: AxiosResponse) => {
}).catch((error: AxiosError) => { }).catch((_error: AxiosError) => {
console.log(error);
init({ init({
message: "Что-то пошло не так.", message: "Что-то пошло не так.",
color: "error", color: "error",