Genre Admin page, new Genre store
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import { Rating } from "../models/acts/rating.model";
|
|
||||||
import { Band } from "../models/acts/band.model";
|
import { Band } from "../models/acts/band.model";
|
||||||
import { Genre } from "../models/acts/genre.model";
|
import { Genre } from "../models/acts/genre.model";
|
||||||
import { Request, Response, Router } from "express";
|
import { Request, Response, Router } from "express";
|
||||||
@@ -9,7 +8,9 @@ export const genre = Router()
|
|||||||
* Get all available Genres
|
* Get all available Genres
|
||||||
*/
|
*/
|
||||||
genre.get("/", (req: Request, res: Response) => {
|
genre.get("/", (req: Request, res: Response) => {
|
||||||
Genre.findAll()
|
Genre.findAll({
|
||||||
|
include: [ Band ]
|
||||||
|
})
|
||||||
.then(genres => {
|
.then(genres => {
|
||||||
res.status(200).json(genres)
|
res.status(200).json(genres)
|
||||||
})
|
})
|
||||||
|
|||||||
47
software/src/layouts/adminDataLayout.vue
Normal file
47
software/src/layouts/adminDataLayout.vue
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import outlinedButton from '@/components/basics/outlinedButton.vue';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
|
const fetchInProgress = defineModel("fetchInProgress", { default: false })
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
addButtonString: String,
|
||||||
|
onAddClick: {
|
||||||
|
type: Function,
|
||||||
|
default: () => {}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<v-container>
|
||||||
|
<v-row>
|
||||||
|
<v-col>
|
||||||
|
<outlined-button
|
||||||
|
prepend-icon="mdi-arrow-left"
|
||||||
|
@click="router.go(-1)"
|
||||||
|
>
|
||||||
|
{{ $t('misc.onePageBack') }}
|
||||||
|
</outlined-button>
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<v-col class="text-end">
|
||||||
|
<outlined-button
|
||||||
|
prepend-icon="mdi-plus"
|
||||||
|
color="green"
|
||||||
|
:disabled="fetchInProgress"
|
||||||
|
@click="onAddClick()"
|
||||||
|
>
|
||||||
|
{{ addButtonString }}
|
||||||
|
</outlined-button>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
|
||||||
|
<v-row>
|
||||||
|
<v-col>
|
||||||
|
<slot></slot>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
</v-container>
|
||||||
|
</template>
|
||||||
@@ -40,7 +40,9 @@
|
|||||||
"descriptionEn": "Beschreibung Englisch",
|
"descriptionEn": "Beschreibung Englisch",
|
||||||
"addNewBand": "Neue Band hinzufügen",
|
"addNewBand": "Neue Band hinzufügen",
|
||||||
"logo": "Band Logo",
|
"logo": "Band Logo",
|
||||||
"imageMember": "Bilder Mitglieder"
|
"imageMember": "Bilder Mitglieder",
|
||||||
|
"addNewGenre": "Neues Genre hinzufügen",
|
||||||
|
"editGenre": "Genre bearbeiten"
|
||||||
},
|
},
|
||||||
"ticket": {
|
"ticket": {
|
||||||
"tickets": "Ticket | Tickets"
|
"tickets": "Ticket | Tickets"
|
||||||
|
|||||||
@@ -40,7 +40,9 @@
|
|||||||
"descriptionEn": "Description English",
|
"descriptionEn": "Description English",
|
||||||
"addNewBand": "Add new Band",
|
"addNewBand": "Add new Band",
|
||||||
"logo": "Band logo",
|
"logo": "Band logo",
|
||||||
"imageMember": "Images Members"
|
"imageMember": "Images Members",
|
||||||
|
"addNewGenre": "Add new Genre",
|
||||||
|
"editGenre": "Edit Genre"
|
||||||
},
|
},
|
||||||
"ticket": {
|
"ticket": {
|
||||||
"tickets": "Ticket | Tickets"
|
"tickets": "Ticket | Tickets"
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ import actionDialog from '@/components/basics/actionDialog.vue';
|
|||||||
import OutlinedButton from '@/components/basics/outlinedButton.vue';
|
import OutlinedButton from '@/components/basics/outlinedButton.vue';
|
||||||
import { GenreModel } from '@/data/models/acts/genreModel';
|
import { GenreModel } from '@/data/models/acts/genreModel';
|
||||||
import { useBandStore } from '@/stores/band.store';
|
import { useBandStore } from '@/stores/band.store';
|
||||||
|
import { useGenreStore } from '@/stores/genre.store';
|
||||||
|
|
||||||
const bandStore = useBandStore()
|
const bandStore = useBandStore()
|
||||||
|
const genreStore = useGenreStore()
|
||||||
|
|
||||||
function itemProps(item: GenreModel) {
|
function itemProps(item: GenreModel) {
|
||||||
return {
|
return {
|
||||||
@@ -15,7 +17,7 @@ function itemProps(item: GenreModel) {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<action-dialog
|
<action-dialog
|
||||||
v-model="bandStore.showBandEditDialog"
|
v-model="bandStore.showEditDialog"
|
||||||
:title="$t('band.editBand')"
|
:title="$t('band.editBand')"
|
||||||
icon="mdi-pencil"
|
icon="mdi-pencil"
|
||||||
>
|
>
|
||||||
@@ -43,7 +45,7 @@ function itemProps(item: GenreModel) {
|
|||||||
<v-select
|
<v-select
|
||||||
:label="$t('band.genre', 2)"
|
:label="$t('band.genre', 2)"
|
||||||
v-model="bandStore.band.genres"
|
v-model="bandStore.band.genres"
|
||||||
:items="bandStore.availableGenres"
|
:items="genreStore.genres"
|
||||||
:item-props="itemProps"
|
:item-props="itemProps"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
hide-details
|
hide-details
|
||||||
|
|||||||
@@ -8,11 +8,13 @@ import { useAccountStore } from '@/stores/account.store';
|
|||||||
import { useLocationStore } from '@/stores/location.store';
|
import { useLocationStore } from '@/stores/location.store';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { useExerciseStore } from '@/stores/exercise.store';
|
import { useExerciseStore } from '@/stores/exercise.store';
|
||||||
|
import { useGenreStore } from '@/stores/genre.store';
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const concertStore = useConcertStore()
|
const concertStore = useConcertStore()
|
||||||
const bandStore = useBandStore()
|
const bandStore = useBandStore()
|
||||||
const accountStore = useAccountStore()
|
const accountStore = useAccountStore()
|
||||||
|
const genreStore = useGenreStore()
|
||||||
const locationStore = useLocationStore()
|
const locationStore = useLocationStore()
|
||||||
const soldOutConcerts = ref(0)
|
const soldOutConcerts = ref(0)
|
||||||
const exerciseStore = useExerciseStore()
|
const exerciseStore = useExerciseStore()
|
||||||
@@ -21,6 +23,7 @@ exerciseStore.solveExercise(2, 1)
|
|||||||
|
|
||||||
bandStore.getBands()
|
bandStore.getBands()
|
||||||
locationStore.getLocations()
|
locationStore.getLocations()
|
||||||
|
genreStore.getGenres()
|
||||||
concertStore.getConcerts()
|
concertStore.getConcerts()
|
||||||
.then(result => {
|
.then(result => {
|
||||||
for(let concert of concertStore.concerts) {
|
for(let concert of concertStore.concerts) {
|
||||||
@@ -112,7 +115,7 @@ concertStore.getConcerts()
|
|||||||
icon="mdi-account"
|
icon="mdi-account"
|
||||||
>
|
>
|
||||||
<div class="text-h4 text-center">
|
<div class="text-h4 text-center">
|
||||||
{{ bandStore.availableGenres.length }} {{ $t('band.genre', 2) }}
|
{{ genreStore.genres.length }} {{ $t('band.genre', 2) }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<template #actions>
|
<template #actions>
|
||||||
|
|||||||
38
software/src/pages/admin/genresAdminPage/genreEditDialog.vue
Normal file
38
software/src/pages/admin/genresAdminPage/genreEditDialog.vue
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import actionDialog from '@/components/basics/actionDialog.vue';
|
||||||
|
import outlinedButton from '@/components/basics/outlinedButton.vue';
|
||||||
|
import { useGenreStore } from '@/stores/genre.store';
|
||||||
|
|
||||||
|
const genreStore = useGenreStore()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<action-dialog
|
||||||
|
v-model="genreStore.showEditDialog"
|
||||||
|
:title="$t('band.editGenre')"
|
||||||
|
icon="mdi-pencil"
|
||||||
|
>
|
||||||
|
<v-container>
|
||||||
|
<v-row>
|
||||||
|
<v-col>
|
||||||
|
<v-text-field
|
||||||
|
:label="$t('band.genre')"
|
||||||
|
v-model="genreStore.genre.name"
|
||||||
|
variant="outlined"
|
||||||
|
hide-details
|
||||||
|
/>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
</v-container>
|
||||||
|
|
||||||
|
<template #actions>
|
||||||
|
<outlined-button
|
||||||
|
color="green"
|
||||||
|
@click="genreStore.saveGenre"
|
||||||
|
:loading="genreStore.fetchInProgress"
|
||||||
|
>
|
||||||
|
{{ $t('misc.actions.save') }}
|
||||||
|
</outlined-button>
|
||||||
|
</template>
|
||||||
|
</action-dialog>
|
||||||
|
</template>
|
||||||
@@ -1,6 +1,53 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import adminDataLayout from '@/layouts/adminDataLayout.vue';
|
||||||
|
import genreEditDialog from './genreEditDialog.vue';
|
||||||
|
import { useGenreStore } from '@/stores/genre.store';
|
||||||
|
|
||||||
|
const genreStore = useGenreStore()
|
||||||
|
|
||||||
|
const headers = [
|
||||||
|
{ title: "Name", value: "name" },
|
||||||
|
{ title: "Bands", value: "bands" },
|
||||||
|
{ title: "", value: "edit", width: 130 }
|
||||||
|
]
|
||||||
|
|
||||||
|
genreStore.getGenres()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
Genres Admin Page
|
<admin-data-layout
|
||||||
|
:add-button-string="$t('band.addNewGenre')"
|
||||||
|
:fetch-in-progress="genreStore.fetchInProgress"
|
||||||
|
:on-add-click="() => { genreStore.newGenre() }"
|
||||||
|
>
|
||||||
|
<v-data-table
|
||||||
|
:loading="genreStore.fetchInProgress"
|
||||||
|
:items="genreStore.genres"
|
||||||
|
:headers="headers"
|
||||||
|
>
|
||||||
|
<template #item.bands="{ item }">
|
||||||
|
<v-chip v-for="band of item.bands" class="mx-1">
|
||||||
|
{{ band.name }}
|
||||||
|
</v-chip>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #item.edit="{ item }">
|
||||||
|
<v-btn
|
||||||
|
icon="mdi-pencil"
|
||||||
|
variant="plain"
|
||||||
|
color="orange"
|
||||||
|
@click="genreStore.editGenre(item)"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<v-btn
|
||||||
|
icon="mdi-delete"
|
||||||
|
variant="plain"
|
||||||
|
color="red"
|
||||||
|
@click="genreStore.deleteGenre(item)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</v-data-table>
|
||||||
|
</admin-data-layout>
|
||||||
|
|
||||||
|
<genre-edit-dialog />
|
||||||
</template>
|
</template>
|
||||||
@@ -3,8 +3,10 @@ import cardView from '@/components/basics/cardView.vue';
|
|||||||
import { useBandStore } from '@/stores/band.store';
|
import { useBandStore } from '@/stores/band.store';
|
||||||
import outlinedButton from '@/components/basics/outlinedButton.vue';
|
import outlinedButton from '@/components/basics/outlinedButton.vue';
|
||||||
import { GenreModel } from '@/data/models/acts/genreModel';
|
import { GenreModel } from '@/data/models/acts/genreModel';
|
||||||
|
import { useGenreStore } from '@/stores/genre.store';
|
||||||
|
|
||||||
const bandStore = useBandStore()
|
const bandStore = useBandStore()
|
||||||
|
const genreStore = useGenreStore()
|
||||||
|
|
||||||
function itemProps(item: GenreModel) {
|
function itemProps(item: GenreModel) {
|
||||||
return {
|
return {
|
||||||
@@ -21,8 +23,8 @@ function itemProps(item: GenreModel) {
|
|||||||
<v-row>
|
<v-row>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-select
|
<v-select
|
||||||
v-model="bandStore.filteredGenres"
|
v-model="genreStore.filteredGenres"
|
||||||
:items="bandStore.availableGenres"
|
:items="genreStore.genres"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
:label="$t('band.genre', 2)"
|
:label="$t('band.genre', 2)"
|
||||||
:item-props="itemProps"
|
:item-props="itemProps"
|
||||||
|
|||||||
@@ -3,10 +3,9 @@ import { ref } from "vue";
|
|||||||
import { BandApiModel } from "../data/models/acts/bandApiModel";
|
import { BandApiModel } from "../data/models/acts/bandApiModel";
|
||||||
import { fetchAllBands, fetchBandByName, patchBand, postBand } from "../data/api/bandApi";
|
import { fetchAllBands, fetchBandByName, patchBand, postBand } from "../data/api/bandApi";
|
||||||
import { BandDetailsApiModel } from "../data/models/acts/bandDetailsApiModel";
|
import { BandDetailsApiModel } from "../data/models/acts/bandDetailsApiModel";
|
||||||
import { GenreModel } from "@/data/models/acts/genreModel";
|
|
||||||
import { fetchAllGenres } from "@/data/api/genreApi";
|
|
||||||
import { useFeedbackStore } from "./feedback.store";
|
import { useFeedbackStore } from "./feedback.store";
|
||||||
import { BannerStateEnum } from "@/data/enums/bannerStateEnum";
|
import { BannerStateEnum } from "@/data/enums/bannerStateEnum";
|
||||||
|
import { useGenreStore } from "./genre.store";
|
||||||
|
|
||||||
export const useBandStore = defineStore("bandStore", {
|
export const useBandStore = defineStore("bandStore", {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
@@ -16,17 +15,11 @@ export const useBandStore = defineStore("bandStore", {
|
|||||||
/** All information about a single band */
|
/** All information about a single band */
|
||||||
band: ref<BandDetailsApiModel>(new BandDetailsApiModel()),
|
band: ref<BandDetailsApiModel>(new BandDetailsApiModel()),
|
||||||
|
|
||||||
/** Genres to filter bands for */
|
|
||||||
filteredGenres: ref<Array<GenreModel>>([]),
|
|
||||||
|
|
||||||
/** All available genres from server */
|
|
||||||
availableGenres: ref<Array<GenreModel>>([]),
|
|
||||||
|
|
||||||
/** Request to server sent, waiting for data response */
|
/** Request to server sent, waiting for data response */
|
||||||
fetchInProgress: ref(false),
|
fetchInProgress: ref(false),
|
||||||
|
|
||||||
/** Show or hide the edit dialog for edit a band */
|
/** Show or hide the edit dialog for edit a band or genre */
|
||||||
showBandEditDialog: ref(false)
|
showEditDialog: ref(false)
|
||||||
}),
|
}),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
@@ -34,17 +27,18 @@ export const useBandStore = defineStore("bandStore", {
|
|||||||
* Get all bands from server
|
* Get all bands from server
|
||||||
*/
|
*/
|
||||||
async getBands() {
|
async getBands() {
|
||||||
|
const genreStore = useGenreStore()
|
||||||
this.fetchInProgress = true
|
this.fetchInProgress = true
|
||||||
|
|
||||||
await fetchAllBands()
|
await fetchAllBands()
|
||||||
.then(result => {
|
.then(result => {
|
||||||
this.bands = result.data.filter((band: BandApiModel) => {
|
this.bands = result.data.filter((band: BandApiModel) => {
|
||||||
if (this.filteredGenres.length == 0) {
|
if (genreStore.filteredGenres.length == 0) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let bandGenre of band.genres) {
|
for (let bandGenre of band.genres) {
|
||||||
for (let filteredGenres of this.filteredGenres) {
|
for (let filteredGenres of genreStore.filteredGenres) {
|
||||||
if (bandGenre.name == filteredGenres.name) {
|
if (bandGenre.name == filteredGenres.name) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -55,11 +49,6 @@ export const useBandStore = defineStore("bandStore", {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
await fetchAllGenres()
|
|
||||||
.then(result => {
|
|
||||||
this.availableGenres = result.data
|
|
||||||
})
|
|
||||||
|
|
||||||
this.fetchInProgress = false
|
this.fetchInProgress = false
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -83,10 +72,10 @@ export const useBandStore = defineStore("bandStore", {
|
|||||||
*/
|
*/
|
||||||
newBand() {
|
newBand() {
|
||||||
this.band = new BandDetailsApiModel()
|
this.band = new BandDetailsApiModel()
|
||||||
|
this.showEditDialog = true
|
||||||
this.showBandEditDialog = true
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit a band. Fetch all information about the band, opens the edit dialog
|
* Edit a band. Fetch all information about the band, opens the edit dialog
|
||||||
*
|
*
|
||||||
@@ -95,7 +84,7 @@ export const useBandStore = defineStore("bandStore", {
|
|||||||
async editBand(name: string) {
|
async editBand(name: string) {
|
||||||
await this.getBand(name)
|
await this.getBand(name)
|
||||||
|
|
||||||
this.showBandEditDialog = true
|
this.showEditDialog = true
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -112,7 +101,7 @@ export const useBandStore = defineStore("bandStore", {
|
|||||||
feedbackStore.changeBanner(BannerStateEnum.BANDSAVEDSUCCESSFUL)
|
feedbackStore.changeBanner(BannerStateEnum.BANDSAVEDSUCCESSFUL)
|
||||||
|
|
||||||
this.getBands()
|
this.getBands()
|
||||||
this.showBandEditDialog = false
|
this.showEditDialog = false
|
||||||
} else {
|
} else {
|
||||||
feedbackStore.changeBanner(BannerStateEnum.BANDSAVEDERROR)
|
feedbackStore.changeBanner(BannerStateEnum.BANDSAVEDERROR)
|
||||||
}
|
}
|
||||||
@@ -124,7 +113,7 @@ export const useBandStore = defineStore("bandStore", {
|
|||||||
feedbackStore.changeBanner(BannerStateEnum.BANDSAVEDSUCCESSFUL)
|
feedbackStore.changeBanner(BannerStateEnum.BANDSAVEDSUCCESSFUL)
|
||||||
|
|
||||||
this.getBands()
|
this.getBands()
|
||||||
this.showBandEditDialog = false
|
this.showEditDialog = false
|
||||||
} else {
|
} else {
|
||||||
feedbackStore.changeBanner(BannerStateEnum.BANDSAVEDERROR)
|
feedbackStore.changeBanner(BannerStateEnum.BANDSAVEDERROR)
|
||||||
}
|
}
|
||||||
|
|||||||
53
software/src/stores/genre.store.ts
Normal file
53
software/src/stores/genre.store.ts
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
import { fetchAllGenres } from "@/data/api/genreApi";
|
||||||
|
import { GenreApiModel } from "@/data/models/acts/genreApiModel";
|
||||||
|
import { defineStore } from "pinia";
|
||||||
|
import { ref } from "vue";
|
||||||
|
|
||||||
|
export const useGenreStore = defineStore("genreStore", {
|
||||||
|
state: () => ({
|
||||||
|
/** All available genres from server */
|
||||||
|
genres: ref<Array<GenreApiModel>>([]),
|
||||||
|
|
||||||
|
/** Currently edited genre */
|
||||||
|
genre: ref<GenreApiModel>(new GenreApiModel()),
|
||||||
|
|
||||||
|
/** Genres to filter bands for */
|
||||||
|
filteredGenres: ref<Array<GenreApiModel>>([]),
|
||||||
|
|
||||||
|
showEditDialog: ref(false),
|
||||||
|
fetchInProgress: ref(false)
|
||||||
|
}),
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
getGenres() {
|
||||||
|
this.fetchInProgress = true
|
||||||
|
|
||||||
|
fetchAllGenres()
|
||||||
|
.then(response => {
|
||||||
|
this.genres = response.data
|
||||||
|
this.fetchInProgress = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare edit dialog for new genre, opens it
|
||||||
|
*/
|
||||||
|
newGenre() {
|
||||||
|
this.genre = new GenreApiModel()
|
||||||
|
this.showEditDialog = true
|
||||||
|
},
|
||||||
|
|
||||||
|
editGenre(genre: GenreApiModel) {
|
||||||
|
this.genre = genre
|
||||||
|
this.showEditDialog = true
|
||||||
|
},
|
||||||
|
|
||||||
|
saveGenre() {
|
||||||
|
// todo
|
||||||
|
},
|
||||||
|
|
||||||
|
deleteGenre(genre: GenreApiModel) {
|
||||||
|
// todo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user