From c2a337e0516b6cf0c07d1509cc82c0f29cfc4362 Mon Sep 17 00:00:00 2001 From: TobiZog Date: Wed, 6 Nov 2024 17:55:18 +0100 Subject: [PATCH] Finish GenresAdminPanel --- software/backend/routes/genre.routes.ts | 50 ++++++++++++++ software/backend/scripts/databaseHelper.ts | 24 ++++--- .../components/basics/cardViewTopImage.vue | 2 +- .../src/components/pageParts/bandListItem.vue | 2 +- .../src/components/pageParts/heroImage.vue | 4 +- .../components/pageParts/ticketListItem.vue | 2 +- software/src/data/api/genreApi.ts | 15 +++++ software/src/data/enums/bannerStateEnum.ts | 12 +++- software/src/data/models/acts/genreModel.ts | 2 +- .../admin/bandsAdminPage/bandEditDialog.vue | 15 +++++ .../admin/genresAdminPage/genreEditDialog.vue | 1 + .../src/pages/admin/genresAdminPage/index.vue | 1 + .../bands/bandDetailPage/gallerySection.vue | 2 +- .../src/pages/bands/bandDetailPage/index.vue | 1 - software/src/pages/homePage/bandsSection.vue | 2 +- .../homePage/upcomingConcertsSection.vue | 2 + software/src/stores/genre.store.ts | 65 ++++++++++++++++++- 17 files changed, 181 insertions(+), 21 deletions(-) diff --git a/software/backend/routes/genre.routes.ts b/software/backend/routes/genre.routes.ts index 91273be..a98b4dc 100644 --- a/software/backend/routes/genre.routes.ts +++ b/software/backend/routes/genre.routes.ts @@ -14,4 +14,54 @@ genre.get("/", (req: Request, res: Response) => { .then(genres => { res.status(200).json(genres) }) + .catch(error => { + res.status(500).send() + }) +}) + +/** + * Update a Genre entry + */ +genre.patch("/", (req: Request, res: Response) => { + Genre.update(req.body, { + where: { + id: req.body.id + } + }) + .then(result => { + res.status(200).json(result) + }) + .catch(error => { + res.status(500).send() + }) +}) + +/** + * Create a new Genre entry + */ +genre.post("/", (req: Request, res: Response) => { + Genre.create(req.body) + .then(result => { + res.status(200).json(result) + }) + .catch(error => { + res.status(500).send() + }) +}) + +/** + * Delete a Genre entry + */ +genre.delete("/", (req: Request, res: Response) => { + Genre.destroy({ + where: { + id: req.body.id + } + }) + .then(result => { + res.status(200).json(result) + }) + .catch(error => { + res.status(500).send() + }) }) \ No newline at end of file diff --git a/software/backend/scripts/databaseHelper.ts b/software/backend/scripts/databaseHelper.ts index a9cc106..b8e06de 100644 --- a/software/backend/scripts/databaseHelper.ts +++ b/software/backend/scripts/databaseHelper.ts @@ -88,6 +88,8 @@ export async function prepopulateDatabase() { { location["cityId"] = cityDataset.id location["urlName"] = location.name.replaceAll(" ", "-").toLowerCase() + location["imageIndoor"] = "http://localhost:3000/static/" + location["imageIndoor"] + location["imageOutdoor"] = "http://localhost:3000/static/" + location["imageOutdoor"] await Location.create(location) .then(async locationDataset => { @@ -193,14 +195,14 @@ export async function prepopulateDatabase() { }) } - for (let payment of account.payments) { - await Payment.create({ - accountId: dataset.dataValues.id, - bankName: payment.bankName, - iban: payment.iban - }) - } - }) + for (let payment of account.payments) { + await Payment.create({ + accountId: dataset.dataValues.id, + bankName: payment.bankName, + iban: payment.iban + }) + } + }) } @@ -208,6 +210,10 @@ export async function prepopulateDatabase() { ////////// Band and Concert Tables ////////// for(let band of bandsConcerts.bands) { + band.imageMembers = "http://localhost:3000/static/" + band.imageMembers + band.images = band.images.map(image => "http://localhost:3000/static/" + image) + band.logo = "http://localhost:3000/static/" + band.logo + // Create a band dataset await Band.create(band) .then(async dataset => { @@ -245,6 +251,8 @@ export async function prepopulateDatabase() { } for (let member of band.members) { + member.image = "http://localhost:3000/static/" + member.image + await Member.create({ name: member.name, image: member.image, diff --git a/software/src/components/basics/cardViewTopImage.vue b/software/src/components/basics/cardViewTopImage.vue index e8dfbe1..cdb535e 100644 --- a/software/src/components/basics/cardViewTopImage.vue +++ b/software/src/components/basics/cardViewTopImage.vue @@ -29,7 +29,7 @@ defineProps({ height="150" >