fix: 🐛 added hostname to api requests and renamed drivertype to be used properly

This commit is contained in:
steev 2025-01-08 22:44:14 +01:00
parent 279bf5944e
commit 77cf71e288
3 changed files with 14 additions and 12 deletions

2
.gitignore vendored
View File

@ -27,7 +27,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
*.js
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.

View File

@ -48,7 +48,7 @@ export default defineComponent({
formData.append("driverId", selectedDriver.value.toString());
try {
const response = await fetch('/track', {
const response = await fetch('http://localhost:5000/track', {
method: 'POST',
body: formData,
});

View File

@ -6,7 +6,7 @@ import '@vuepic/vue-datepicker/dist/main.css'
import Map from '../components/map.vue';
import FileUpload from '../components/fileUpload.vue';
type driver = {
type DriverType = {
id:number
name:string
}
@ -14,7 +14,7 @@ type driver = {
type track = {
id:number
name:string
driver: driver
driver: DriverType
}
export default defineComponent({
@ -24,7 +24,7 @@ export default defineComponent({
const showMap:Ref<boolean> = ref(false);
const showCloud:Ref<boolean> = ref(false);
const search:Ref<boolean> = ref(false);
const showUpload:Ref<boolean> = ref(true);
const showUpload:Ref<boolean> = ref(false);
const tracks:Ref<track[]> = ref([])
const startSearchDate = ref();
const endSearchDate = ref();
@ -40,7 +40,7 @@ export default defineComponent({
headers.set('Content-Type', 'application/json')
headers.set('Accept', 'application/json')
const request: RequestInfo = new Request("/track?id=" + id, {
const request: RequestInfo = new Request("http://localhost:5000/track?id=" + id, {
method:"GET",
headers:headers
})
@ -52,7 +52,7 @@ export default defineComponent({
// convert vehicles from json response to processable data
mapData.value = await response.json()
} else {
alert(response.text)
console.log(await response.text())
}
}
@ -62,7 +62,7 @@ export default defineComponent({
headers.set('Content-Type', 'application/json')
headers.set('Accept', 'application/json')
const request: RequestInfo = new Request("/track", {
const request: RequestInfo = new Request("http://localhost:5000/track", {
method:"GET",
headers:headers
})
@ -74,10 +74,12 @@ export default defineComponent({
// convert vehicles from json response to processable data
for(let i = 0; i < jsonBody.length; i++) {
tracks.value.push({id: jsonBody[i]["id"], name: jsonBody[i]["name"]})
tracks.value.push({id: jsonBody[i]["id"], name: jsonBody[i]["name"], driver: {
id: jsonBody[i]["driver"]["id"], name: jsonBody[i]["driver"]["name"]
}})
}
} else {
alert(response.text)
console.log(await response.text())
}
}
@ -86,7 +88,7 @@ export default defineComponent({
headers.set('Content-Type', 'application/json')
headers.set('Accept', 'application/json')
const request: RequestInfo = new Request("/track?start="+startSearchDate.value+"&end="+endSearchDate.value, {
const request: RequestInfo = new Request("http://localhost:5000/track?start="+startSearchDate.value+"&end="+endSearchDate.value, {
method:"GET",
headers:headers
})
@ -108,7 +110,7 @@ export default defineComponent({
})
}
} else {
alert(response.text)
console.log(await response.text())
}
}