Docstrings, AdminDashboard button loading, new BannerStateEnums

This commit is contained in:
2024-11-06 18:22:03 +01:00
parent 9ec8e382cf
commit 844898bb3c
5 changed files with 128 additions and 43 deletions

View File

@@ -170,7 +170,11 @@
"bandDeleteError": "Fehler beim Löschen der Band",
"bandDeleteSuccessful": "Band erfolgreich gelöscht",
"bandSavedError": "Fehler beim Speichern der Band",
"bandSavedSuccessful": "Band erfolgreich gespeichert"
"bandSavedSuccessful": "Band erfolgreich gespeichert",
"genreDeleteError": "Fehler beim Löschen des Genres",
"genreDeleteSuccessful": "Genre erfolgreich gelöscht",
"genreSavedError": "Genre erfolgreich gespeichert",
"genreSavedSuccessful": "Fehler beim Speichern des Genres"
},
"misc": {
"404": {
@@ -212,5 +216,8 @@
"title": "Ersteinrichtung",
"description": "Die Datenbank wird eingerichtet. Dies kann 1-2 Minuten dauern. Bitte warten..."
}
},
"genre": {
"withoutBand": "ohne Band"
}
}

View File

@@ -170,7 +170,11 @@
"bandDeleteError": "Error on deleting band",
"bandDeleteSuccessful": "Band successfully deleted",
"bandSavedError": "Error on saving band",
"bandSavedSuccessful": "Band successfully saved"
"bandSavedSuccessful": "Band successfully saved",
"genreDeleteError": "Error on deleting Genre",
"genreDeleteSuccessful": "Genre successfully deleted",
"genreSavedError": "Genre successfully saved",
"genreSavedSuccessful": "Error on saving genre"
},
"misc": {
"404": {
@@ -212,5 +216,8 @@
"title": "First startup",
"description": "Creating database. This could take 1-2 minutes. Please wait..."
}
},
"genre": {
"withoutBand": "without Band"
}
}

View File

@@ -6,7 +6,6 @@ import { useConcertStore } from '@/stores/concert.store';
import { useBandStore } from '@/stores/band.store';
import { useAccountStore } from '@/stores/account.store';
import { useLocationStore } from '@/stores/location.store';
import { ref } from 'vue';
import { useExerciseStore } from '@/stores/exercise.store';
import { useGenreStore } from '@/stores/genre.store';
import { usePreferencesStore } from '@/stores/preferences.store';
@@ -45,6 +44,7 @@ concertStore.getConcerts()
<template #actions>
<outlined-button
@click="router.push('/admin/bands')"
:loading="bandStore.fetchInProgress"
>
{{ $t('misc.actions.more') }}
</outlined-button>
@@ -74,6 +74,7 @@ concertStore.getConcerts()
<template #actions>
<outlined-button
@click="router.push('/admin/concerts')"
:loading="concertStore.fetchInProgress"
>
{{ $t('misc.actions.more') }}
</outlined-button>
@@ -106,6 +107,7 @@ concertStore.getConcerts()
<template #actions>
<outlined-button
@click="router.push('/admin/locations')"
:loading="locationStore.fetchInProgress"
>
{{ $t('misc.actions.more') }}
</outlined-button>
@@ -115,7 +117,6 @@ concertStore.getConcerts()
</v-row>
<v-row>
<v-col>
<card-view
@@ -129,6 +130,7 @@ concertStore.getConcerts()
<template #actions>
<outlined-button
@click="router.push('/admin/accounts')"
:loading="accountStore.fetchInProgress"
>
{{ $t('misc.actions.more') }}
</outlined-button>
@@ -145,9 +147,16 @@ concertStore.getConcerts()
{{ genreStore.genres.length }} {{ $t('band.genre', 2) }}
</div>
<div class="text-h6 text-center text-disabled">
{{ genreStore.genres.reduce((counter, obj) => {
return obj.bands.length == 0 ? counter += 1 : counter
}, 0) }} {{ $t('genre.withoutBand') }}
</div>
<template #actions>
<outlined-button
@click="router.push('/admin/genres')"
:loading="genreStore.fetchInProgress"
>
{{ $t('misc.actions.more') }}
</outlined-button>
@@ -173,6 +182,7 @@ concertStore.getConcerts()
<template #actions>
<outlined-button
@click="router.push('/admin/files')"
:loading="preferencesStore.fetchInProgress"
>
{{ $t('misc.actions.more') }}
</outlined-button>

View File

