From b490d058e46bf06dac7dcd737973bfcca7aecbb7 Mon Sep 17 00:00:00 2001 From: TobiZog Date: Sat, 12 Oct 2024 21:00:42 +0200 Subject: [PATCH] Remove EventModel in frontend --- software/backend/routes/band.routes.ts | 20 +++- software/backend/routes/concert.routes.ts | 7 ++ software/backend/routes/location.routes.ts | 1 + software/backend/scripts/databaseHelper.ts | 2 +- .../navigation/navigationAppendItems.vue | 7 +- .../src/components/pageParts/bandListItem.vue | 2 +- software/src/data/api/bandApi.ts | 2 +- software/src/data/api/concertApi.ts | 15 ++- software/src/data/api/eventApi.ts | 36 -------- software/src/data/api/locationApi.ts | 3 +- software/src/data/models/acts/bandApiModel.ts | 3 +- .../models/acts/concertDetailsApiModel.ts | 9 ++ software/src/data/stores/bandStore.ts | 35 +++++++ software/src/data/stores/basketStore.ts | 3 +- software/src/data/stores/concertStore.ts | 39 ++++++-- software/src/data/stores/locationStore.ts | 34 +++++-- software/src/data/stores/searchStore.ts | 8 +- software/src/data/stores/shoppingStore.ts | 13 +-- software/src/locales/de.json | 4 +- software/src/locales/en.json | 4 +- .../bands/bandDetailPage/concertSection.vue | 50 ++++------ .../bands/bandDetailPage/gallerySection.vue | 6 +- .../src/pages/bands/bandDetailPage/index.vue | 48 +++++----- .../bands/bandDetailPage/ratingSection.vue | 8 +- software/src/pages/bands/bandsPage/index.vue | 45 ++++++++- .../concerts/concertBookingPage/index.vue | 43 ++++----- .../src/pages/concerts/concertsPage/index.vue | 4 +- .../src/pages/events/eventsPage/filterBar.vue | 92 ------------------- .../src/pages/events/eventsPage/index.vue | 68 -------------- .../src/pages/homePage/highlightCarousel.vue | 10 +- software/src/pages/homePage/index.vue | 60 +++++------- .../locations/locationDetailPage/index.vue | 7 +- software/src/router/routes.ts | 2 +- 33 files changed, 313 insertions(+), 377 deletions(-) delete mode 100644 software/src/data/api/eventApi.ts create mode 100644 software/src/data/models/acts/concertDetailsApiModel.ts create mode 100644 software/src/data/stores/bandStore.ts delete mode 100644 software/src/pages/events/eventsPage/filterBar.vue delete mode 100644 software/src/pages/events/eventsPage/index.vue diff --git a/software/backend/routes/band.routes.ts b/software/backend/routes/band.routes.ts index f6aeafa..bc4a9f5 100644 --- a/software/backend/routes/band.routes.ts +++ b/software/backend/routes/band.routes.ts @@ -13,6 +13,9 @@ export const band = Router() // Get all bands band.get("/", (req: Request, res: Response) => { + let sort = req.query.sort + let count = req.query.count + Band.findAll({ include: [ { @@ -35,13 +38,28 @@ band.get("/", (req: Request, res: Response) => { // Delete unnecessary Arrays delete band.dataValues.ratings - delete band.dataValues.concerts for (let genre of band.dataValues.genres) { delete genre.dataValues.BandGenre } } + // Sort ascending/descending by number of concerts + if (sort != undefined) { + bands.sort((band1, band2) => { + if (sort == "desc") { + return band2.dataValues.concerts.length - band1.dataValues.concerts.length + } else if (sort == "asc") { + return band1.dataValues.concerts.length - band2.dataValues.concerts.length + } + }) + } + + // Limit number of items + if (count != undefined) { + bands.splice(Number(count)) + } + res.status(200).json(bands) }) }) diff --git a/software/backend/routes/concert.routes.ts b/software/backend/routes/concert.routes.ts index 38ee75c..fe83466 100644 --- a/software/backend/routes/concert.routes.ts +++ b/software/backend/routes/concert.routes.ts @@ -12,6 +12,8 @@ export const concert = Router() concert.get("/", (req: Request, res: Response) => { + let count = req.query.count + Concert.findAll({ include: [ Band, Location ], order: [ @@ -19,6 +21,11 @@ concert.get("/", (req: Request, res: Response) => { ] }) .then(concerts => { + // Limit number of items + if (count != undefined) { + concerts.splice(Number(count)) + } + res.status(200).json(concerts) }) }) diff --git a/software/backend/routes/location.routes.ts b/software/backend/routes/location.routes.ts index e77b5fd..b8e19d1 100644 --- a/software/backend/routes/location.routes.ts +++ b/software/backend/routes/location.routes.ts @@ -27,6 +27,7 @@ location.get("/", (req: Request, res: Response) => { } }) .then(async locations => { + // Sort ascending/descending by number of concerts if (sort != undefined) { locations.sort((location1, location2) => { if (sort == "desc") { diff --git a/software/backend/scripts/databaseHelper.ts b/software/backend/scripts/databaseHelper.ts index 0650dea..b53c135 100644 --- a/software/backend/scripts/databaseHelper.ts +++ b/software/backend/scripts/databaseHelper.ts @@ -226,7 +226,7 @@ export async function prepopulateDatabase() { date: concert.date, name: concertGroup.name, price: concert.price, - image: concertGroup.name, + image: concertGroup.image, inStock: concert.inStock, offered: true, bandId: dataset.dataValues.id, diff --git a/software/src/components/navigation/navigationAppendItems.vue b/software/src/components/navigation/navigationAppendItems.vue index 025090a..47ffd03 100644 --- a/software/src/components/navigation/navigationAppendItems.vue +++ b/software/src/components/navigation/navigationAppendItems.vue @@ -1,7 +1,6 @@ \ No newline at end of file diff --git a/software/src/pages/bands/bandDetailPage/gallerySection.vue b/software/src/pages/bands/bandDetailPage/gallerySection.vue index 913517d..ff420ea 100644 --- a/software/src/pages/bands/bandDetailPage/gallerySection.vue +++ b/software/src/pages/bands/bandDetailPage/gallerySection.vue @@ -1,8 +1,8 @@