From c643fb22c2dfdb7f9956b5b118b586ffa10eea82 Mon Sep 17 00:00:00 2001 From: Arnout_Allaert Date: Tue, 16 May 2023 18:57:14 +0200 Subject: [PATCH 01/18] fix: show all users with their name in syndicus select --- web/src/views/building/BuildingMaker.vue | 49 ++++++++++++++++++++---- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/web/src/views/building/BuildingMaker.vue b/web/src/views/building/BuildingMaker.vue index bd99e8467..9e04df4fe 100644 --- a/web/src/views/building/BuildingMaker.vue +++ b/web/src/views/building/BuildingMaker.vue @@ -14,11 +14,27 @@ v-model="building.ivago_id" label="Ivago ID" > + + :items="syndici" + v-model="building.syndicus" + prepend-inner-icon="mdi-account" + > + + + + | undefined): string { + if (s) { + return s.first_name + " " + s.last_name; + } else { + return " "; + } +} + const submit = () => { tryOrAlertAsync(async () => { const { id } = await new AddressQuery().createOne(address.value); building.value.address_id = id; - const { id: buildingId } = await new BuildingQuery().createOne( - building.value, + const { id: buildingId } = await new BuildingQuery().createOne({ + id: building.value.id, + ivago_id: building.value.ivago_id, + syndicus_id: building.value.syndicus.id, + address_id: building.value.address_id, + manual_id: building.value.manual_id, + } ); await router.push(`/gebouw/${buildingId}`); }); From 259c1f112253ae1c44d02bc4594d02f35263ed4e Mon Sep 17 00:00:00 2001 From: Arnout_Allaert Date: Tue, 16 May 2023 20:58:43 +0200 Subject: [PATCH 02/18] feat: added leaflet map --- web/src/views/building/BuildingMaker.vue | 41 +++++++++++++++--------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/web/src/views/building/BuildingMaker.vue b/web/src/views/building/BuildingMaker.vue index 9e04df4fe..e64652f96 100644 --- a/web/src/views/building/BuildingMaker.vue +++ b/web/src/views/building/BuildingMaker.vue @@ -45,22 +45,25 @@ - - - - - - - + + + + + + + {{ building.name }} + + + +
@@ -111,6 +114,10 @@ import { UserQuery, } from "@selab-2/groep-1-query"; import router from "@/router"; +import "leaflet/dist/leaflet.css"; +import "leaflet/dist/leaflet.js"; +import { LMap, LTileLayer, LMarker, LTooltip } from "@vue-leaflet/vue-leaflet"; +import CardLayout from "@/layouts/CardLayout.vue"; const dummyMap = ref(null); @@ -145,6 +152,8 @@ function getFullStudentName(s: Result | undefined): string { } } +const zoom = ref(8); + const submit = () => { tryOrAlertAsync(async () => { const { id } = await new AddressQuery().createOne(address.value); From 89be941bd1c11d507afa9566b5377c335240f4b4 Mon Sep 17 00:00:00 2001 From: Arnout_Allaert Date: Wed, 17 May 2023 16:57:27 +0200 Subject: [PATCH 03/18] fix: coordinates --- web/src/views/building/BuildingMaker.vue | 68 +++++++++++++++++------- 1 file changed, 49 insertions(+), 19 deletions(-) diff --git a/web/src/views/building/BuildingMaker.vue b/web/src/views/building/BuildingMaker.vue index e64652f96..24311b720 100644 --- a/web/src/views/building/BuildingMaker.vue +++ b/web/src/views/building/BuildingMaker.vue @@ -37,16 +37,18 @@ - + @@ -63,7 +65,7 @@ - +
@@ -71,16 +73,16 @@ @@ -104,7 +106,7 @@ From 69ce43266d8104f68d8bb0864b5535a494e37af5 Mon Sep 17 00:00:00 2001 From: Arnout_Allaert Date: Thu, 18 May 2023 12:53:26 +0200 Subject: [PATCH 04/18] fix: corrected syndicus usage --- api_query/src/building.ts | 37 ++++++++++++++++++- web/src/views/building/BuildingMaker.vue | 46 +++++++++++++----------- 2 files changed, 62 insertions(+), 21 deletions(-) diff --git a/api_query/src/building.ts b/api_query/src/building.ts index ff4f9468b..6f4dc4835 100644 --- a/api_query/src/building.ts +++ b/api_query/src/building.ts @@ -1,4 +1,4 @@ -import { Image, Prisma } from "@selab-2/groep-1-orm"; +import { Image, File, Prisma } from "@selab-2/groep-1-orm"; import { Query } from "./query"; import { includeUserWithoutAddress } from "./include"; import { QueryError } from "./query_error"; @@ -103,6 +103,41 @@ export class BuildingQuery extends Query< return this.fetchJSON(imageEndpoint, "DELETE", { hardDelete: hard }); } + /** + * Voeg een handleiding toe via HTTP POST + * @throws QueryError + */ + async createManual( + id: number, + element: Partial, + ): Promise { + if (Number.isNaN(id)) { + throw new QueryError(400, "Bad Request"); + } + + const fileEndpoint = this.server + this.endpoint + "/" + id + "/file"; + + return this.fetchJSON(fileEndpoint, "POST", element); + } + + /** + * Verwijder de handleiding via HTTP DELETE + * @throws QueryError + */ + async deleteManual( + id: number, + manual_id: number, + hard = false, + ): Promise { + if (Number.isNaN(id)) { + throw new QueryError(400, "Bad Request"); + } + + const fileEndpoint = this.server + this.endpoint + "/" + id + "/file/" + manual_id; + + return this.fetchJSON(fileEndpoint, "DELETE", { hardDelete: hard }); + } + async getAnalytics( startdate: Date, enddate: Date, diff --git a/web/src/views/building/BuildingMaker.vue b/web/src/views/building/BuildingMaker.vue index 24311b720..e7061bea3 100644 --- a/web/src/views/building/BuildingMaker.vue +++ b/web/src/views/building/BuildingMaker.vue @@ -17,7 +17,7 @@ @@ -114,13 +114,15 @@ import { AddressQuery, BuildingQuery, UserQuery, + SyndicusQuery, } from "@selab-2/groep-1-query"; import router from "@/router"; import "leaflet/dist/leaflet.css"; import "leaflet/dist/leaflet.js"; import { LMap, LTileLayer, LMarker, LTooltip } from "@vue-leaflet/vue-leaflet"; -const syndici = await new UserQuery().getAll(); +const users = await new UserQuery().getAll(); +const syndici = await new SyndicusQuery().getAll(); const address = ref({ street: "", @@ -142,8 +144,6 @@ const building = ref({ first_name: "", last_name: "" }, - address_id: 0, - manual_id: null, }); const manual = ref(null) @@ -159,11 +159,22 @@ function getFullStudentName(s: Result | undefined): string { const zoom = ref(8); const submit = () => { - console.log(address.value) - console.log(latitude.value) - console.log(longitude.value) - /* + // check if the user is already a syndicus, else we need to make the user a syndicus + let createSyndicus: boolean = true; + for(const syndicus of syndici){ + if(syndicus.user_id == building.value.syndicus.id){ + createSyndicus = false; + building.value.syndicus.id = syndicus.id; + break; + } + } tryOrAlertAsync(async () => { + if (createSyndicus) { + let {id: syndicusId} = await new SyndicusQuery().createOne({ + user_id: building.value.syndicus.id, + }); + building.value.syndicus.id = syndicusId; + } const { id: addressId } = await new AddressQuery().createOne({ street: address.value.street, number: address.value.number, @@ -172,31 +183,26 @@ const submit = () => { latitude: latitude.value, longitude: longitude.value, }); - console.log(addressId) - building.value.address_id = id; const { id: buildingId } = await new BuildingQuery().createOne({ - // id: building.value.id, name: building.value.name, ivago_id: building.value.ivago_id, syndicus_id: building.value.syndicus.id, address_id: addressId, - manual_id: building.value.manual_id, } ); - // await new BuildingQuery().createImage({ // id: buildingId, // image: , - //} - - // await new BuildingQuery().createFile({ deze functie bestaat nog niet - // id: buildingId, - // file: manual.value, - //} + //}) + const {id: manualId} = await new BuildingQuery().createManual({ + id: buildingId, + file: manual.value, + }) + console.log(manualId) // await router.push(`/gebouw/${buildingId}`); + }); - */ }; From 49b3db63d7165a957803cb79ede70105eb2b58d4 Mon Sep 17 00:00:00 2001 From: Arnout_Allaert Date: Thu, 18 May 2023 15:09:29 +0200 Subject: [PATCH 05/18] feat: added description for building --- api_query/src/building.ts | 37 +------------------ web/src/views/building/BuildingMaker.vue | 46 +++++++++++++++++------- 2 files changed, 34 insertions(+), 49 deletions(-) diff --git a/api_query/src/building.ts b/api_query/src/building.ts index 6f4dc4835..ff4f9468b 100644 --- a/api_query/src/building.ts +++ b/api_query/src/building.ts @@ -1,4 +1,4 @@ -import { Image, File, Prisma } from "@selab-2/groep-1-orm"; +import { Image, Prisma } from "@selab-2/groep-1-orm"; import { Query } from "./query"; import { includeUserWithoutAddress } from "./include"; import { QueryError } from "./query_error"; @@ -103,41 +103,6 @@ export class BuildingQuery extends Query< return this.fetchJSON(imageEndpoint, "DELETE", { hardDelete: hard }); } - /** - * Voeg een handleiding toe via HTTP POST - * @throws QueryError - */ - async createManual( - id: number, - element: Partial, - ): Promise { - if (Number.isNaN(id)) { - throw new QueryError(400, "Bad Request"); - } - - const fileEndpoint = this.server + this.endpoint + "/" + id + "/file"; - - return this.fetchJSON(fileEndpoint, "POST", element); - } - - /** - * Verwijder de handleiding via HTTP DELETE - * @throws QueryError - */ - async deleteManual( - id: number, - manual_id: number, - hard = false, - ): Promise { - if (Number.isNaN(id)) { - throw new QueryError(400, "Bad Request"); - } - - const fileEndpoint = this.server + this.endpoint + "/" + id + "/file/" + manual_id; - - return this.fetchJSON(fileEndpoint, "DELETE", { hardDelete: hard }); - } - async getAnalytics( startdate: Date, enddate: Date, diff --git a/web/src/views/building/BuildingMaker.vue b/web/src/views/building/BuildingMaker.vue index e7061bea3..027d9976e 100644 --- a/web/src/views/building/BuildingMaker.vue +++ b/web/src/views/building/BuildingMaker.vue @@ -47,7 +47,7 @@ - + + + + + + + + + | undefined): string { if (s) { @@ -183,24 +201,26 @@ const submit = () => { latitude: latitude.value, longitude: longitude.value, }); + const { id: buildingId } = await new BuildingQuery().createOne({ name: building.value.name, ivago_id: building.value.ivago_id, + description: description.value, syndicus_id: building.value.syndicus.id, address_id: addressId, + // manual_id: manualId, } ); - // await new BuildingQuery().createImage({ - // id: buildingId, - // image: , - //}) - - const {id: manualId} = await new BuildingQuery().createManual({ - id: buildingId, - file: manual.value, - }) - console.log(manualId) - // await router.push(`/gebouw/${buildingId}`); + /* + for(const image of images){ + await new BuildingQuery().createImage({ + id: buildingId, + image: image, // wss eerst de images omzetten naar Image type van db + }); + }; + */ + + await router.push(`/gebouw/${buildingId}`); }); From d6eacb20764479966b8456c3f4ff6159f1723b12 Mon Sep 17 00:00:00 2001 From: Arnout_Allaert Date: Thu, 18 May 2023 15:53:56 +0200 Subject: [PATCH 06/18] chore: tried upload manual and images --- web/src/views/building/BuildingMaker.vue | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/web/src/views/building/BuildingMaker.vue b/web/src/views/building/BuildingMaker.vue index 027d9976e..e7b18ee52 100644 --- a/web/src/views/building/BuildingMaker.vue +++ b/web/src/views/building/BuildingMaker.vue @@ -103,7 +103,9 @@ - + + { longitude: longitude.value, }); + // create File object for manual + // const response = await fetch('http://10.0.0.5:8080/file/', {method: "POST", body: JSON.stringify(manual)}); + // const man = await response.json() + const { id: buildingId } = await new BuildingQuery().createOne({ name: building.value.name, ivago_id: building.value.ivago_id, description: description.value, syndicus_id: building.value.syndicus.id, address_id: addressId, - // manual_id: manualId, + // manual_id: man.id, } ); + /* for(const image of images){ + // create Image object from the image + const response = await fetch('http://10.0.0.5:8080/image/', {method: "POST", body: JSON.stringify(image)}); + const im = await response.json() + + // add the image to the building await new BuildingQuery().createImage({ id: buildingId, - image: image, // wss eerst de images omzetten naar Image type van db + image: im, }); }; */ From ca499a69817520c01170f93b461d8d6dcb3f6c19 Mon Sep 17 00:00:00 2001 From: arne Date: Sat, 20 May 2023 02:46:16 +0200 Subject: [PATCH 07/18] feat: cleanup and extra emits --- web/src/components/images/AddImage.vue | 38 ++++----------------- web/src/components/images/MultiAddImage.vue | 23 ++++++++++--- web/src/views/building/BuildingMaker.vue | 3 +- 3 files changed, 26 insertions(+), 38 deletions(-) diff --git a/web/src/components/images/AddImage.vue b/web/src/components/images/AddImage.vue index a19904189..abef0edb1 100644 --- a/web/src/components/images/AddImage.vue +++ b/web/src/components/images/AddImage.vue @@ -17,23 +17,17 @@ prepend-icon="" prepend-inner-icon="mdi-image" append-inner-icon="mdi-upload" - @change="previewImage" + @change="{previewImage(); $emit('uploaded', image[0])}" variant="solo" /> - @@ -44,16 +38,12 @@ diff --git a/web/src/components/images/MultiAddImage.vue b/web/src/components/images/MultiAddImage.vue deleted file mode 100644 index 4eeeb082f..000000000 --- a/web/src/components/images/MultiAddImage.vue +++ /dev/null @@ -1,54 +0,0 @@ - - - diff --git a/web/src/views/building/BuildingMaker.vue b/web/src/views/building/BuildingMaker.vue index 7878d5e0c..00d6e6a3e 100644 --- a/web/src/views/building/BuildingMaker.vue +++ b/web/src/views/building/BuildingMaker.vue @@ -116,8 +116,9 @@ > - - + | undefined): string { const zoom = ref(8); const submit = () => { - // check if the user is already a syndicus, else we need to make the user a syndicus - let createSyndicus: boolean = true; - for (const syndicus of syndici) { - if (syndicus.user_id == building.value.syndicus.id) { - createSyndicus = false; - building.value.syndicus.id = syndicus.id; - break; - } - } tryOrAlertAsync(async () => { /* const newAddress = await new AddressQuery().createOne({ From 58933a9845b170dab388ed8dd398aff602fecbff Mon Sep 17 00:00:00 2001 From: arne Date: Sun, 21 May 2023 02:07:39 +0200 Subject: [PATCH 11/18] fix: uncommented file uploader --- web/src/views/building/BuildingMaker.vue | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/web/src/views/building/BuildingMaker.vue b/web/src/views/building/BuildingMaker.vue index 00d6e6a3e..d9f3961dd 100644 --- a/web/src/views/building/BuildingMaker.vue +++ b/web/src/views/building/BuildingMaker.vue @@ -153,6 +153,7 @@ import { BuildingQuery, UserQuery, SyndicusQuery, + FileQuery, } from "@selab-2/groep-1-query"; import router from "@/router"; import "leaflet/dist/leaflet.css"; @@ -283,9 +284,7 @@ const submit = () => { buildingUnwrapped.syndicus.id = syndicusId; } - /* const file = await new FileQuery().createOne("manual-id"); - */ const newBuilding = await new BuildingQuery().createOne({ name: buildingUnwrapped.name, @@ -294,7 +293,7 @@ const submit = () => { ivago_id: buildingUnwrapped.ivago_id, expected_time: expectedTimeInHours.value * 60, syndicus_id: buildingUnwrapped.syndicus.id, - manual_id: buildingUnwrapped.manual_id, + manual_id: file.id, }); for (const fileId of fileIds.value) { From 6acd5aaa21f0614553266f3bfff484985167680a Mon Sep 17 00:00:00 2001 From: arne Date: Sun, 21 May 2023 03:34:11 +0200 Subject: [PATCH 12/18] feat: conditional routing --- web/src/router/index.ts | 2 +- web/src/views/building/BuildingMaker.vue | 63 ++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/web/src/router/index.ts b/web/src/router/index.ts index 04b546110..cc4217d75 100644 --- a/web/src/router/index.ts +++ b/web/src/router/index.ts @@ -159,7 +159,7 @@ const routes: any[] = [ }, }, { - path: "/gebouw/nieuw", + path: "/gebouw/nieuw/:id?", name: "building_new", component: BuildingMaker, meta: { diff --git a/web/src/views/building/BuildingMaker.vue b/web/src/views/building/BuildingMaker.vue index d9f3961dd..7853dfb91 100644 --- a/web/src/views/building/BuildingMaker.vue +++ b/web/src/views/building/BuildingMaker.vue @@ -16,6 +16,7 @@ >
@@ -116,11 +124,12 @@ > - + (["Hoofdafbeelding"]); +const fileContent = ref>([[]]) + +const manualContent = ref() function addFileId() { fileIds.value.push("Afbeelding " + fileIds.value.length); + fileContent.value.push([]) } function removeFileId() { if (fileIds.value.length > 1) { fileIds.value.pop(); + fileContent.value.pop() } } @@ -197,6 +213,7 @@ const longitude = ref(0); const building = ref({ name: "", ivago_id: "", + description: "", syndicus: { id: 0, first_name: "", @@ -206,7 +223,45 @@ const building = ref({ manual_id: 1, }); -const description = ref(""); +const route = useRoute(); +const buildingId: number = Number(route.params.id); + +if (buildingId) { + tryOrAlertAsync(async () => { + const requestedBuilding: Result = + await new BuildingQuery().getOne(buildingId); + + const thisSyndicus = requestedBuilding.syndicus; + const thisAddress = requestedBuilding.address; + + building.value.name = requestedBuilding.name; + building.value.ivago_id = requestedBuilding.ivago_id; + building.value.syndicus = { + id: thisSyndicus.id, + first_name: thisSyndicus.user.first_name, + last_name: thisSyndicus.user.last_name, + }; + building.value.description = requestedBuilding.description + ? requestedBuilding.description + : ""; + + address.value = { + street: thisAddress.street, + number: thisAddress.number, + city: thisAddress.city, + zip_code: thisAddress.zip_code, + }; + latitude.value = requestedBuilding.address.latitude; + longitude.value = requestedBuilding.address.longitude; + + + manualContent.value = requestedBuilding.manual? [requestedBuilding.manual] as any : [] + + fileContent.value = requestedBuilding.images[0].image as any + console.log(fileContent.value) + + }); +} function getFullStudentName(s: Result | undefined): string { if (s) { @@ -289,7 +344,7 @@ const submit = () => { const newBuilding = await new BuildingQuery().createOne({ name: buildingUnwrapped.name, address_id: newAddress.id, - description: description.value, + description: buildingUnwrapped.description, ivago_id: buildingUnwrapped.ivago_id, expected_time: expectedTimeInHours.value * 60, syndicus_id: buildingUnwrapped.syndicus.id, From 19251f27276a0bd4610232ba392bd388f86fdc61 Mon Sep 17 00:00:00 2001 From: arne Date: Sun, 21 May 2023 05:55:04 +0200 Subject: [PATCH 13/18] render edit page --- web/src/views/building/BuildingMaker.vue | 80 +++++++++++++++++++----- 1 file changed, 63 insertions(+), 17 deletions(-) diff --git a/web/src/views/building/BuildingMaker.vue b/web/src/views/building/BuildingMaker.vue index 7853dfb91..c970462fd 100644 --- a/web/src/views/building/BuildingMaker.vue +++ b/web/src/views/building/BuildingMaker.vue @@ -16,7 +16,7 @@ > - + @@ -183,7 +220,6 @@ From 6493acd8e5fed05507c64cce3363d70d542e7274 Mon Sep 17 00:00:00 2001 From: arne Date: Sun, 21 May 2023 07:08:26 +0200 Subject: [PATCH 15/18] feat: routing to page, button changed --- web/src/views/building/BuildingMaker.vue | 3 +-- web/src/views/building/BuildingScreen.vue | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/web/src/views/building/BuildingMaker.vue b/web/src/views/building/BuildingMaker.vue index 878fa474e..cf58b437d 100644 --- a/web/src/views/building/BuildingMaker.vue +++ b/web/src/views/building/BuildingMaker.vue @@ -213,7 +213,7 @@ color="success" prepend-icon="mdi-check" class="mb-12" - >Maak gebouw{{ edit ? "Pas wijzigingen toe" : "Maak gebouw" }} @@ -384,7 +384,6 @@ const submit = () => { manual_id: file.id, }); - for (const fileId of fileIds.value) { const element: any = document.getElementById(fileId); console.log(element.files.length); diff --git a/web/src/views/building/BuildingScreen.vue b/web/src/views/building/BuildingScreen.vue index a9914d219..57d4a7bb9 100644 --- a/web/src/views/building/BuildingScreen.vue +++ b/web/src/views/building/BuildingScreen.vue @@ -66,7 +66,15 @@ Handleiding
- + + Pas aan +