@@ -7,6 +7,7 @@ import { BannerStateEnum } from "@/data/enums/bannerStateEnum";
export const useExerciseStore = defineStore("exerciseStore", {
state: () => ({
/** All exercise groups with sub-exercises */
exerciseGroups: ref<Array<ExerciseGroupApiModel>>([]),
/** Request to server sent, waiting for data response */
@@ -14,20 +15,34 @@ export const useExerciseStore = defineStore("exerciseStore", {
}),
actions: {
getAllExercises() {
/**
* Get all exercises and exercise groups from server
*/
async getAllExercises() {
this.fetchInProgress = true
fetchAllExerciseGroups()
await fetchAllExerciseGroups()
.then(result => {
this.exerciseGroups = result.data
this.fetchInProgress = false
})
},
solveExercise(exerciseGroupNr: number, exerciseNr: number) {
/**
* Mark an exercise as solved
*
* @param exerciseGroupNr Exercise group number (0-3)
* @param exerciseNr Exercise number (1-3)
*/
async solveExercise(exerciseGroupNr: number, exerciseNr: number) {
// Request all exercises from server
await this.getAllExercises()
const feedbackStore = useFeedbackStore()
this.fetchInProgress = true
// Change only if the exercise is not solved
if(!this.exerciseGroups[exerciseGroupNr].exercises[exerciseNr - 1].solved) {
updateExercise(exerciseGroupNr, exerciseNr, true)
.then(result => {
let bannerState = BannerStateEnum.ERROR
@@ -78,4 +93,5 @@ export const useExerciseStore = defineStore("exerciseStore", {
})
}
}
}
})

View File

@@ -9,10 +9,19 @@ import { Composer } from 'vue-i18n';
*/
export const useFeedbackStore = defineStore("feedbackStore", {
state: () => ({
/** Show notification banner in top right corner */
showBanner: ref(false),
/** Text in the notification banner */
title: ref(""),
/** Color of the notification banner */
color: ref(""),
/** Prepend icon of the notification banner */
icon: ref(""),
/** Programmatically access to language translation module */
$i18n: {},
/** Band, Location or concert on URL does not exist, redirect to 404 page */
@@ -26,6 +35,11 @@ export const useFeedbackStore = defineStore("feedbackStore", {
},
actions: {
/**
* Change the state of the banner, displays it immediately
*
* @param bannerState New banner state
*/
changeBanner(bannerState: BannerStateEnum) {
// Banner message
switch (bannerState) {
@@ -153,6 +167,25 @@ export const useFeedbackStore = defineStore("feedbackStore", {
case BannerStateEnum.BANDSAVEDSUCCESSFUL: {
this.title = this.i18n.t('bannerMessages.bandSavedSuccessful'); break;
}
////////// API Endpoint /genres //////////
case BannerStateEnum.GENREDELETEERROR: {
this.title = this.i18n.t('bannerMessages.genreDeleteError'); break;
}
case BannerStateEnum.GENREDELETESUCCESSFUL: {
this.title = this.i18n.t('bannerMessages.genreDeleteSuccessful'); break;
}
case BannerStateEnum.GENRESAVEDERROR: {
this.title = this.i18n.t('bannerMessages.genreSavedError'); break;
}
case BannerStateEnum.GENRESAVEDSUCCESSFUL: {
this.title = this.i18n.t('bannerMessages.genreSavedSuccessful'); break;
}
}
@@ -166,6 +199,8 @@ export const useFeedbackStore = defineStore("feedbackStore", {
case BannerStateEnum.ACCOUNTREGISTERUSERNAMEINUSE:
case BannerStateEnum.BANDDELETEERROR:
case BannerStateEnum.BANDSAVEDERROR:
case BannerStateEnum.GENREDELETEERROR:
case BannerStateEnum.GENRESAVEDERROR:
this.color = "red"
break;
@@ -179,6 +214,8 @@ export const useFeedbackStore = defineStore("feedbackStore", {
case BannerStateEnum.BANDDELETESUCCESSFUL:
case BannerStateEnum.BANDSAVEDSUCCESSFUL:
case BannerStateEnum.EXERCISEPROGRESSRESETSUCCESSFUL:
case BannerStateEnum.GENREDELETESUCCESSFUL:
case BannerStateEnum.GENRESAVEDSUCCESSFUL:
this.color = "green"
break;
@@ -231,6 +268,7 @@ export const useFeedbackStore = defineStore("feedbackStore", {
case BannerStateEnum.DATABASERESETSUCCESSFUL:
case BannerStateEnum.EXERCISEPROGRESSRESETSUCCESSFUL:
this.icon = "mdi-database-refresh"
break;
@@ -265,6 +303,13 @@ export const useFeedbackStore = defineStore("feedbackStore", {
case BannerStateEnum.BANDSAVEDSUCCESSFUL:
this.icon = "mdi-guitar-electric"
break;
case BannerStateEnum.GENREDELETEERROR:
case BannerStateEnum.GENREDELETESUCCESSFUL:
case BannerStateEnum.GENRESAVEDERROR:
case BannerStateEnum.GENRESAVEDSUCCESSFUL:
this.icon = "mdi-music"
break;
}
this.showBanner = true