Improve Snackbar
This commit is contained in:
@@ -88,16 +88,6 @@ account.post("/", async (req: Request, res: Response) => {
|
|||||||
.then(account => {
|
.then(account => {
|
||||||
// Status: 201 Created
|
// Status: 201 Created
|
||||||
res.status(201).json(account)
|
res.status(201).json(account)
|
||||||
|
|
||||||
// Check exercise in table
|
|
||||||
Exercise.update(
|
|
||||||
{ solved: true },
|
|
||||||
{
|
|
||||||
where: {
|
|
||||||
nameEn: "Register"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}).catch(reason => {
|
}).catch(reason => {
|
||||||
// Status: 409 Conflict
|
// Status: 409 Conflict
|
||||||
res.status(409).json({
|
res.status(409).json({
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useTheme } from 'vuetify/lib/framework.mjs';
|
import { useTheme } from 'vuetify/lib/framework.mjs';
|
||||||
import { i18n } from './plugins/i18n';
|
import { i18n } from './plugins/i18n';
|
||||||
import { watch } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
import navigationAppendItems from './components/navigation/navigationAppendItems.vue';
|
|
||||||
import navigationPrependItems from './components/navigation/navigationPrependItems.vue';
|
|
||||||
import { usePreferencesStore } from './stores/preferences.store';
|
import { usePreferencesStore } from './stores/preferences.store';
|
||||||
import { useFeedbackStore } from './stores/feedback.store';
|
import { useFeedbackStore } from './stores/feedback.store';
|
||||||
import companyFooter from './components/navigation/companyFooter.vue';
|
import companyFooter from './components/navigation/companyFooter.vue';
|
||||||
import urlBar from './components/navigation/urlBar.vue';
|
import urlBar from './components/navigation/urlBar.vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import NavigationBar from './components/navigation/navigationBar.vue';
|
import NavigationBar from './components/navigation/navigationBar.vue';
|
||||||
|
import { BannerStateEnum } from './data/enums/bannerStateEnum';
|
||||||
|
|
||||||
const preferencesStore = usePreferencesStore()
|
const preferencesStore = usePreferencesStore()
|
||||||
const feedbackStore = useFeedbackStore()
|
const feedbackStore = useFeedbackStore()
|
||||||
@@ -27,6 +26,7 @@ watch(() => preferencesStore.language, () => {
|
|||||||
// Watch for theme change
|
// Watch for theme change
|
||||||
watch(() => preferencesStore.theme, () => {
|
watch(() => preferencesStore.theme, () => {
|
||||||
theme.global.name.value = preferencesStore.theme
|
theme.global.name.value = preferencesStore.theme
|
||||||
|
feedbackStore.addSnackbar(BannerStateEnum.ERROR)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Watch for 404 page directions
|
// Watch for 404 page directions
|
||||||
@@ -36,6 +36,17 @@ watch(() => feedbackStore.notFound, () => {
|
|||||||
router.push("/404")
|
router.push("/404")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Watch for snackbar disappear
|
||||||
|
watch(() => feedbackStore.showSnackbar, () => {
|
||||||
|
if (!feedbackStore.showSnackbar) {
|
||||||
|
feedbackStore.snackbars = []
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
function calcMargin(i) {
|
||||||
|
return (i * 60) + 10 + 'px'
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -50,22 +61,18 @@ watch(() => feedbackStore.notFound, () => {
|
|||||||
<v-main>
|
<v-main>
|
||||||
<!-- Snackbar in the top right corner for user feedback -->
|
<!-- Snackbar in the top right corner for user feedback -->
|
||||||
<v-snackbar
|
<v-snackbar
|
||||||
v-model="feedbackStore.showBanner"
|
v-for="(s, i) in feedbackStore.snackbars"
|
||||||
|
v-model="feedbackStore.showSnackbar"
|
||||||
|
:key="i"
|
||||||
timeout="3000"
|
timeout="3000"
|
||||||
location="top right"
|
location="top right"
|
||||||
:color="feedbackStore.color"
|
:color="s.color"
|
||||||
|
:style="{ 'margin-top': calcMargin(i) }"
|
||||||
|
:icon="s.icon"
|
||||||
close
|
close
|
||||||
>
|
>
|
||||||
<v-icon :icon="feedbackStore.icon" />
|
<v-icon :icon="s.icon" />
|
||||||
{{ feedbackStore.title }}
|
{{ s.text }}
|
||||||
|
|
||||||
<template v-slot:actions>
|
|
||||||
<v-btn
|
|
||||||
variant="text"
|
|
||||||
@click="feedbackStore.showBanner = false"
|
|
||||||
icon="mdi-close"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</v-snackbar>
|
</v-snackbar>
|
||||||
|
|
||||||
<!-- Here changes the router the content -->
|
<!-- Here changes the router the content -->
|
||||||
|
|||||||
@@ -24,7 +24,13 @@ function confirmPressed() {
|
|||||||
v-model="showDialog"
|
v-model="showDialog"
|
||||||
persistent
|
persistent
|
||||||
>
|
>
|
||||||
{{ description }}
|
<v-container>
|
||||||
|
<v-row>
|
||||||
|
<v-col>
|
||||||
|
{{ description }}
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
</v-container>
|
||||||
|
|
||||||
<template #actions>
|
<template #actions>
|
||||||
<outlined-button
|
<outlined-button
|
||||||
|
|||||||
@@ -170,6 +170,7 @@
|
|||||||
"wrongLogin": "Falscher Username oder falsches Passwort!",
|
"wrongLogin": "Falscher Username oder falsches Passwort!",
|
||||||
"error": "Es ist ein Fehler aufgetreten...",
|
"error": "Es ist ein Fehler aufgetreten...",
|
||||||
"databaseResetSuccessful": "Datenbank erfolgreich zurück gesetzt!",
|
"databaseResetSuccessful": "Datenbank erfolgreich zurück gesetzt!",
|
||||||
|
"exerciseProgressResetSuccessful": "Aufgabenfortschritt erfolgreich zurück gesetzt!",
|
||||||
"registerSuccessful": "Account erfolgreich erstellt!",
|
"registerSuccessful": "Account erfolgreich erstellt!",
|
||||||
"usernameInUse": "Der Accountname ist bereits vergeben!",
|
"usernameInUse": "Der Accountname ist bereits vergeben!",
|
||||||
"accountUpdated": "Account erfolgreich aktualisiert",
|
"accountUpdated": "Account erfolgreich aktualisiert",
|
||||||
|
|||||||
@@ -170,6 +170,7 @@
|
|||||||
"wrongLogin": "Wrong username or wrong password!",
|
"wrongLogin": "Wrong username or wrong password!",
|
||||||
"error": "There is some error...",
|
"error": "There is some error...",
|
||||||
"databaseResetSuccessful": "Database successfully resetted!",
|
"databaseResetSuccessful": "Database successfully resetted!",
|
||||||
|
"exerciseProgressResetSuccessful": "Exercise progress successfully resetted!",
|
||||||
"registerSuccessful": "Account successfully created!",
|
"registerSuccessful": "Account successfully created!",
|
||||||
"usernameInUse": "The username is already in use!",
|
"usernameInUse": "The username is already in use!",
|
||||||
"accountUpdated": "Account successfully updated",
|
"accountUpdated": "Account successfully updated",
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { PaymentModel } from "../data/models/user/paymentModel";
|
|||||||
import { AccountApiModel } from "../data/models/user/accountApiModel";
|
import { AccountApiModel } from "../data/models/user/accountApiModel";
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
|
import { useExerciseStore } from "./exercise.store";
|
||||||
|
|
||||||
export const useAccountStore = defineStore("accountStore", {
|
export const useAccountStore = defineStore("accountStore", {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
@@ -21,7 +22,7 @@ export const useAccountStore = defineStore("accountStore", {
|
|||||||
/** User input on login screen */
|
/** User input on login screen */
|
||||||
// todo: Remove JSON!
|
// todo: Remove JSON!
|
||||||
loginData: ref<{ username: String, password: String}>(
|
loginData: ref<{ username: String, password: String}>(
|
||||||
{ username: "duranduran", password: "H4nn0ver" }
|
{ username: "", password: "" }
|
||||||
),
|
),
|
||||||
|
|
||||||
/** Buffer for register data */
|
/** Buffer for register data */
|
||||||
@@ -55,31 +56,31 @@ export const useAccountStore = defineStore("accountStore", {
|
|||||||
if (this.loginData.username == null || this.loginData.username.length == 0 ||
|
if (this.loginData.username == null || this.loginData.username.length == 0 ||
|
||||||
this.loginData.password == null || this.loginData.password.length == 0
|
this.loginData.password == null || this.loginData.password.length == 0
|
||||||
) {
|
) {
|
||||||
feedbackStore.changeBanner(BannerStateEnum.ACCOUNTLOGINWRONGLOGIN)
|
feedbackStore.addSnackbar(BannerStateEnum.ACCOUNTLOGINWRONGLOGIN)
|
||||||
this.fetchInProgress = false
|
this.fetchInProgress = false
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await loginAccount(this.loginData.username, this.loginData.password)
|
await loginAccount(this.loginData.username, this.loginData.password)
|
||||||
.then(async result => {
|
.then(async result => {
|
||||||
this.userAccount = result.data
|
this.userAccount = result.data
|
||||||
|
|
||||||
feedbackStore.changeBanner(BannerStateEnum.ACCOUNTLOGINSUCCESSFUL)
|
feedbackStore.addSnackbar(BannerStateEnum.ACCOUNTLOGINSUCCESSFUL)
|
||||||
|
|
||||||
this.fetchInProgress = false
|
this.fetchInProgress = false
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
if (error.status == 400) {
|
if (error.status == 400) {
|
||||||
feedbackStore.changeBanner(BannerStateEnum.ACCOUNTLOGINERROR)
|
feedbackStore.addSnackbar(BannerStateEnum.ACCOUNTLOGINERROR)
|
||||||
} else if (error.status == 401) {
|
} else if (error.status == 401) {
|
||||||
feedbackStore.changeBanner(BannerStateEnum.ACCOUNTLOGINWRONGLOGIN)
|
feedbackStore.addSnackbar(BannerStateEnum.ACCOUNTLOGINWRONGLOGIN)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fetchInProgress = false
|
this.fetchInProgress = false
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -91,12 +92,14 @@ export const useAccountStore = defineStore("accountStore", {
|
|||||||
*/
|
*/
|
||||||
async registerAccount(): Promise<boolean> {
|
async registerAccount(): Promise<boolean> {
|
||||||
const feedbackStore = useFeedbackStore()
|
const feedbackStore = useFeedbackStore()
|
||||||
|
const exerciseStore = useExerciseStore()
|
||||||
this.fetchInProgress = true
|
this.fetchInProgress = true
|
||||||
|
|
||||||
await registerAccount(this.registerData)
|
await registerAccount(this.registerData)
|
||||||
.then(async res => {
|
.then(async res => {
|
||||||
if (res.status == 201) {
|
if (res.status == 201) {
|
||||||
feedbackStore.changeBanner(BannerStateEnum.ACCOUNTREGISTERSUCCESSFUL)
|
feedbackStore.addSnackbar(BannerStateEnum.ACCOUNTREGISTERSUCCESSFUL)
|
||||||
|
exerciseStore.solveExercise(0, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loginData = {
|
this.loginData = {
|
||||||
@@ -108,9 +111,9 @@ export const useAccountStore = defineStore("accountStore", {
|
|||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
if (error.status == 400) {
|
if (error.status == 400) {
|
||||||
feedbackStore.changeBanner(BannerStateEnum.ACCOUNTREGISTERERROR)
|
feedbackStore.addSnackbar(BannerStateEnum.ACCOUNTREGISTERERROR)
|
||||||
} else if (error.status == 409) {
|
} else if (error.status == 409) {
|
||||||
feedbackStore.changeBanner(BannerStateEnum.ACCOUNTREGISTERUSERNAMEINUSE)
|
feedbackStore.addSnackbar(BannerStateEnum.ACCOUNTREGISTERUSERNAMEINUSE)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fetchInProgress = false
|
this.fetchInProgress = false
|
||||||
@@ -129,7 +132,7 @@ export const useAccountStore = defineStore("accountStore", {
|
|||||||
await updateAccount(this.userAccount)
|
await updateAccount(this.userAccount)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res.status == 200) {
|
if (res.status == 200) {
|
||||||
feedbackStore.changeBanner(BannerStateEnum.ACCOUNTUPDATESUCCESSFUL)
|
feedbackStore.addSnackbar(BannerStateEnum.ACCOUNTUPDATESUCCESSFUL)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -143,7 +146,7 @@ export const useAccountStore = defineStore("accountStore", {
|
|||||||
this.userAccount = new AccountModel()
|
this.userAccount = new AccountModel()
|
||||||
this.loggedIn = false
|
this.loggedIn = false
|
||||||
|
|
||||||
feedbackStore.changeBanner(BannerStateEnum.ACCOUNTLOGOUTSUCCESSFUL)
|
feedbackStore.addSnackbar(BannerStateEnum.ACCOUNTLOGOUTSUCCESSFUL)
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -102,24 +102,24 @@ export const useBandStore = defineStore("bandStore", {
|
|||||||
postBand(this.band)
|
postBand(this.band)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
if (result.status == 200) {
|
if (result.status == 200) {
|
||||||
feedbackStore.changeBanner(BannerStateEnum.BANDSAVEDSUCCESSFUL)
|
feedbackStore.addSnackbar(BannerStateEnum.BANDSAVEDSUCCESSFUL)
|
||||||
|
|
||||||
this.getBands()
|
this.getBands()
|
||||||
this.showEditDialog = false
|
this.showEditDialog = false
|
||||||
} else {
|
} else {
|
||||||
feedbackStore.changeBanner(BannerStateEnum.BANDSAVEDERROR)
|
feedbackStore.addSnackbar(BannerStateEnum.BANDSAVEDERROR)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
patchBand(this.band)
|
patchBand(this.band)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
if (result.status == 200) {
|
if (result.status == 200) {
|
||||||
feedbackStore.changeBanner(BannerStateEnum.BANDSAVEDSUCCESSFUL)
|
feedbackStore.addSnackbar(BannerStateEnum.BANDSAVEDSUCCESSFUL)
|
||||||
|
|
||||||
this.getBands()
|
this.getBands()
|
||||||
this.showEditDialog = false
|
this.showEditDialog = false
|
||||||
} else {
|
} else {
|
||||||
feedbackStore.changeBanner(BannerStateEnum.BANDSAVEDERROR)
|
feedbackStore.addSnackbar(BannerStateEnum.BANDSAVEDERROR)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export const useBasketStore = defineStore('basketStore', {
|
|||||||
*/
|
*/
|
||||||
removeItemFromBasket(item: BasketItemModel) {
|
removeItemFromBasket(item: BasketItemModel) {
|
||||||
const feedbackStore = useFeedbackStore()
|
const feedbackStore = useFeedbackStore()
|
||||||
feedbackStore.changeBanner(BannerStateEnum.BASKETPRODUCTREMOVED)
|
feedbackStore.addSnackbar(BannerStateEnum.BASKETPRODUCTREMOVED)
|
||||||
|
|
||||||
this.itemsInBasket = this.itemsInBasket.filter((basketItemModel: BasketItemModel) =>
|
this.itemsInBasket = this.itemsInBasket.filter((basketItemModel: BasketItemModel) =>
|
||||||
basketItemModel.concert.id != item.concert.id
|
basketItemModel.concert.id != item.concert.id
|
||||||
@@ -110,12 +110,12 @@ export const useBasketStore = defineStore('basketStore', {
|
|||||||
await accountStore.refreshOrders()
|
await accountStore.refreshOrders()
|
||||||
|
|
||||||
this.itemsInBasket = []
|
this.itemsInBasket = []
|
||||||
feedbackStore.changeBanner(BannerStateEnum.ORDERPLACESUCCESSFUL)
|
feedbackStore.addSnackbar(BannerStateEnum.ORDERPLACESUCCESSFUL)
|
||||||
|
|
||||||
// Exercise 0.2 is solved
|
// Exercise 0.2 is solved
|
||||||
exerciseStore.solveExercise(0, 2)
|
exerciseStore.solveExercise(0, 2)
|
||||||
} else {
|
} else {
|
||||||
feedbackStore.changeBanner(BannerStateEnum.ERROR)
|
feedbackStore.addSnackbar(BannerStateEnum.ERROR)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ export const useExerciseStore = defineStore("exerciseStore", {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
feedbackStore.changeBanner(bannerState)
|
feedbackStore.addSnackbar(bannerState)
|
||||||
this.getAllExercises()
|
this.getAllExercises()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -9,8 +9,10 @@ import { Composer } from 'vue-i18n';
|
|||||||
*/
|
*/
|
||||||
export const useFeedbackStore = defineStore("feedbackStore", {
|
export const useFeedbackStore = defineStore("feedbackStore", {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
|
snackbars: ref<Array<{text: string, color: string, icon: string }>>([]),
|
||||||
|
|
||||||
/** Show notification banner in top right corner */
|
/** Show notification banner in top right corner */
|
||||||
showBanner: ref(false),
|
showSnackbar: ref(false),
|
||||||
|
|
||||||
/** Text in the notification banner */
|
/** Text in the notification banner */
|
||||||
title: ref(""),
|
title: ref(""),
|
||||||
@@ -35,162 +37,148 @@ export const useFeedbackStore = defineStore("feedbackStore", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
/**
|
addSnackbar(bannerState: BannerStateEnum) {
|
||||||
* Change the state of the banner, displays it immediately
|
this.snackbars.push({
|
||||||
*
|
text: this.getSnackbarText(bannerState),
|
||||||
* @param bannerState New banner state
|
color: this.getSnackbarColor(bannerState),
|
||||||
*/
|
icon: this.getSnackbarIcon(bannerState)
|
||||||
changeBanner(bannerState: BannerStateEnum) {
|
})
|
||||||
// Banner message
|
|
||||||
|
this.showSnackbar = true
|
||||||
|
},
|
||||||
|
|
||||||
|
getSnackbarText(bannerState: BannerStateEnum) {
|
||||||
switch (bannerState) {
|
switch (bannerState) {
|
||||||
////////// System feedback //////////
|
////////// System feedback //////////
|
||||||
|
|
||||||
case BannerStateEnum.ERROR: {
|
case BannerStateEnum.ERROR:
|
||||||
this.title = this.i18n.t('bannerMessages.error'); break;
|
return this.i18n.t('bannerMessages.error')
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.BASKETPRODUCTADDED: {
|
case BannerStateEnum.BASKETPRODUCTADDED:
|
||||||
this.title = this.i18n.t('bannerMessages.basketTicketAdded'); break;
|
return this.i18n.t('bannerMessages.basketTicketAdded')
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.BASKETPRODUCTREMOVED: {
|
case BannerStateEnum.BASKETPRODUCTREMOVED:
|
||||||
this.title = this.i18n.t("bannerMessages.basketTicketRemoved"); break;
|
return this.i18n.t("bannerMessages.basketTicketRemoved")
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////// Exercise feedback //////////
|
////////// Exercise feedback //////////
|
||||||
|
|
||||||
case BannerStateEnum.EXERCISESOLVED01: {
|
case BannerStateEnum.EXERCISESOLVED01:
|
||||||
this.title = this.i18n.t("bannerMessages.exerciseSolvedNr", [0, 1]); break;
|
return this.i18n.t("bannerMessages.exerciseSolvedNr", [0, 1])
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.EXERCISESOLVED02: {
|
|
||||||
this.title = this.i18n.t("bannerMessages.exerciseSolvedNr", [0, 2]); break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.EXERCISESOLVED11: {
|
case BannerStateEnum.EXERCISESOLVED02:
|
||||||
this.title = this.i18n.t("bannerMessages.exerciseSolvedNr", [1, 1]); break;
|
return this.i18n.t("bannerMessages.exerciseSolvedNr", [0, 2])
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.EXERCISESOLVED12: {
|
|
||||||
this.title = this.i18n.t("bannerMessages.exerciseSolvedNr", [1, 2]); break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.EXERCISESOLVED13: {
|
case BannerStateEnum.EXERCISESOLVED11:
|
||||||
this.title = this.i18n.t("bannerMessages.exerciseSolvedNr", [1, 3]); break;
|
return this.i18n.t("bannerMessages.exerciseSolvedNr", [1, 1])
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.EXERCISESOLVED21: {
|
|
||||||
this.title = this.i18n.t("bannerMessages.exerciseSolvedNr", [2, 1]); break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.EXERCISESOLVED22: {
|
case BannerStateEnum.EXERCISESOLVED12:
|
||||||
this.title = this.i18n.t("bannerMessages.exerciseSolvedNr", [2, 2]); break;
|
return this.i18n.t("bannerMessages.exerciseSolvedNr", [1, 2])
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.EXERCISESOLVED23: {
|
|
||||||
this.title = this.i18n.t("bannerMessages.exerciseSolvedNr", [2, 3]); break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.EXERCISESOLVED31: {
|
case BannerStateEnum.EXERCISESOLVED13:
|
||||||
this.title = this.i18n.t("bannerMessages.exerciseSolvedNr", [3, 1]); break;
|
return this.i18n.t("bannerMessages.exerciseSolvedNr", [1, 3])
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.EXERCISESOLVED32: {
|
|
||||||
this.title = this.i18n.t("bannerMessages.exerciseSolvedNr", [3, 2]); break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.EXERCISESOLVED33: {
|
case BannerStateEnum.EXERCISESOLVED21:
|
||||||
this.title = this.i18n.t("bannerMessages.exerciseSolvedNr", [3, 3]); break;
|
return this.i18n.t("bannerMessages.exerciseSolvedNr", [2, 1])
|
||||||
}
|
|
||||||
|
|
||||||
|
case BannerStateEnum.EXERCISESOLVED22:
|
||||||
|
return this.i18n.t("bannerMessages.exerciseSolvedNr", [2, 2])
|
||||||
|
|
||||||
|
|
||||||
|
case BannerStateEnum.EXERCISESOLVED23:
|
||||||
|
return this.i18n.t("bannerMessages.exerciseSolvedNr", [2, 3])
|
||||||
|
|
||||||
|
|
||||||
|
case BannerStateEnum.EXERCISESOLVED31:
|
||||||
|
return this.i18n.t("bannerMessages.exerciseSolvedNr", [3, 1])
|
||||||
|
|
||||||
|
|
||||||
|
case BannerStateEnum.EXERCISESOLVED32:
|
||||||
|
return this.i18n.t("bannerMessages.exerciseSolvedNr", [3, 2])
|
||||||
|
|
||||||
|
|
||||||
|
case BannerStateEnum.EXERCISESOLVED33:
|
||||||
|
return this.i18n.t("bannerMessages.exerciseSolvedNr", [3, 3])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////// API Endpoint /api //////////
|
////////// API Endpoint /api //////////
|
||||||
|
|
||||||
case BannerStateEnum.DATABASERESETSUCCESSFUL: {
|
case BannerStateEnum.DATABASERESETSUCCESSFUL:
|
||||||
this.title = this.i18n.t('bannerMessages.databaseResetSuccessful'); break;
|
return this.i18n.t('bannerMessages.databaseResetSuccessful')
|
||||||
}
|
|
||||||
|
case BannerStateEnum.EXERCISEPROGRESSRESETSUCCESSFUL:
|
||||||
|
return this.i18n.t('bannerMessages.exerciseProgressResetSuccessful')
|
||||||
|
|
||||||
|
|
||||||
////////// API Endpoint /accounts //////////
|
////////// API Endpoint /accounts //////////
|
||||||
|
|
||||||
case BannerStateEnum.ACCOUNTLOGINSUCCESSFUL: {
|
case BannerStateEnum.ACCOUNTLOGINSUCCESSFUL:
|
||||||
this.title = this.i18n.t('bannerMessages.loginSuccessful'); break;
|
return this.i18n.t('bannerMessages.loginSuccessful')
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.ACCOUNTLOGINWRONGLOGIN: {
|
case BannerStateEnum.ACCOUNTLOGINWRONGLOGIN:
|
||||||
this.title = this.i18n.t('bannerMessages.wrongLogin'); break;
|
return this.i18n.t('bannerMessages.wrongLogin')
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.ACCOUNTLOGINERROR: {
|
case BannerStateEnum.ACCOUNTLOGINERROR:
|
||||||
this.title = this.i18n.t('bannerMessages.error'); break;
|
return this.i18n.t('bannerMessages.error')
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.ACCOUNTREGISTERSUCCESSFUL: {
|
case BannerStateEnum.ACCOUNTREGISTERSUCCESSFUL:
|
||||||
this.title = this.i18n.t("bannerMessages.registerSuccessful"); break;
|
return this.i18n.t("bannerMessages.registerSuccessful")
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.ACCOUNTREGISTERUSERNAMEINUSE: {
|
case BannerStateEnum.ACCOUNTREGISTERUSERNAMEINUSE:
|
||||||
this.title = this.i18n.t("bannerMessages.usernameInUse"); break;
|
return this.i18n.t("bannerMessages.usernameInUse")
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.ACCOUNTUPDATESUCCESSFUL: {
|
case BannerStateEnum.ACCOUNTUPDATESUCCESSFUL:
|
||||||
this.title = this.i18n.t("bannerMessages.accountUpdated"); break;
|
return this.i18n.t("bannerMessages.accountUpdated")
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.ACCOUNTLOGOUTSUCCESSFUL: {
|
case BannerStateEnum.ACCOUNTLOGOUTSUCCESSFUL:
|
||||||
this.title = this.i18n.t('bannerMessages.logoutSuccessful'); break;
|
return this.i18n.t('bannerMessages.logoutSuccessful')
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////// API Endpoint /orders //////////
|
////////// API Endpoint /orders //////////
|
||||||
|
|
||||||
case BannerStateEnum.ORDERPLACESUCCESSFUL: {
|
case BannerStateEnum.ORDERPLACESUCCESSFUL:
|
||||||
this.title = this.i18n.t('bannerMessages.orderPlaceSuccessfull'); break;
|
return this.i18n.t('bannerMessages.orderPlaceSuccessfull')
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////// API Endpoint /bands //////////
|
////////// API Endpoint /bands //////////
|
||||||
|
|
||||||
case BannerStateEnum.BANDDELETEERROR: {
|
case BannerStateEnum.BANDDELETEERROR:
|
||||||
this.title = this.i18n.t('bannerMessages.bandDeleteError'); break;
|
return this.i18n.t('bannerMessages.bandDeleteError')
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.BANDDELETESUCCESSFUL: {
|
case BannerStateEnum.BANDDELETESUCCESSFUL:
|
||||||
this.title = this.i18n.t('bannerMessages.bandDeleteSuccessful'); break;
|
return this.i18n.t('bannerMessages.bandDeleteSuccessful')
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.BANDSAVEDERROR: {
|
case BannerStateEnum.BANDSAVEDERROR:
|
||||||
this.title = this.i18n.t('bannerMessages.bandSavedError'); break;
|
return this.i18n.t('bannerMessages.bandSavedError')
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.BANDSAVEDSUCCESSFUL: {
|
case BannerStateEnum.BANDSAVEDSUCCESSFUL:
|
||||||
this.title = this.i18n.t('bannerMessages.bandSavedSuccessful'); break;
|
return this.i18n.t('bannerMessages.bandSavedSuccessful')
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////// API Endpoint /genres //////////
|
////////// API Endpoint /genres //////////
|
||||||
|
|
||||||
case BannerStateEnum.GENREDELETEERROR: {
|
case BannerStateEnum.GENREDELETEERROR:
|
||||||
this.title = this.i18n.t('bannerMessages.genreDeleteError'); break;
|
return this.i18n.t('bannerMessages.genreDeleteError')
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.GENREDELETESUCCESSFUL: {
|
case BannerStateEnum.GENREDELETESUCCESSFUL:
|
||||||
this.title = this.i18n.t('bannerMessages.genreDeleteSuccessful'); break;
|
return this.i18n.t('bannerMessages.genreDeleteSuccessful')
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.GENRESAVEDERROR: {
|
case BannerStateEnum.GENRESAVEDERROR:
|
||||||
this.title = this.i18n.t('bannerMessages.genreSavedError'); break;
|
return this.i18n.t('bannerMessages.genreSavedError')
|
||||||
}
|
|
||||||
|
|
||||||
case BannerStateEnum.GENRESAVEDSUCCESSFUL: {
|
case BannerStateEnum.GENRESAVEDSUCCESSFUL:
|
||||||
this.title = this.i18n.t('bannerMessages.genreSavedSuccessful'); break;
|
return this.i18n.t('bannerMessages.genreSavedSuccessful')
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getSnackbarColor(bannerState: BannerStateEnum) {
|
||||||
// Banner color
|
|
||||||
|
|
||||||
switch (bannerState) {
|
switch (bannerState) {
|
||||||
case BannerStateEnum.ERROR:
|
case BannerStateEnum.ERROR:
|
||||||
case BannerStateEnum.ACCOUNTLOGINERROR:
|
case BannerStateEnum.ACCOUNTLOGINERROR:
|
||||||
@@ -201,8 +189,7 @@ export const useFeedbackStore = defineStore("feedbackStore", {
|
|||||||
case BannerStateEnum.BANDSAVEDERROR:
|
case BannerStateEnum.BANDSAVEDERROR:
|
||||||
case BannerStateEnum.GENREDELETEERROR:
|
case BannerStateEnum.GENREDELETEERROR:
|
||||||
case BannerStateEnum.GENRESAVEDERROR:
|
case BannerStateEnum.GENRESAVEDERROR:
|
||||||
this.color = "red"
|
return "red"
|
||||||
break;
|
|
||||||
|
|
||||||
case BannerStateEnum.BASKETPRODUCTADDED:
|
case BannerStateEnum.BASKETPRODUCTADDED:
|
||||||
case BannerStateEnum.DATABASERESETSUCCESSFUL:
|
case BannerStateEnum.DATABASERESETSUCCESSFUL:
|
||||||
@@ -216,8 +203,7 @@ export const useFeedbackStore = defineStore("feedbackStore", {
|
|||||||
case BannerStateEnum.EXERCISEPROGRESSRESETSUCCESSFUL:
|
case BannerStateEnum.EXERCISEPROGRESSRESETSUCCESSFUL:
|
||||||
case BannerStateEnum.GENREDELETESUCCESSFUL:
|
case BannerStateEnum.GENREDELETESUCCESSFUL:
|
||||||
case BannerStateEnum.GENRESAVEDSUCCESSFUL:
|
case BannerStateEnum.GENRESAVEDSUCCESSFUL:
|
||||||
this.color = "green"
|
return "green"
|
||||||
break;
|
|
||||||
|
|
||||||
case BannerStateEnum.EXERCISESOLVED01:
|
case BannerStateEnum.EXERCISESOLVED01:
|
||||||
case BannerStateEnum.EXERCISESOLVED02:
|
case BannerStateEnum.EXERCISESOLVED02:
|
||||||
@@ -230,27 +216,24 @@ export const useFeedbackStore = defineStore("feedbackStore", {
|
|||||||
case BannerStateEnum.EXERCISESOLVED31:
|
case BannerStateEnum.EXERCISESOLVED31:
|
||||||
case BannerStateEnum.EXERCISESOLVED32:
|
case BannerStateEnum.EXERCISESOLVED32:
|
||||||
case BannerStateEnum.EXERCISESOLVED33:
|
case BannerStateEnum.EXERCISESOLVED33:
|
||||||
this.color = "purple"
|
return "purple"
|
||||||
break;
|
|
||||||
|
|
||||||
case BannerStateEnum.BASKETPRODUCTREMOVED:
|
case BannerStateEnum.BASKETPRODUCTREMOVED:
|
||||||
this.color = "blue"
|
return "blue"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
// Banner icon
|
getSnackbarIcon(bannerState: BannerStateEnum) {
|
||||||
|
|
||||||
switch (bannerState) {
|
switch (bannerState) {
|
||||||
case BannerStateEnum.ERROR:
|
case BannerStateEnum.ERROR:
|
||||||
this.icon = "mdi-alert-circle"
|
return "mdi-alert-circle"
|
||||||
break;
|
|
||||||
|
|
||||||
case BannerStateEnum.ACCOUNTLOGINERROR:
|
case BannerStateEnum.ACCOUNTLOGINERROR:
|
||||||
case BannerStateEnum.ACCOUNTLOGINWRONGLOGIN:
|
case BannerStateEnum.ACCOUNTLOGINWRONGLOGIN:
|
||||||
case BannerStateEnum.ACCOUNTREGISTERERROR:
|
case BannerStateEnum.ACCOUNTREGISTERERROR:
|
||||||
case BannerStateEnum.ACCOUNTREGISTERUSERNAMEINUSE:
|
case BannerStateEnum.ACCOUNTREGISTERUSERNAMEINUSE:
|
||||||
this.icon = "mdi-account"
|
return "mdi-account"
|
||||||
break;
|
|
||||||
|
|
||||||
case BannerStateEnum.EXERCISESOLVED01:
|
case BannerStateEnum.EXERCISESOLVED01:
|
||||||
case BannerStateEnum.EXERCISESOLVED02:
|
case BannerStateEnum.EXERCISESOLVED02:
|
||||||
@@ -263,56 +246,43 @@ export const useFeedbackStore = defineStore("feedbackStore", {
|
|||||||
case BannerStateEnum.EXERCISESOLVED31:
|
case BannerStateEnum.EXERCISESOLVED31:
|
||||||
case BannerStateEnum.EXERCISESOLVED32:
|
case BannerStateEnum.EXERCISESOLVED32:
|
||||||
case BannerStateEnum.EXERCISESOLVED33:
|
case BannerStateEnum.EXERCISESOLVED33:
|
||||||
this.icon = "mdi-check-circle-outline"
|
return "mdi-check-circle-outline"
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
case BannerStateEnum.DATABASERESETSUCCESSFUL:
|
case BannerStateEnum.DATABASERESETSUCCESSFUL:
|
||||||
case BannerStateEnum.EXERCISEPROGRESSRESETSUCCESSFUL:
|
case BannerStateEnum.EXERCISEPROGRESSRESETSUCCESSFUL:
|
||||||
this.icon = "mdi-database-refresh"
|
return "mdi-database-refresh"
|
||||||
break;
|
|
||||||
|
|
||||||
case BannerStateEnum.BASKETPRODUCTADDED:
|
case BannerStateEnum.BASKETPRODUCTADDED:
|
||||||
case BannerStateEnum.BASKETPRODUCTREMOVED:
|
case BannerStateEnum.BASKETPRODUCTREMOVED:
|
||||||
this.icon = "mdi-basket"
|
return "mdi-basket"
|
||||||
break;
|
|
||||||
|
|
||||||
case BannerStateEnum.ORDERPLACESUCCESSFUL:
|
case BannerStateEnum.ORDERPLACESUCCESSFUL:
|
||||||
this.icon = "mdi-basket-check"
|
return "mdi-basket-check"
|
||||||
break;
|
|
||||||
|
|
||||||
case BannerStateEnum.ACCOUNTLOGOUTSUCCESSFUL:
|
case BannerStateEnum.ACCOUNTLOGOUTSUCCESSFUL:
|
||||||
this.icon = "mdi-logout"
|
return "mdi-logout"
|
||||||
break;
|
|
||||||
|
|
||||||
case BannerStateEnum.ACCOUNTLOGINSUCCESSFUL:
|
case BannerStateEnum.ACCOUNTLOGINSUCCESSFUL:
|
||||||
this.icon = "mdi-login"
|
return "mdi-login"
|
||||||
break;
|
|
||||||
|
|
||||||
case BannerStateEnum.ACCOUNTREGISTERSUCCESSFUL:
|
case BannerStateEnum.ACCOUNTREGISTERSUCCESSFUL:
|
||||||
this.icon = "mdi-account-plus"
|
return "mdi-account-plus"
|
||||||
break;
|
|
||||||
|
|
||||||
case BannerStateEnum.ACCOUNTUPDATESUCCESSFUL:
|
case BannerStateEnum.ACCOUNTUPDATESUCCESSFUL:
|
||||||
this.icon = "mdi-account-reactivate"
|
return "mdi-account-reactivate"
|
||||||
break;
|
|
||||||
|
|
||||||
case BannerStateEnum.BANDDELETEERROR:
|
case BannerStateEnum.BANDDELETEERROR:
|
||||||
case BannerStateEnum.BANDDELETESUCCESSFUL:
|
case BannerStateEnum.BANDDELETESUCCESSFUL:
|
||||||
case BannerStateEnum.BANDSAVEDERROR:
|
case BannerStateEnum.BANDSAVEDERROR:
|
||||||
case BannerStateEnum.BANDSAVEDSUCCESSFUL:
|
case BannerStateEnum.BANDSAVEDSUCCESSFUL:
|
||||||
this.icon = "mdi-guitar-electric"
|
return "mdi-guitar-electric"
|
||||||
break;
|
|
||||||
|
|
||||||
case BannerStateEnum.GENREDELETEERROR:
|
case BannerStateEnum.GENREDELETEERROR:
|
||||||
case BannerStateEnum.GENREDELETESUCCESSFUL:
|
case BannerStateEnum.GENREDELETESUCCESSFUL:
|
||||||
case BannerStateEnum.GENRESAVEDERROR:
|
case BannerStateEnum.GENRESAVEDERROR:
|
||||||
case BannerStateEnum.GENRESAVEDSUCCESSFUL:
|
case BannerStateEnum.GENRESAVEDSUCCESSFUL:
|
||||||
this.icon = "mdi-music-clef-treble"
|
return "mdi-music-clef-treble"
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.showBanner = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -67,11 +67,11 @@ export const useGenreStore = defineStore("genreStore", {
|
|||||||
postGenre(this.genre)
|
postGenre(this.genre)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.status == 200) {
|
if (response.status == 200) {
|
||||||
feedbackStore.changeBanner(BannerStateEnum.GENRESAVEDSUCCESSFUL)
|
feedbackStore.addSnackbar(BannerStateEnum.GENRESAVEDSUCCESSFUL)
|
||||||
this.getGenres()
|
this.getGenres()
|
||||||
this.showEditDialog = false
|
this.showEditDialog = false
|
||||||
} else {
|
} else {
|
||||||
feedbackStore.changeBanner(BannerStateEnum.GENRESAVEDERROR)
|
feedbackStore.addSnackbar(BannerStateEnum.GENRESAVEDERROR)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@@ -79,11 +79,11 @@ export const useGenreStore = defineStore("genreStore", {
|
|||||||
patchGenre(this.genre)
|
patchGenre(this.genre)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.status == 200) {
|
if (response.status == 200) {
|
||||||
feedbackStore.changeBanner(BannerStateEnum.GENRESAVEDSUCCESSFUL)
|
feedbackStore.addSnackbar(BannerStateEnum.GENRESAVEDSUCCESSFUL)
|
||||||
this.getGenres()
|
this.getGenres()
|
||||||
this.showEditDialog = false
|
this.showEditDialog = false
|
||||||
} else {
|
} else {
|
||||||
feedbackStore.changeBanner(BannerStateEnum.GENRESAVEDERROR)
|
feedbackStore.addSnackbar(BannerStateEnum.GENRESAVEDERROR)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -101,10 +101,10 @@ export const useGenreStore = defineStore("genreStore", {
|
|||||||
deleteGenre(genre)
|
deleteGenre(genre)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.status == 200) {
|
if (response.status == 200) {
|
||||||
feedbackStore.changeBanner(BannerStateEnum.GENREDELETESUCCESSFUL)
|
feedbackStore.addSnackbar(BannerStateEnum.GENREDELETESUCCESSFUL)
|
||||||
this.getGenres()
|
this.getGenres()
|
||||||
} else {
|
} else {
|
||||||
feedbackStore.changeBanner(BannerStateEnum.GENREDELETEERROR)
|
feedbackStore.addSnackbar(BannerStateEnum.GENREDELETEERROR)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { ServerStateEnum } from "@/data/enums/serverStateEnum";
|
|||||||
import { BannerStateEnum } from "@/data/enums/bannerStateEnum";
|
import { BannerStateEnum } from "@/data/enums/bannerStateEnum";
|
||||||
import { useFeedbackStore } from "./feedback.store";
|
import { useFeedbackStore } from "./feedback.store";
|
||||||
import { useBasketStore } from "./basket.store";
|
import { useBasketStore } from "./basket.store";
|
||||||
|
import { useExerciseStore } from "./exercise.store";
|
||||||
|
|
||||||
export const usePreferencesStore = defineStore('preferencesStore', {
|
export const usePreferencesStore = defineStore('preferencesStore', {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
@@ -76,7 +77,7 @@ export const usePreferencesStore = defineStore('preferencesStore', {
|
|||||||
await resetDatabase()
|
await resetDatabase()
|
||||||
.then(result => {
|
.then(result => {
|
||||||
if (result.status == 200) {
|
if (result.status == 200) {
|
||||||
feedbackStore.changeBanner(BannerStateEnum.DATABASERESETSUCCESSFUL)
|
feedbackStore.addSnackbar(BannerStateEnum.DATABASERESETSUCCESSFUL)
|
||||||
this.serverState = ServerStateEnum.ONLINE
|
this.serverState = ServerStateEnum.ONLINE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,14 +91,18 @@ export const usePreferencesStore = defineStore('preferencesStore', {
|
|||||||
*/
|
*/
|
||||||
async resetExerciseProg() {
|
async resetExerciseProg() {
|
||||||
const feedbackStore = useFeedbackStore()
|
const feedbackStore = useFeedbackStore()
|
||||||
|
const exerciseStore = useExerciseStore()
|
||||||
|
|
||||||
this.serverState = ServerStateEnum.PENDING
|
this.serverState = ServerStateEnum.PENDING
|
||||||
this.fetchInProgress = true
|
this.fetchInProgress = true
|
||||||
|
|
||||||
await resetExerciseProgress()
|
await resetExerciseProgress()
|
||||||
.then(result => {
|
.then(result => {
|
||||||
if (result.status == 200) {
|
if (result.status == 200) {
|
||||||
feedbackStore.changeBanner(BannerStateEnum.EXERCISEPROGRESSRESETSUCCESSFUL)
|
feedbackStore.addSnackbar(BannerStateEnum.EXERCISEPROGRESSRESETSUCCESSFUL)
|
||||||
this.serverState = ServerStateEnum.ONLINE
|
this.serverState = ServerStateEnum.ONLINE
|
||||||
|
|
||||||
|
exerciseStore.getAllExercises()
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fetchInProgress = false
|
this.fetchInProgress = false
|
||||||
|
|||||||
Reference in New Issue
Block a user