Loading hinzugefügt

Circular Progress kann nun mit Logo verwendet werden.
Beim Anmelden wird der Bildschirm beim Laden gesperrt.
This commit is contained in:
Tim Gröger 2020-10-16 13:54:01 +02:00
parent 2411fc86cd
commit 704f6fd3fe
5 changed files with 42 additions and 6 deletions

View File

@ -103,7 +103,7 @@ module.exports = configure(function(ctx) {
// directives: [], // directives: [],
// Quasar plugins // Quasar plugins
plugins: ['LocalStorage'] plugins: ['LocalStorage', 'Loading']
}, },
// animations: 'all', // --- includes all animations // animations: 'all', // --- includes all animations

View File

@ -0,0 +1,23 @@
<template>
<q-circular-progress
indeterminate
show-value
font-size="10px"
class="q-ma-md"
size="80px"
:thickness="0.15"
color="primary"
track-color="grey-3"
>
<q-avatar size="60px">
<img src="logo-dark.svg" />
</q-avatar>
</q-circular-progress>
</template>
<script lang="ts">
import { defineComponent } from '@vue/composition-api';
export default defineComponent({
name: 'CircularProgress'
});
</script>

View File

@ -7,6 +7,8 @@
<div <div
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" />
<div>tada:: {{ sessionsLoading }}</div>
<q-card <q-card
class="col-12" class="col-12"
height="" height=""
@ -62,10 +64,10 @@
<script lang="ts"> <script lang="ts">
import { computed, defineComponent, onBeforeMount } from '@vue/composition-api'; import { computed, defineComponent, onBeforeMount } from '@vue/composition-api';
import { mainLink } from '../plugin'; import CircularProgress from 'components/loading/CircularProgress.vue';
import { platform } from 'os';
export default defineComponent({ export default defineComponent({
// name: 'PageName' // name: 'PageName'
components: { CircularProgress },
setup(_, { root }) { setup(_, { root }) {
onBeforeMount(() => { onBeforeMount(() => {
root.$store.dispatch('sessions/getSessions'); root.$store.dispatch('sessions/getSessions');
@ -101,13 +103,19 @@ export default defineComponent({
function isThisSession(token: string) { function isThisSession(token: string) {
return root.$store.getters['user/token'].token == token; return root.$store.getters['user/token'].token == token;
} }
const sessionsLoading = computed(() => {
return root.$store.getters['sessions/loading'];
});
return { return {
showRootGetters, showRootGetters,
sessions, sessions,
getBrowserIcon, getBrowserIcon,
getPlatformIcon, getPlatformIcon,
isThisSession, isThisSession,
deleteSession deleteSession,
sessionsLoading
}; };
} }
}); });

View File

@ -26,7 +26,7 @@ const mutations: MutationTree<SessionInterface> = {
setSessions(state, sessions: Session[]) { setSessions(state, sessions: Session[]) {
state.sessions = sessions; state.sessions = sessions;
}, },
setLoading(state, value) { setLoading(state, value: boolean) {
state.loading = value; state.loading = value;
} }
}; };
@ -71,6 +71,9 @@ const actions: ActionTree<SessionInterface, StateInterface> = {
const getters: GetterTree<SessionInterface, StateInterface> = { const getters: GetterTree<SessionInterface, StateInterface> = {
sessions(state) { sessions(state) {
return state.sessions; return state.sessions;
},
loading(state) {
return state.loading;
} }
}; };

View File

@ -3,7 +3,7 @@ import { StateInterface } from 'src/store';
import { axios } from 'boot/axios'; import { axios } from 'boot/axios';
import { LoginData } from 'src/plugins/user/models'; import { LoginData } from 'src/plugins/user/models';
import { AxiosResponse } from 'axios'; import { AxiosResponse } from 'axios';
import { LocalStorage } from 'quasar'; import { LocalStorage, Loading } from 'quasar';
import { Router } from 'src/router'; import { Router } from 'src/router';
export interface Token { export interface Token {
@ -72,6 +72,7 @@ const actions: ActionTree<UserStateInterface, StateInterface> = {
login({ commit }, data: LoginData) { login({ commit }, data: LoginData) {
console.log('bla'); console.log('bla');
commit('setLoginLoading', true); commit('setLoginLoading', true);
Loading.show({ message: 'Du wirst eingeloggt' });
void axios void axios
.post('http://localhost:5000/auth', data) .post('http://localhost:5000/auth', data)
.then((response: AxiosResponse<LoginResponse>) => { .then((response: AxiosResponse<LoginResponse>) => {
@ -93,6 +94,7 @@ const actions: ActionTree<UserStateInterface, StateInterface> = {
}) })
.finally(() => { .finally(() => {
commit('setLoginLoading', false); commit('setLoginLoading', false);
Loading.hide();
}); });
} }
}; };