2020-11-01 18:36:00 +01:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<a @click="$store.commit('menuActive', false)" class="menu-hide-button" v-if="menuActive">
|
2021-11-13 15:16:14 +01:00
|
|
|
<icon icon="times" />
|
2020-11-01 18:36:00 +01:00
|
|
|
</a>
|
|
|
|
<div
|
|
|
|
:class="{'has-background': background}"
|
2021-09-08 18:28:26 +02:00
|
|
|
:style="{'background-image': background && `url(${background})`}"
|
2020-11-01 18:36:00 +01:00
|
|
|
class="app-container"
|
|
|
|
>
|
|
|
|
<navigation/>
|
|
|
|
<div
|
|
|
|
:class="[
|
2021-09-08 11:59:46 +02:00
|
|
|
{ 'is-menu-enabled': menuActive },
|
2020-11-01 18:36:00 +01:00
|
|
|
$route.name,
|
|
|
|
]"
|
|
|
|
class="app-content"
|
|
|
|
>
|
|
|
|
<a @click="$store.commit('menuActive', false)" class="mobile-overlay" v-if="menuActive"></a>
|
2021-04-18 19:32:31 +02:00
|
|
|
|
2021-05-30 20:30:08 +02:00
|
|
|
<quick-actions/>
|
|
|
|
|
2021-01-20 22:11:05 +01:00
|
|
|
<router-view/>
|
2021-04-18 19:32:31 +02:00
|
|
|
|
2021-08-20 15:17:19 +02:00
|
|
|
<router-view name="popup" v-slot="{ Component }">
|
|
|
|
<transition name="modal">
|
|
|
|
<component :is="Component" />
|
|
|
|
</transition>
|
|
|
|
</router-view>
|
2021-04-18 19:32:31 +02:00
|
|
|
|
|
|
|
<a
|
|
|
|
class="keyboard-shortcuts-button"
|
|
|
|
@click="showKeyboardShortcuts()"
|
2021-11-13 21:28:29 +01:00
|
|
|
v-shortcut="'?'"
|
2021-04-18 19:32:31 +02:00
|
|
|
>
|
2020-11-01 18:36:00 +01:00
|
|
|
<icon icon="keyboard"/>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import {mapState} from 'vuex'
|
2021-04-18 19:32:31 +02:00
|
|
|
import {CURRENT_LIST, KEYBOARD_SHORTCUTS_ACTIVE, MENU_ACTIVE} from '@/store/mutation-types'
|
2021-07-25 15:27:15 +02:00
|
|
|
import Navigation from '@/components/home/navigation.vue'
|
|
|
|
import QuickActions from '@/components/quick-actions/quick-actions.vue'
|
2020-11-01 18:36:00 +01:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'contentAuth',
|
2021-05-30 20:30:08 +02:00
|
|
|
components: {QuickActions, Navigation},
|
2020-11-01 18:36:00 +01:00
|
|
|
watch: {
|
2021-09-08 11:59:38 +02:00
|
|
|
'$route': {
|
|
|
|
handler: 'doStuffAfterRoute',
|
|
|
|
deep: true,
|
|
|
|
},
|
2020-11-01 18:36:00 +01:00
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.renewTokenOnFocus()
|
2021-06-03 22:23:04 +02:00
|
|
|
this.loadLabels()
|
2020-11-01 18:36:00 +01:00
|
|
|
},
|
|
|
|
computed: mapState({
|
2021-09-08 18:28:26 +02:00
|
|
|
background: 'background',
|
2020-11-01 18:36:00 +01:00
|
|
|
menuActive: MENU_ACTIVE,
|
2020-11-10 21:54:04 +01:00
|
|
|
userInfo: state => state.auth.info,
|
2021-04-07 16:37:43 +02:00
|
|
|
authenticated: state => state.auth.authenticated,
|
2020-11-01 18:36:00 +01:00
|
|
|
}),
|
|
|
|
methods: {
|
|
|
|
doStuffAfterRoute() {
|
|
|
|
// this.setTitle('') // Reset the title if the page component does not set one itself
|
2020-11-21 22:31:34 +01:00
|
|
|
this.hideMenuOnMobile()
|
2020-11-01 18:36:00 +01:00
|
|
|
this.resetCurrentList()
|
|
|
|
},
|
|
|
|
resetCurrentList() {
|
|
|
|
// Reset the current list highlight in menu if the current list is not list related.
|
|
|
|
if (
|
|
|
|
this.$route.name === 'home' ||
|
|
|
|
this.$route.name === 'namespace.edit' ||
|
|
|
|
this.$route.name === 'teams.index' ||
|
|
|
|
this.$route.name === 'teams.edit' ||
|
|
|
|
this.$route.name === 'tasks.range' ||
|
|
|
|
this.$route.name === 'labels.index' ||
|
|
|
|
this.$route.name === 'migrate.start' ||
|
|
|
|
this.$route.name === 'migrate.wunderlist' ||
|
2021-11-28 15:56:05 +01:00
|
|
|
this.$route.name.startsWith('user.settings') ||
|
2020-11-01 18:36:00 +01:00
|
|
|
this.$route.name === 'namespaces.index'
|
|
|
|
) {
|
2021-10-16 17:51:27 +02:00
|
|
|
return this.$store.dispatch(CURRENT_LIST, null)
|
2020-11-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
renewTokenOnFocus() {
|
|
|
|
// Try renewing the token every time vikunja is loaded initially
|
|
|
|
// (When opening the browser the focus event is not fired)
|
|
|
|
this.$store.dispatch('auth/renewToken')
|
|
|
|
|
|
|
|
// Check if the token is still valid if the window gets focus again to maybe renew it
|
|
|
|
window.addEventListener('focus', () => {
|
|
|
|
|
2021-04-07 16:37:43 +02:00
|
|
|
if (!this.authenticated) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:35:14 +02:00
|
|
|
const expiresIn = (this.userInfo !== null ? this.userInfo.exp : 0) - +new Date() / 1000
|
2020-11-01 18:36:00 +01:00
|
|
|
|
|
|
|
// If the token expiry is negative, it is already expired and we have no choice but to redirect
|
|
|
|
// the user to the login page
|
|
|
|
if (expiresIn < 0) {
|
|
|
|
this.$store.dispatch('auth/checkAuth')
|
|
|
|
this.$router.push({name: 'user.login'})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the token is valid for less than 60 hours and renew if thats the case
|
|
|
|
if (expiresIn < 60 * 3600) {
|
|
|
|
this.$store.dispatch('auth/renewToken')
|
|
|
|
console.debug('renewed token')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
2020-11-21 22:31:34 +01:00
|
|
|
hideMenuOnMobile() {
|
|
|
|
if (window.innerWidth < 769) {
|
|
|
|
this.$store.commit(MENU_ACTIVE, false)
|
|
|
|
}
|
|
|
|
},
|
2021-04-18 19:32:31 +02:00
|
|
|
showKeyboardShortcuts() {
|
|
|
|
this.$store.commit(KEYBOARD_SHORTCUTS_ACTIVE, true)
|
|
|
|
},
|
2021-06-03 22:23:04 +02:00
|
|
|
loadLabels() {
|
|
|
|
this.$store.dispatch('labels/loadAllLabels')
|
|
|
|
},
|
2020-11-01 18:36:00 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
2021-10-18 14:20:39 +02:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-11-13 15:16:14 +01:00
|
|
|
.menu-hide-button {
|
|
|
|
position: fixed;
|
|
|
|
top: 0.5rem;
|
|
|
|
right: 0.5rem;
|
|
|
|
z-index: 31;
|
|
|
|
width: 3rem;
|
|
|
|
height: 3rem;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
font-size: 2rem;
|
2021-11-22 22:12:54 +01:00
|
|
|
color: var(--grey-400);
|
2021-11-13 15:16:14 +01:00
|
|
|
line-height: 1;
|
|
|
|
transition: all $transition;
|
|
|
|
|
|
|
|
@media screen and (min-width: $tablet) {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:hover,
|
|
|
|
&:focus {
|
|
|
|
height: 1rem;
|
2021-11-22 22:12:54 +01:00
|
|
|
color: var(--grey-600);
|
2021-11-13 15:16:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-18 14:32:59 +02:00
|
|
|
.app-container {
|
|
|
|
min-height: calc(100vh - 65px);
|
|
|
|
|
|
|
|
@media screen and (max-width: $tablet) {
|
|
|
|
padding-top: $navbar-height;
|
|
|
|
}
|
|
|
|
|
|
|
|
.app-content {
|
|
|
|
padding: $navbar-height + 1.5rem 1.5rem 1rem 1.5rem;
|
|
|
|
z-index: 2;
|
|
|
|
|
|
|
|
@media screen and (max-width: $tablet) {
|
|
|
|
margin-left: 0;
|
|
|
|
padding-top: 1.5rem;
|
|
|
|
min-height: calc(100vh - 4rem);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.is-menu-enabled {
|
|
|
|
margin-left: $navbar-width;
|
|
|
|
|
|
|
|
@media screen and (max-width: $tablet) {
|
|
|
|
min-width: 100%;
|
|
|
|
margin-left: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.task\.detail {
|
|
|
|
padding-left: 0;
|
|
|
|
padding-right: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.card {
|
2021-11-22 22:12:54 +01:00
|
|
|
background: var(--white);
|
2021-10-18 14:32:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-18 14:33:23 +02:00
|
|
|
.mobile-overlay {
|
|
|
|
display: none;
|
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
background: rgba(250, 250, 250, 0.8);
|
|
|
|
z-index: 5;
|
|
|
|
opacity: 0;
|
|
|
|
transition: all $transition;
|
|
|
|
|
|
|
|
@media screen and (max-width: $tablet) {
|
|
|
|
display: block;
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-18 14:20:39 +02:00
|
|
|
.keyboard-shortcuts-button {
|
|
|
|
position: fixed;
|
|
|
|
bottom: calc(1rem - 4px);
|
|
|
|
right: 1rem;
|
|
|
|
z-index: 4500; // The modal has a z-index of 4000
|
|
|
|
|
2021-11-22 22:12:54 +01:00
|
|
|
color: var(--grey-500);
|
2021-10-18 14:20:39 +02:00
|
|
|
transition: color $transition;
|
|
|
|
|
|
|
|
@media screen and (max-width: $tablet) {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|