Dynamische LoadingBar hinzugefügt
* mit setLoadingBoar, kann ein WatcherSource mitgeliefert werden, sodass eine LoadingBar erscheint. * muss jeweils einmal! für alle loadings angewendet werden.
This commit is contained in:
parent
63b25bb3d6
commit
97b60298ec
|
@ -89,7 +89,12 @@ module.exports = configure(function(ctx) {
|
||||||
iconSet: 'material-icons', // Quasar icon set
|
iconSet: 'material-icons', // Quasar icon set
|
||||||
lang: 'de', // Quasar language pack
|
lang: 'de', // Quasar language pack
|
||||||
config: {
|
config: {
|
||||||
dark: 'auto'
|
dark: 'auto',
|
||||||
|
loadingBar: {
|
||||||
|
position: 'top',
|
||||||
|
color: 'warning',
|
||||||
|
size: '5px'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Possible values for "importStrategy":
|
// Possible values for "importStrategy":
|
||||||
|
@ -105,7 +110,13 @@ module.exports = configure(function(ctx) {
|
||||||
// directives: [],
|
// directives: [],
|
||||||
|
|
||||||
// Quasar plugins
|
// Quasar plugins
|
||||||
plugins: ['LocalStorage', 'SessionStorage', 'Loading', 'Notify']
|
plugins: [
|
||||||
|
'LocalStorage',
|
||||||
|
'SessionStorage',
|
||||||
|
'Loading',
|
||||||
|
'Notify',
|
||||||
|
'LoadingBar'
|
||||||
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
// animations: 'all', // --- includes all animations
|
// animations: 'all', // --- includes all animations
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { watch, WatchSource } from '@vue/composition-api';
|
||||||
|
import { LoadingBar } from 'quasar';
|
||||||
|
|
||||||
|
function setLoadingBar(loading: WatchSource<boolean>) {
|
||||||
|
return watch<boolean>(loading, loading => {
|
||||||
|
if (loading) LoadingBar.start(10000);
|
||||||
|
if (!loading) LoadingBar.stop();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default setLoadingBar;
|
|
@ -27,13 +27,24 @@
|
||||||
import { computed, defineComponent } from '@vue/composition-api';
|
import { computed, defineComponent } from '@vue/composition-api';
|
||||||
import EssentialLink from 'src/components/navigation/EssentialLink.vue';
|
import EssentialLink from 'src/components/navigation/EssentialLink.vue';
|
||||||
import mainRoutes from 'src/plugins/balance/routes';
|
import mainRoutes from 'src/plugins/balance/routes';
|
||||||
|
import { Store } from 'vuex';
|
||||||
|
import { BalanceInterface } from 'src/plugins/balance/store/balance';
|
||||||
|
import setLoadingBar from 'components/loading';
|
||||||
|
import { StateInterface } from 'src/store';
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
// name: 'PageName'
|
// name: 'PageName'
|
||||||
components: { EssentialLink },
|
components: { EssentialLink },
|
||||||
setup(_, { root }) {
|
setup(_, { root }) {
|
||||||
|
const store = <Store<StateInterface>>root.$store;
|
||||||
|
const loading = computed(() => {
|
||||||
|
return (<BalanceInterface>store.state.balance).loading > 0;
|
||||||
|
});
|
||||||
const checkMain = computed(() => {
|
const checkMain = computed(() => {
|
||||||
return root.$route.matched.length == 2;
|
return root.$route.matched.length == 2;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setLoadingBar(loading);
|
||||||
|
|
||||||
return { checkMain, mainRoutes };
|
return { checkMain, mainRoutes };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,13 +11,15 @@ interface BalanceResponse {
|
||||||
|
|
||||||
export interface BalanceInterface extends BalanceResponse {
|
export interface BalanceInterface extends BalanceResponse {
|
||||||
limit: number;
|
limit: number;
|
||||||
|
loading: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const state: BalanceInterface = {
|
const state: BalanceInterface = {
|
||||||
balance: 0,
|
balance: 0,
|
||||||
credit: 0,
|
credit: 0,
|
||||||
debit: 0,
|
debit: 0,
|
||||||
limit: 0
|
limit: 0,
|
||||||
|
loading: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
const mutations: MutationTree<BalanceInterface> = {
|
const mutations: MutationTree<BalanceInterface> = {
|
||||||
|
@ -32,11 +34,16 @@ const mutations: MutationTree<BalanceInterface> = {
|
||||||
},
|
},
|
||||||
setLimit(state, data: number) {
|
setLimit(state, data: number) {
|
||||||
state.limit = data;
|
state.limit = data;
|
||||||
|
},
|
||||||
|
setLoading(state, data = true) {
|
||||||
|
if (data) state.loading += 1;
|
||||||
|
else state.loading -= 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const actions: ActionTree<BalanceInterface, StateInterface> = {
|
const actions: ActionTree<BalanceInterface, StateInterface> = {
|
||||||
getBalance({ commit, rootState }) {
|
getBalance({ commit, rootState }) {
|
||||||
|
commit('setLoading');
|
||||||
axios
|
axios
|
||||||
/* eslint-disable-next-line @typescript-eslint/restrict-template-expressions */
|
/* eslint-disable-next-line @typescript-eslint/restrict-template-expressions */
|
||||||
.get(`/users/${rootState.user.currentUser?.userid}/balance`)
|
.get(`/users/${rootState.user.currentUser?.userid}/balance`)
|
||||||
|
@ -47,9 +54,11 @@ const actions: ActionTree<BalanceInterface, StateInterface> = {
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.warn(err);
|
console.warn(err);
|
||||||
});
|
})
|
||||||
|
.finally(() => commit('setLoading', false));
|
||||||
},
|
},
|
||||||
getLimit({ rootState }) {
|
getLimit({ rootState, commit }) {
|
||||||
|
commit('setLoading');
|
||||||
axios
|
axios
|
||||||
/* eslint-disable-next-line @typescript-eslint/restrict-template-expressions */
|
/* eslint-disable-next-line @typescript-eslint/restrict-template-expressions */
|
||||||
.get(`/users/${rootState.user.currentUser?.userid}/balance/limit`)
|
.get(`/users/${rootState.user.currentUser?.userid}/balance/limit`)
|
||||||
|
@ -58,9 +67,11 @@ const actions: ActionTree<BalanceInterface, StateInterface> = {
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.warn(err);
|
console.warn(err);
|
||||||
});
|
})
|
||||||
|
.finally(() => commit('setLoading', false));
|
||||||
},
|
},
|
||||||
changeBalance({ rootState, dispatch }, amount: number) {
|
changeBalance({ rootState, dispatch, commit }, amount: number) {
|
||||||
|
commit('setLoading');
|
||||||
axios
|
axios
|
||||||
/* eslint-disable-next-line @typescript-eslint/restrict-template-expressions */
|
/* eslint-disable-next-line @typescript-eslint/restrict-template-expressions */
|
||||||
.put(`/users/${rootState.user.currentUser?.userid}/balance`, <
|
.put(`/users/${rootState.user.currentUser?.userid}/balance`, <
|
||||||
|
@ -71,7 +82,8 @@ const actions: ActionTree<BalanceInterface, StateInterface> = {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
dispatch('getBalance').catch(err => console.warn(err));
|
dispatch('getBalance').catch(err => console.warn(err));
|
||||||
})
|
})
|
||||||
.catch(err => console.warn(err));
|
.catch(err => console.warn(err))
|
||||||
|
.finally(() => commit('setLoading', false));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<q-form @submit="save" @reset="reset">
|
<q-form @submit="save" @reset="reset">
|
||||||
<q-linear-progress indeterminate rounded color="primary" v-if="loading" />
|
|
||||||
<q-card-section class="fit row justify-start content-center items-center">
|
<q-card-section class="fit row justify-start content-center items-center">
|
||||||
<q-input
|
<q-input
|
||||||
class="col-xs-12 col-sm-6 q-pa-sm"
|
class="col-xs-12 col-sm-6 q-pa-sm"
|
||||||
|
@ -194,8 +193,6 @@ export default defineComponent({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const loading = computed(() => store.state.user.loading > 0);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props,
|
props,
|
||||||
allRoles,
|
allRoles,
|
||||||
|
@ -209,8 +206,7 @@ export default defineComponent({
|
||||||
notEmpty,
|
notEmpty,
|
||||||
isUseridUsed,
|
isUseridUsed,
|
||||||
save,
|
save,
|
||||||
reset,
|
reset
|
||||||
loading
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,12 +2,6 @@
|
||||||
<div>
|
<div>
|
||||||
<q-card class="col-12">
|
<q-card class="col-12">
|
||||||
<q-form @submit="save" @reset="reset">
|
<q-form @submit="save" @reset="reset">
|
||||||
<q-linear-progress
|
|
||||||
indeterminate
|
|
||||||
rounded
|
|
||||||
color="primary"
|
|
||||||
v-if="loading"
|
|
||||||
/>
|
|
||||||
<q-card-section
|
<q-card-section
|
||||||
class="fit row justify-start content-center items-center"
|
class="fit row justify-start content-center items-center"
|
||||||
>
|
>
|
||||||
|
@ -86,7 +80,6 @@ export default defineComponent({
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const loading = computed(() => store.state.user.loading > 0);
|
|
||||||
const role = ref<FG.Role | null>(null);
|
const role = ref<FG.Role | null>(null);
|
||||||
const roles = computed(() => store.state.user.roles);
|
const roles = computed(() => store.state.user.roles);
|
||||||
const permissions = computed(() =>
|
const permissions = computed(() =>
|
||||||
|
@ -174,7 +167,6 @@ export default defineComponent({
|
||||||
reset,
|
reset,
|
||||||
removeRole,
|
removeRole,
|
||||||
remove,
|
remove,
|
||||||
loading,
|
|
||||||
newRoleName
|
newRoleName
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
padding
|
padding
|
||||||
class="fit row justify-center content-center items-center q-gutter-sm"
|
class="fit row justify-center content-center items-center q-gutter-sm"
|
||||||
>
|
>
|
||||||
<circular-progress v-if="sessionsLoading" />
|
|
||||||
<q-card class="col-12">
|
<q-card class="col-12">
|
||||||
<q-card-section
|
<q-card-section
|
||||||
class="fit row justify-start content-center items-center"
|
class="fit row justify-start content-center items-center"
|
||||||
|
@ -35,6 +34,7 @@ import Sessions from '../components/settings/Sessions.vue';
|
||||||
import MainUserSettings from '../components/settings/MainUserSettings.vue';
|
import MainUserSettings from '../components/settings/MainUserSettings.vue';
|
||||||
import { Store } from 'vuex';
|
import { Store } from 'vuex';
|
||||||
import { StateInterface } from 'src/store';
|
import { StateInterface } from 'src/store';
|
||||||
|
import setLoadingBar from 'components/loading';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
// name: 'PageName'
|
// name: 'PageName'
|
||||||
|
@ -50,16 +50,19 @@ export default defineComponent({
|
||||||
|
|
||||||
const currentUser = ref(<FG.User>store.state.user.currentUser);
|
const currentUser = ref(<FG.User>store.state.user.currentUser);
|
||||||
const sessions = computed(() => store.state.session.sessions);
|
const sessions = computed(() => store.state.session.sessions);
|
||||||
const sessionsLoading = computed(() => store.state.session.loading);
|
const loading = computed(
|
||||||
|
() => store.state.session.loading || store.state.user.loading > 0
|
||||||
|
);
|
||||||
function updateUser(value: FG.User) {
|
function updateUser(value: FG.User) {
|
||||||
store.dispatch('user/updateUser', value).catch(error => {
|
store.dispatch('user/updateUser', value).catch(error => {
|
||||||
console.warn(error);
|
console.warn(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setLoadingBar(loading);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
currentUser,
|
currentUser,
|
||||||
sessionsLoading,
|
|
||||||
sessions,
|
sessions,
|
||||||
updateUser
|
updateUser
|
||||||
};
|
};
|
||||||
|
|
|
@ -83,6 +83,7 @@ const actions: ActionTree<UserStateInterface, StateInterface> = {
|
||||||
},
|
},
|
||||||
|
|
||||||
getUsers({ commit }) {
|
getUsers({ commit }) {
|
||||||
|
commit('setLoading');
|
||||||
axios
|
axios
|
||||||
.get('/users')
|
.get('/users')
|
||||||
.then((response: AxiosResponse<FG.User[]>) => {
|
.then((response: AxiosResponse<FG.User[]>) => {
|
||||||
|
@ -90,6 +91,9 @@ const actions: ActionTree<UserStateInterface, StateInterface> = {
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.warn(err);
|
console.warn(err);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
commit('setLoading', false);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import { UserStateInterface } from 'src/plugins/user/store/user';
|
||||||
export interface StateInterface {
|
export interface StateInterface {
|
||||||
user: UserStateInterface;
|
user: UserStateInterface;
|
||||||
session: SessionInterface;
|
session: SessionInterface;
|
||||||
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default store(function({ Vue }) {
|
export default store(function({ Vue }) {
|
||||||
|
|
Loading…
Reference in New Issue