2020-11-25 16:19:00 +01:00
|
|
|
<template>
|
2020-11-26 01:30:15 +01:00
|
|
|
<div id="app" v-if="$store.state.appReady">
|
|
|
|
|
|
|
|
<navbar/>
|
|
|
|
|
|
|
|
<div id="content">
|
|
|
|
<router-view/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="footer">
|
|
|
|
<footer-nav/>
|
2020-11-25 16:19:00 +01:00
|
|
|
</div>
|
2020-11-26 01:30:15 +01:00
|
|
|
|
|
|
|
</div>
|
|
|
|
<div id="app-loader" v-else>
|
|
|
|
<loading-screen/>
|
2020-11-25 16:19:00 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2020-11-26 01:30:15 +01:00
|
|
|
<script>
|
|
|
|
import FooterNav from "@/components/FooterNav";
|
|
|
|
import Navbar from "@/components/Navbar";
|
|
|
|
import LoadingScreen from "@/components/LoadingScreen";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "Login",
|
|
|
|
components: {
|
|
|
|
Navbar,
|
|
|
|
FooterNav,
|
|
|
|
LoadingScreen
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
// The basic app is created... Currently showing a loading screen (as soon as mounted)
|
2020-11-26 03:18:28 +01:00
|
|
|
|
|
|
|
if (this.$api.haveToken) {
|
|
|
|
|
|
|
|
this.$api.getMyInfo().then(({name}) => {
|
|
|
|
|
|
|
|
this.$store.dispatch('storeUserData', name).then(() => {
|
|
|
|
this.$router.push('/').catch(() => {});
|
|
|
|
this.$store.dispatch('setAppReady');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}).catch(({status, text}) => {
|
|
|
|
if (status === 401) {
|
|
|
|
this.$api.clearTokenFromLocalStorage();
|
|
|
|
this.$router.push('/login').catch(() => {});
|
|
|
|
this.$store.dispatch('setAppReady');
|
|
|
|
|
|
|
|
} else {
|
|
|
|
this.$showToast(text);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
this.$router.push('/login').catch(() => {});
|
2020-11-26 01:30:15 +01:00
|
|
|
this.$store.dispatch('setAppReady');
|
2020-11-26 03:18:28 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-11-26 01:30:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2020-11-25 16:19:00 +01:00
|
|
|
<style>
|
2020-11-26 01:30:15 +01:00
|
|
|
#content {
|
|
|
|
margin-top: 70px;
|
|
|
|
margin-bottom: 20px;
|
2020-11-25 16:19:00 +01:00
|
|
|
}
|
|
|
|
|
2020-11-26 01:30:15 +01:00
|
|
|
#app {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
min-height: 100vh;
|
2020-11-25 16:19:00 +01:00
|
|
|
}
|
|
|
|
|
2020-11-26 01:30:15 +01:00
|
|
|
#footer {
|
|
|
|
padding: 1em;
|
|
|
|
margin-top: auto;
|
|
|
|
background: #E9ECEF;
|
2020-11-25 16:19:00 +01:00
|
|
|
}
|
|
|
|
|
2020-11-26 01:30:15 +01:00
|
|
|
#app-loader {
|
|
|
|
height: 100%;
|
2020-11-25 16:19:00 +01:00
|
|
|
}
|
|
|
|
</style>
|