check if workout uploaded
Gitea Actions Demo / build_and_push (push) Successful in 2m47s
Details
Gitea Actions Demo / build_and_push (push) Successful in 2m47s
Details
This commit is contained in:
parent
74467d1c7b
commit
1d5676c58b
|
|
@ -50,8 +50,7 @@ const initWorkout = (id: string) => {
|
|||
dzenLink.value = d.dzenLink;
|
||||
}
|
||||
})
|
||||
.catch((error: AxiosError) => {
|
||||
console.log(error);
|
||||
.catch((_error: AxiosError) => {
|
||||
init({
|
||||
message: "Что-то пошло не так.",
|
||||
color: "error",
|
||||
|
|
|
|||
|
|
@ -50,8 +50,7 @@ const initWorkout = (id: string) => {
|
|||
dzenLink.value = d.dzenLink;
|
||||
}
|
||||
})
|
||||
.catch((error: AxiosError) => {
|
||||
console.log(error);
|
||||
.catch((_error: AxiosError) => {
|
||||
init({
|
||||
message: "Что-то пошло не так.",
|
||||
color: "error",
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
/>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { AxiosResponse, AxiosInstance } from "axios";
|
||||
import { AxiosResponse, AxiosInstance, AxiosError } from "axios";
|
||||
import { inject } from 'vue'
|
||||
import { VaFileUpload } from "vuestic-ui";
|
||||
import { useToast } from "vuestic-ui/web-components";
|
||||
|
|
@ -32,6 +32,14 @@ let file: {
|
|||
text: () => Promise<string>,
|
||||
};
|
||||
|
||||
type ErrorItem = {
|
||||
code_string: string;
|
||||
}
|
||||
|
||||
type Error = {
|
||||
detail: ErrorItem;
|
||||
}
|
||||
|
||||
function onFileChanged() {
|
||||
var formData = new FormData();
|
||||
formData.append("file", file);
|
||||
|
|
@ -47,11 +55,21 @@ function onFileChanged() {
|
|||
init({ message: "Тренировка успешно загружена!", color: "success" });
|
||||
router.push({ name: "workout_item", params: { id: response.data.id } });
|
||||
})
|
||||
.catch((error: any) => {
|
||||
init({
|
||||
message: "Что-то пошло не так.",
|
||||
color: "error",
|
||||
});
|
||||
.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({
|
||||
message: "Что-то пошло не так.",
|
||||
color: "error",
|
||||
});
|
||||
|
||||
});
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
import { AxiosResponse, AxiosInstance, AxiosError } from "axios";
|
||||
import { AxiosResponse, AxiosInstance } from "axios";
|
||||
import { inject } from 'vue'
|
||||
import { WorkoutItem, ChartData } from "../Definitions.vue";
|
||||
|
||||
|
|
|
|||
|
|
@ -327,10 +327,9 @@ const saveLink = (hide: any) => {
|
|||
}
|
||||
axiosAuth
|
||||
.patch(`/api/v0/workouts/${workoutItem.id}`,{ links: [{"value": dzenLink.value, "type": "dzen"}] })
|
||||
.then((response: AxiosResponse) => {
|
||||
.then((_response: AxiosResponse) => {
|
||||
hide();
|
||||
}).catch((error: AxiosError) => {
|
||||
console.log(error);
|
||||
}).catch((_error: AxiosError) => {
|
||||
init({
|
||||
message: "Что-то пошло не так.",
|
||||
color: "error",
|
||||
|
|
@ -350,10 +349,9 @@ const saveName = (hide: any) => {
|
|||
}
|
||||
axiosAuth
|
||||
.patch(`/api/v0/workouts/${workoutItem.id}`,{ name: workoutItem.name })
|
||||
.then((response: AxiosResponse) => {
|
||||
.then((_response: AxiosResponse) => {
|
||||
hide();
|
||||
}).catch((error: AxiosError) => {
|
||||
console.log(error);
|
||||
}).catch((_error: AxiosError) => {
|
||||
init({
|
||||
message: "Что-то пошло не так.",
|
||||
color: "error",
|
||||
|
|
@ -366,10 +364,9 @@ const changePublic = (value: boolean) => {
|
|||
}
|
||||
axiosAuth
|
||||
.patch(`/api/v0/workouts/${workoutItem.id}`,{ is_public: value })
|
||||
.then((response: AxiosResponse) => {
|
||||
.then((_response: AxiosResponse) => {
|
||||
|
||||
}).catch((error: AxiosError) => {
|
||||
console.log(error);
|
||||
}).catch((_error: AxiosError) => {
|
||||
init({
|
||||
message: "Что-то пошло не так.",
|
||||
color: "error",
|
||||
|
|
|
|||
Loading…
Reference in New Issue