fix frontend bugs
Gitea Actions Demo / build_and_push (push) Successful in 1m17s Details

This commit is contained in:
artem 2025-02-15 10:52:28 +03:00
parent 1d5676c58b
commit 976a0b8276
4 changed files with 27 additions and 78 deletions

View File

@ -62,8 +62,8 @@ function httpErrorHandler(error: any) {
//The request was made but no response was received, `error.request` is an instance of XMLHttpRequest in the browser and an instance of http.ClientRequest in Node.js
}
}
//Something happened in setting up the request and triggered an Error
console.log(error.message)
console.log(error.status, error.message)
throw error
}
function responseHandler(response: AxiosResponse<any>) {

View File

@ -71,15 +71,6 @@ initWorkouts();
</script>
<style>
.image-container {
cursor: pointer;
height: 300px;
width: 100%;
background-position: 50% 50%;
background-repeat: no-repeat;
background-size: cover;
}
.news-feed {
display: flex;
flex-direction: column;
@ -87,45 +78,4 @@ initWorkouts();
justify-content: center;
}
.news-item {
display: flex;
flex-direction: column;
padding: 1rem;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
transition: transform 0.2s ease-in-out;
width: 100%;
}
.news-item-header {
cursor: pointer;
display: flex;
justify-content: space-between;
}
.news-item-icon {
cursor: pointer;
}
.news-item h3 {
font-weight: bold;
color: #3d3d3d;
}
.metadata {
border-top: #9c9a9a 1px solid;
}
.metadata li {
list-style: none;
display: inline-block;
margin-left: 1rem;
}
.metadata span {
font-size: 0.9em;
opacity: 0.7;
}
</style>

View File

@ -1,15 +1,25 @@
<template>
<h1 class="page-title">Загрузить тренировку</h1>
<VaFileUpload
v-model="file"
<VaFileUpload v-if="!inProgress"
v-model="file"
file-types="gpx,fit"
type="single"
v-on:update:model-value="onFileChanged"
color="#F4F6F8"
:hideFileList=true
dropzone
/>
<div v-else>
<VaInnerLoading
loading
:size="60"
>
</VaInnerLoading>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { AxiosResponse, AxiosInstance, AxiosError } from "axios";
import { inject } from 'vue'
import { VaFileUpload } from "vuestic-ui";
@ -19,7 +29,7 @@ import { useRouter } from "vue-router";
const axiosAuth= inject('axiosAuth') as AxiosInstance;
const { init } = useToast();
const router = useRouter();
const inProgress = ref(false);
let file: {
name: "Example",
url: "",
@ -41,6 +51,14 @@ type Error = {
}
function onFileChanged() {
if (file == undefined) {
init({
message: "Невозможно загрузить такой тип файла",
color: "error",
});
return
}
inProgress.value = true;
var formData = new FormData();
formData.append("file", file);
axiosAuth.post(`/api/v0/attachment/upload`, formData).then(
@ -51,11 +69,12 @@ function onFileChanged() {
"name": "Новая тренировка",
})
.then((response: AxiosResponse) => {
inProgress.value = false;
init({ message: "Тренировка успешно загружена!", color: "success" });
router.push({ name: "workout_item", params: { id: response.data.id } });
})
.catch((error: AxiosError) => {
inProgress.value = false;
if (error.status == 400) {
let err = <Error>error.response?.data
if (err.detail.code_string == "ObjectExists") {

View File

@ -23,10 +23,12 @@
if (mapX.length >= 2 || xIndex == undefined) {
mapX = [];
clickCoordinates = [];
chart.chart.draw();
}
if (xIndex !== undefined) {
clickCoordinates.push(e.coordinates);
mapX.push(xIndex);
chart.chart.draw();
}
}}"/>
<yandex-map-default-marker v-if="currentCoordinates" :settings="{
@ -163,7 +165,6 @@ const dzenLink = ref(dzenLinkProps);
const map = shallowRef<null | YMap>(null);
const chart = ref();
const mapX = ref<Array<number>>([]);
const mapXPrev = ref<Array<number>>([]);
let currentCoordinates = ref<Array<number> | null>([]);
let clickCoordinates = ref<Array<number>>([]);
let coordWithIndex: Map<string, number> = new Map();
@ -189,7 +190,6 @@ ChartJS.register(
zoomPlugin,
TimeScale
)
const { init } = useToast();
type afterEventEvent = {
@ -198,7 +198,6 @@ type afterEventEvent = {
type afterEventArgs = {
"event": afterEventEvent,
}
let zoomLine = 1.0;
const chartPlugins = [
{
id: 'eventPlugin',
@ -211,25 +210,6 @@ const chartPlugins = [
{
id: 'yandexMapLine',
mapX: mapX,
beforeInit(chart: any, ) {
setInterval(() => {
let isEq = true
for (let i = 0; i < mapX.value.length; i++) {
if (mapXPrev.value[i] == mapX.value[i]) {
continue;
}
isEq = false;
break;
}
if (isEq) {
return;
}
chart.draw();
for (let i = 0; i < mapX.value.length; i++) {
mapXPrev.value[i] = mapX.value[i];
}
}, 300)
}
}
];
const chartOptions = {