2018-08-28 22:50:22 +02:00
|
|
|
<template>
|
2021-07-28 21:56:29 +02:00
|
|
|
<div :class="{'is-touch': isTouch}">
|
2021-04-19 22:36:31 +02:00
|
|
|
<div :class="{'is-hidden': !online}">
|
2019-11-03 13:44:40 +01:00
|
|
|
<!-- This is a workaround to get the sw to "see" the to-be-cached version of the offline background image -->
|
|
|
|
<div class="offline" style="height: 0;width: 0;"></div>
|
2020-11-01 18:36:00 +01:00
|
|
|
<top-navigation v-if="authUser"/>
|
|
|
|
<content-auth v-if="authUser"/>
|
|
|
|
<content-link-share v-else-if="authLinkShare"/>
|
|
|
|
<content-no-auth v-else/>
|
2020-03-02 21:19:26 +01:00
|
|
|
<notification/>
|
2021-04-19 22:36:31 +02:00
|
|
|
</div>
|
|
|
|
<div class="app offline" v-if="!online">
|
2019-11-03 13:44:40 +01:00
|
|
|
<div class="offline-message">
|
|
|
|
<h1>You are offline.</h1>
|
|
|
|
<p>Please check your network connection and try again.</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-07-25 16:52:04 +02:00
|
|
|
|
|
|
|
<transition name="fade">
|
2020-11-01 18:36:00 +01:00
|
|
|
<keyboard-shortcuts v-if="keyboardShortcutsActive"/>
|
2020-07-25 16:52:04 +02:00
|
|
|
</transition>
|
2019-11-03 13:44:40 +01:00
|
|
|
</div>
|
2018-08-28 22:50:22 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-09-10 15:04:00 +02:00
|
|
|
import {mapState, mapGetters} from 'vuex'
|
2021-07-28 21:56:29 +02:00
|
|
|
import isTouchDevice from 'is-touch-device'
|
2019-09-09 19:55:43 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
import Notification from './components/misc/notification'
|
2020-11-01 18:36:00 +01:00
|
|
|
import {KEYBOARD_SHORTCUTS_ACTIVE, ONLINE} from './store/mutation-types'
|
2020-09-05 22:35:52 +02:00
|
|
|
import KeyboardShortcuts from './components/misc/keyboard-shortcuts'
|
2021-07-25 15:27:15 +02:00
|
|
|
import TopNavigation from './components/home/topNavigation'
|
|
|
|
import ContentAuth from './components/home/contentAuth'
|
|
|
|
import ContentLinkShare from './components/home/contentLinkShare'
|
|
|
|
import ContentNoAuth from './components/home/contentNoAuth'
|
|
|
|
import {setLanguage} from './i18n/setup'
|
2021-08-11 21:08:18 +02:00
|
|
|
import AccountDeleteService from '@/services/accountDelete'
|
2019-12-18 22:30:20 +01:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
export default {
|
|
|
|
name: 'app',
|
|
|
|
components: {
|
2020-11-01 18:36:00 +01:00
|
|
|
ContentNoAuth,
|
|
|
|
ContentLinkShare,
|
|
|
|
ContentAuth,
|
|
|
|
TopNavigation,
|
2020-09-05 22:35:52 +02:00
|
|
|
KeyboardShortcuts,
|
|
|
|
Notification,
|
|
|
|
},
|
|
|
|
beforeMount() {
|
2020-11-01 18:36:00 +01:00
|
|
|
this.setupOnlineStatus()
|
|
|
|
this.setupPasswortResetRedirect()
|
|
|
|
this.setupEmailVerificationRedirect()
|
2021-08-11 21:08:18 +02:00
|
|
|
this.setupAccountDeletionVerification()
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
beforeCreate() {
|
|
|
|
this.$store.dispatch('config/update')
|
2021-08-15 12:02:29 +02:00
|
|
|
.then(() => {
|
|
|
|
this.$store.dispatch('auth/checkAuth')
|
|
|
|
})
|
2021-08-15 18:52:22 +02:00
|
|
|
this.$store.dispatch('auth/checkAuth')
|
2021-06-24 01:24:57 +02:00
|
|
|
|
|
|
|
setLanguage()
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
created() {
|
2020-10-08 22:17:41 +02:00
|
|
|
// Make sure to always load the home route when running with electron
|
2020-11-01 18:36:00 +01:00
|
|
|
if (this.$route.fullPath.endsWith('frontend/index.html')) {
|
2020-10-08 22:17:41 +02:00
|
|
|
this.$router.push({name: 'home'})
|
|
|
|
}
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
2021-07-28 21:56:29 +02:00
|
|
|
computed: {
|
|
|
|
isTouch() {
|
|
|
|
return isTouchDevice()
|
|
|
|
},
|
|
|
|
...mapState({
|
|
|
|
online: ONLINE,
|
|
|
|
keyboardShortcutsActive: KEYBOARD_SHORTCUTS_ACTIVE,
|
|
|
|
}),
|
2021-09-10 15:04:00 +02:00
|
|
|
...mapGetters('auth', [
|
|
|
|
'authUser',
|
|
|
|
'authLinkShare',
|
|
|
|
]),
|
2021-07-28 21:56:29 +02:00
|
|
|
},
|
2020-11-01 18:36:00 +01:00
|
|
|
methods: {
|
|
|
|
setupOnlineStatus() {
|
|
|
|
this.$store.commit(ONLINE, navigator.onLine)
|
|
|
|
window.addEventListener('online', () => this.$store.commit(ONLINE, navigator.onLine))
|
|
|
|
window.addEventListener('offline', () => this.$store.commit(ONLINE, navigator.onLine))
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
2020-11-01 18:36:00 +01:00
|
|
|
setupPasswortResetRedirect() {
|
2020-12-30 21:43:43 +01:00
|
|
|
if (typeof this.$route.query.userPasswordReset !== 'undefined') {
|
2020-11-01 18:36:00 +01:00
|
|
|
localStorage.removeItem('passwordResetToken') // Delete an eventually preexisting old token
|
|
|
|
localStorage.setItem('passwordResetToken', this.$route.query.userPasswordReset)
|
|
|
|
this.$router.push({name: 'user.password-reset.reset'})
|
2020-09-05 22:35:52 +02:00
|
|
|
}
|
2019-03-02 11:25:10 +01:00
|
|
|
},
|
2020-11-01 18:36:00 +01:00
|
|
|
setupEmailVerificationRedirect() {
|
2020-12-30 21:43:43 +01:00
|
|
|
if (typeof this.$route.query.userEmailConfirm !== 'undefined') {
|
2020-11-01 18:36:00 +01:00
|
|
|
localStorage.removeItem('emailConfirmToken') // Delete an eventually preexisting old token
|
|
|
|
localStorage.setItem('emailConfirmToken', this.$route.query.userEmailConfirm)
|
|
|
|
this.$router.push({name: 'user.login'})
|
2020-09-06 16:20:48 +02:00
|
|
|
}
|
|
|
|
},
|
2021-08-11 21:08:18 +02:00
|
|
|
setupAccountDeletionVerification() {
|
|
|
|
if (typeof this.$route.query.accountDeletionConfirm !== 'undefined') {
|
|
|
|
const accountDeletionService = new AccountDeleteService()
|
|
|
|
accountDeletionService.confirm(this.$route.query.accountDeletionConfirm)
|
|
|
|
.then(() => {
|
|
|
|
this.success({message: this.$t('user.deletion.confirmSuccess')})
|
|
|
|
this.$store.dispatch('auth/refreshUserInfo')
|
|
|
|
})
|
|
|
|
.catch(e => this.error(e))
|
|
|
|
}
|
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
}
|
2018-08-28 22:50:22 +02:00
|
|
|
</script>
|