2018-08-28 22:50:22 +02:00
|
|
|
<template>
|
2019-11-03 13:44:40 +01:00
|
|
|
<div>
|
2020-05-08 20:43:51 +02:00
|
|
|
<div v-if="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-05-31 21:17:10 +02:00
|
|
|
<nav
|
2020-09-05 22:35:52 +02:00
|
|
|
:class="{'has-background': background}"
|
|
|
|
aria-label="main navigation"
|
|
|
|
class="navbar main-theme is-fixed-top"
|
|
|
|
role="navigation"
|
|
|
|
v-if="userAuthenticated && (userInfo && userInfo.type === authTypes.USER)">
|
2019-11-03 13:44:40 +01:00
|
|
|
<div class="navbar-brand">
|
|
|
|
<router-link :to="{name: 'home'}" class="navbar-item logo">
|
2020-09-05 22:35:52 +02:00
|
|
|
<img alt="Vikunja" src="/images/logo-full-pride.svg" v-if="(new Date()).getMonth() === 5"/>
|
|
|
|
<img alt="Vikunja" src="/images/logo-full.svg" v-else/>
|
2019-11-03 13:44:40 +01:00
|
|
|
</router-link>
|
2020-06-25 23:56:41 +02:00
|
|
|
<a
|
2020-09-05 22:35:52 +02:00
|
|
|
:class="{'is-visible': !menuActive}"
|
|
|
|
@click="menuActive = true"
|
|
|
|
class="menu-show-button"
|
2020-06-25 23:56:41 +02:00
|
|
|
>
|
|
|
|
<icon icon="bars"></icon>
|
|
|
|
</a>
|
2019-11-03 13:44:40 +01:00
|
|
|
</div>
|
2020-06-25 23:56:41 +02:00
|
|
|
<a
|
2020-09-05 22:35:52 +02:00
|
|
|
@click="menuActive = true"
|
|
|
|
class="menu-show-button"
|
2020-06-25 23:56:41 +02:00
|
|
|
>
|
2020-06-12 19:32:37 +02:00
|
|
|
<icon icon="bars"></icon>
|
|
|
|
</a>
|
2020-05-31 21:17:10 +02:00
|
|
|
<div class="list-title" v-if="currentList.id">
|
|
|
|
<h1
|
2020-09-05 22:35:52 +02:00
|
|
|
:style="{ 'opacity': currentList.title === '' ? '0': '1' }"
|
|
|
|
class="title">
|
|
|
|
{{ currentList.title === '' ? 'Loading...' : currentList.title }}
|
2020-05-31 21:17:10 +02:00
|
|
|
</h1>
|
2020-08-11 20:18:59 +02:00
|
|
|
<router-link
|
2020-09-05 22:35:52 +02:00
|
|
|
:to="{ name: 'list.edit', params: { id: currentList.id } }"
|
|
|
|
class="icon"
|
|
|
|
v-if="canWriteCurrentList">
|
2020-05-31 21:17:10 +02:00
|
|
|
<icon icon="cog" size="2x"/>
|
|
|
|
</router-link>
|
|
|
|
</div>
|
2019-11-03 13:44:40 +01:00
|
|
|
<div class="navbar-end">
|
2020-09-05 22:35:52 +02:00
|
|
|
<div class="update-notification" v-if="updateAvailable">
|
2019-12-18 22:30:20 +01:00
|
|
|
<p>There is an update for Vikunja available!</p>
|
|
|
|
<a @click="refreshApp()" class="button is-primary noshadow">Update Now</a>
|
|
|
|
</div>
|
2019-11-03 13:44:40 +01:00
|
|
|
<div class="user">
|
2020-09-05 22:35:52 +02:00
|
|
|
<img :src="userAvatar" alt="" class="avatar"/>
|
2019-11-03 13:44:40 +01:00
|
|
|
<div class="dropdown is-right is-active">
|
|
|
|
<div class="dropdown-trigger">
|
2020-09-05 22:35:52 +02:00
|
|
|
<button @click.stop="userMenuActive = !userMenuActive" class="button noshadow">
|
|
|
|
<span class="username">{{ userInfo.username }}</span>
|
2019-11-03 13:44:40 +01:00
|
|
|
<span class="icon is-small">
|
2019-04-23 21:50:37 +02:00
|
|
|
<icon icon="chevron-down"/>
|
|
|
|
</span>
|
2019-11-03 13:44:40 +01:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<transition name="fade">
|
|
|
|
<div class="dropdown-menu" v-if="userMenuActive">
|
|
|
|
<div class="dropdown-content">
|
2020-06-17 22:24:37 +02:00
|
|
|
<router-link :to="{name: 'user.settings'}" class="dropdown-item">
|
2020-04-17 22:46:50 +02:00
|
|
|
Settings
|
|
|
|
</router-link>
|
2020-09-05 22:35:52 +02:00
|
|
|
<a :href="imprintUrl" class="dropdown-item" target="_blank" v-if="imprintUrl">Imprint</a>
|
|
|
|
<a
|
|
|
|
:href="privacyPolicyUrl"
|
|
|
|
class="dropdown-item"
|
|
|
|
target="_blank"
|
|
|
|
v-if="privacyPolicyUrl">
|
|
|
|
Privacy policy
|
|
|
|
</a>
|
|
|
|
<a @click="keyboardShortcutsActive = true" class="dropdown-item">Keyboard
|
|
|
|
Shortcuts</a>
|
2019-11-03 13:44:40 +01:00
|
|
|
<a @click="logout()" class="dropdown-item">
|
|
|
|
Logout
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</transition>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</nav>
|
2020-05-08 20:43:51 +02:00
|
|
|
<div v-if="userAuthenticated && (userInfo && userInfo.type === authTypes.USER)">
|
2020-06-25 23:56:41 +02:00
|
|
|
<a @click="menuActive = false" class="menu-hide-button" v-if="menuActive">
|
2019-11-03 13:44:40 +01:00
|
|
|
<icon icon="times"></icon>
|
|
|
|
</a>
|
2020-05-31 21:17:10 +02:00
|
|
|
<div
|
2020-09-05 22:35:52 +02:00
|
|
|
:class="{'has-background': background}"
|
|
|
|
:style="{'background-image': `url(${background})`}"
|
|
|
|
class="app-container"
|
2020-05-31 21:17:10 +02:00
|
|
|
>
|
2020-09-05 22:35:52 +02:00
|
|
|
<div :class="{'is-active': menuActive}" class="namespace-container">
|
2019-11-03 13:44:40 +01:00
|
|
|
<div class="menu top-menu">
|
2020-02-09 15:29:55 +01:00
|
|
|
<router-link :to="{name: 'home'}" class="logo">
|
2020-09-05 22:35:52 +02:00
|
|
|
<img alt="Vikunja" src="/images/logo-full.svg"/>
|
2020-02-09 15:29:55 +01:00
|
|
|
</router-link>
|
2019-11-03 13:44:40 +01:00
|
|
|
<ul class="menu-list">
|
|
|
|
<li>
|
|
|
|
<router-link :to="{ name: 'home'}">
|
2018-12-25 16:03:51 +01:00
|
|
|
<span class="icon">
|
|
|
|
<icon icon="calendar"/>
|
|
|
|
</span>
|
2019-11-03 13:44:40 +01:00
|
|
|
Overview
|
|
|
|
</router-link>
|
|
|
|
</li>
|
|
|
|
<li>
|
2020-06-17 22:24:37 +02:00
|
|
|
<router-link :to="{ name: 'tasks.range', params: {type: 'week'}}">
|
2018-12-25 23:41:55 +01:00
|
|
|
<span class="icon">
|
2020-02-14 17:38:48 +01:00
|
|
|
<icon icon="calendar-week"/>
|
2018-12-25 23:41:55 +01:00
|
|
|
</span>
|
2020-02-14 17:38:48 +01:00
|
|
|
Next Week
|
2019-11-03 13:44:40 +01:00
|
|
|
</router-link>
|
|
|
|
</li>
|
|
|
|
<li>
|
2020-06-17 22:24:37 +02:00
|
|
|
<router-link :to="{ name: 'tasks.range', params: {type: 'month'}}">
|
2018-12-25 23:41:55 +01:00
|
|
|
<span class="icon">
|
2020-02-14 17:38:48 +01:00
|
|
|
<icon :icon="['far', 'calendar-alt']"/>
|
2018-12-25 23:41:55 +01:00
|
|
|
</span>
|
2020-02-14 17:38:48 +01:00
|
|
|
Next Month
|
2019-11-03 13:44:40 +01:00
|
|
|
</router-link>
|
|
|
|
</li>
|
|
|
|
<li>
|
2020-06-17 22:24:37 +02:00
|
|
|
<router-link :to="{ name: 'teams.index'}">
|
2018-12-25 16:03:51 +01:00
|
|
|
<span class="icon">
|
|
|
|
<icon icon="users"/>
|
|
|
|
</span>
|
2019-11-03 13:44:40 +01:00
|
|
|
Teams
|
|
|
|
</router-link>
|
|
|
|
</li>
|
|
|
|
<li>
|
2020-06-17 00:20:37 +02:00
|
|
|
<router-link :to="{ name: 'namespaces.index'}">
|
2018-12-25 16:03:51 +01:00
|
|
|
<span class="icon">
|
|
|
|
<icon icon="layer-group"/>
|
|
|
|
</span>
|
2020-06-17 00:20:37 +02:00
|
|
|
Namespaces & Lists
|
2019-11-03 13:44:40 +01:00
|
|
|
</router-link>
|
|
|
|
</li>
|
|
|
|
<li>
|
2020-06-17 22:24:37 +02:00
|
|
|
<router-link :to="{ name: 'labels.index'}">
|
2019-03-07 20:48:40 +01:00
|
|
|
<span class="icon">
|
|
|
|
<icon icon="tags"/>
|
|
|
|
</span>
|
2019-11-03 13:44:40 +01:00
|
|
|
Labels
|
|
|
|
</router-link>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
2020-07-25 16:52:04 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
<a
|
|
|
|
@click="menuActive = false"
|
|
|
|
@shortkey="() => menuActive = !menuActive"
|
|
|
|
class="collapse-menu-button"
|
|
|
|
v-shortkey="['ctrl', 'e']">
|
2020-07-25 16:52:04 +02:00
|
|
|
Collapse Menu
|
|
|
|
</a>
|
|
|
|
|
2019-11-03 13:44:40 +01:00
|
|
|
<aside class="menu namespaces-lists">
|
|
|
|
<template v-for="n in namespaces">
|
|
|
|
<div :key="n.id">
|
2020-06-12 20:02:32 +02:00
|
|
|
<router-link
|
2020-09-05 22:35:52 +02:00
|
|
|
:to="{name: 'namespace.edit', params: {id: n.id} }"
|
|
|
|
class="nsettings"
|
|
|
|
v-if="n.id > 0"
|
|
|
|
v-tooltip.right="'Settings'">
|
2018-12-25 16:03:51 +01:00
|
|
|
<span class="icon">
|
|
|
|
<icon icon="cog"/>
|
|
|
|
</span>
|
2019-11-03 13:44:40 +01:00
|
|
|
</router-link>
|
2020-06-12 20:02:32 +02:00
|
|
|
<router-link
|
2020-09-05 22:35:52 +02:00
|
|
|
:key="n.id + 'list.create'"
|
|
|
|
:to="{ name: 'list.create', params: { id: n.id} }"
|
|
|
|
class="nsettings"
|
|
|
|
v-if="n.id > 0"
|
|
|
|
v-tooltip="'Add a new list in the ' + n.title + ' namespace'">
|
2018-12-25 16:03:51 +01:00
|
|
|
<span class="icon">
|
|
|
|
<icon icon="plus"/>
|
|
|
|
</span>
|
2019-11-03 13:44:40 +01:00
|
|
|
</router-link>
|
2020-06-12 20:02:32 +02:00
|
|
|
<label
|
2020-09-05 22:35:52 +02:00
|
|
|
:for="n.id + 'checker'"
|
|
|
|
class="menu-label"
|
|
|
|
v-tooltip="n.title + ' (' + n.lists.length + ')'">
|
2020-03-25 22:27:29 +01:00
|
|
|
<span class="name">
|
2020-06-12 20:02:32 +02:00
|
|
|
<span
|
2020-09-05 22:35:52 +02:00
|
|
|
:style="{ backgroundColor: n.hexColor }"
|
|
|
|
class="color-bubble"
|
|
|
|
v-if="n.hexColor !== ''">
|
2020-06-12 20:02:32 +02:00
|
|
|
</span>
|
2020-09-05 22:35:52 +02:00
|
|
|
{{ n.title }} ({{ n.lists.length }})
|
2020-03-22 21:40:13 +01:00
|
|
|
</span>
|
2019-11-03 13:44:40 +01:00
|
|
|
</label>
|
|
|
|
</div>
|
2020-06-12 20:02:32 +02:00
|
|
|
<input
|
2020-09-05 22:35:52 +02:00
|
|
|
:id="n.id + 'checker'"
|
|
|
|
:key="n.id + 'checker'"
|
|
|
|
checked="checked"
|
|
|
|
class="checkinput"
|
|
|
|
type="checkbox"/>
|
|
|
|
<div :key="n.id + 'child'" class="more-container">
|
2020-06-12 20:02:32 +02:00
|
|
|
<ul class="menu-list can-be-hidden">
|
2020-08-15 22:28:38 +02:00
|
|
|
<template v-for="l in n.lists">
|
|
|
|
<!-- This is a bit ugly but vue wouldn't want to let me filter this - probably because the lists
|
|
|
|
are nested inside of the namespaces makes it a lot harder.-->
|
2020-09-05 22:35:52 +02:00
|
|
|
<li :key="l.id" v-if="!l.isArchived">
|
2020-08-15 22:28:38 +02:00
|
|
|
<router-link
|
2020-09-06 16:20:48 +02:00
|
|
|
class="list-menu-link"
|
2020-09-05 22:35:52 +02:00
|
|
|
:class="{'router-link-exact-active': currentList.id === l.id}"
|
2020-09-06 16:20:48 +02:00
|
|
|
:to="{ name: 'list.index', params: { listId: l.id} }"
|
|
|
|
tag="span"
|
|
|
|
>
|
|
|
|
<span
|
|
|
|
:style="{ backgroundColor: l.hexColor }"
|
|
|
|
class="color-bubble"
|
|
|
|
v-if="l.hexColor !== ''">
|
|
|
|
</span>
|
|
|
|
<span class="list-menu-title">
|
2020-09-05 22:35:52 +02:00
|
|
|
{{ l.title }}
|
2020-06-12 20:02:32 +02:00
|
|
|
</span>
|
2020-09-06 16:20:48 +02:00
|
|
|
<span
|
|
|
|
:class="{'is-favorite': l.isFavorite}"
|
|
|
|
@click.stop="toggleFavoriteList(l)"
|
|
|
|
class="favorite">
|
|
|
|
<icon icon="star" v-if="l.isFavorite"/>
|
|
|
|
<icon :icon="['far', 'star']" v-else/>
|
|
|
|
</span>
|
2020-08-15 22:28:38 +02:00
|
|
|
</router-link>
|
|
|
|
</li>
|
|
|
|
</template>
|
2019-11-03 13:44:40 +01:00
|
|
|
</ul>
|
2020-09-05 22:35:52 +02:00
|
|
|
<label :for="n.id + 'checker'" class="hidden-hint">
|
|
|
|
Show hidden lists ({{ n.lists.length }})...
|
2019-11-03 13:44:40 +01:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</aside>
|
2020-09-05 22:35:52 +02:00
|
|
|
<a class="menu-bottom-link" href="https://vikunja.io" target="_blank">Powered by Vikunja</a>
|
2019-11-03 13:44:40 +01:00
|
|
|
</div>
|
2020-06-25 23:56:41 +02:00
|
|
|
<div
|
2020-09-05 22:35:52 +02:00
|
|
|
:class="[
|
2020-08-11 20:47:27 +02:00
|
|
|
{
|
|
|
|
'fullpage-overlay': fullpage,
|
|
|
|
'is-menu-enabled': menuActive,
|
|
|
|
},
|
|
|
|
$route.name,
|
|
|
|
]"
|
2020-09-05 22:35:52 +02:00
|
|
|
class="app-content"
|
2020-06-25 23:56:41 +02:00
|
|
|
>
|
2020-09-05 22:35:52 +02:00
|
|
|
<a @click="menuActive = false" class="mobile-overlay" v-if="menuActive"></a>
|
2019-11-03 13:44:40 +01:00
|
|
|
<transition name="fade">
|
|
|
|
<router-view/>
|
|
|
|
</transition>
|
2020-09-05 22:35:52 +02:00
|
|
|
<a @click="keyboardShortcutsActive = true" class="keyboard-shortcuts-button">
|
2020-07-25 16:52:04 +02:00
|
|
|
<icon icon="keyboard"/>
|
|
|
|
</a>
|
2019-11-03 13:44:40 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-05-31 21:31:42 +02:00
|
|
|
<div
|
2020-09-05 22:35:52 +02:00
|
|
|
:class="{'has-background': background}"
|
|
|
|
:style="{'background-image': `url(${background})`}"
|
|
|
|
class="link-share-container"
|
|
|
|
v-else-if="userAuthenticated && (userInfo && userInfo.type === authTypes.LINK_SHARE)"
|
2020-05-31 21:31:42 +02:00
|
|
|
>
|
2019-11-03 13:44:40 +01:00
|
|
|
<div class="container has-text-centered link-share-view">
|
|
|
|
<div class="column is-10 is-offset-1">
|
2020-09-05 22:35:52 +02:00
|
|
|
<img alt="Vikunja" class="logo" src="/images/logo-full.svg"/>
|
2020-05-31 21:31:42 +02:00
|
|
|
<h1
|
2020-09-05 22:35:52 +02:00
|
|
|
:style="{ 'opacity': currentList.title === '' ? '0': '1' }"
|
|
|
|
class="title">
|
|
|
|
{{ currentList.title === '' ? 'Loading...' : currentList.title }}
|
2020-05-31 21:31:42 +02:00
|
|
|
</h1>
|
|
|
|
<div class="box has-text-left view">
|
2019-11-03 13:44:40 +01:00
|
|
|
<div class="logout">
|
2020-05-31 21:31:42 +02:00
|
|
|
<a @click="logout()" class="button">
|
2019-11-03 13:44:40 +01:00
|
|
|
<span>Logout</span>
|
|
|
|
<span class="icon is-small">
|
2019-09-09 19:55:43 +02:00
|
|
|
<icon icon="sign-out-alt"/>
|
|
|
|
</span>
|
2019-11-03 13:44:40 +01:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<router-view/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div v-else>
|
2020-05-12 15:18:37 +02:00
|
|
|
<div class="noauth-container">
|
2020-09-05 22:35:52 +02:00
|
|
|
<img alt="Vikunja" src="/images/logo-full.svg"/>
|
2020-05-12 15:18:37 +02:00
|
|
|
<div class="message is-info" v-if="motd !== ''">
|
|
|
|
<div class="message-header">
|
|
|
|
<p>Info</p>
|
|
|
|
</div>
|
|
|
|
<div class="message-body">
|
|
|
|
{{ motd }}
|
2019-12-25 17:38:49 +01:00
|
|
|
</div>
|
2019-11-03 13:44:40 +01:00
|
|
|
</div>
|
2020-05-12 15:18:37 +02:00
|
|
|
<router-view/>
|
2019-11-03 13:44:40 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-03-02 21:19:26 +01:00
|
|
|
<notification/>
|
2019-11-03 13:44:40 +01:00
|
|
|
</div>
|
|
|
|
<div class="app offline" v-else>
|
|
|
|
<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-09-05 22:35:52 +02:00
|
|
|
<keyboard-shortcuts @close="keyboardShortcutsActive = false" 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>
|
2020-09-05 22:35:52 +02:00
|
|
|
import router from './router'
|
|
|
|
import {mapState} from 'vuex'
|
2019-09-09 19:55:43 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
import authTypes from './models/authTypes'
|
|
|
|
import Rights from './models/rights.json'
|
2018-09-07 08:42:17 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
import swEvents from './ServiceWorker/events'
|
|
|
|
import Notification from './components/misc/notification'
|
|
|
|
import {CURRENT_LIST, IS_FULLPAGE, ONLINE} from './store/mutation-types'
|
|
|
|
import KeyboardShortcuts from './components/misc/keyboard-shortcuts'
|
2019-12-18 22:30:20 +01:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
export default {
|
|
|
|
name: 'app',
|
|
|
|
components: {
|
|
|
|
KeyboardShortcuts,
|
|
|
|
Notification,
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
menuActive: true,
|
|
|
|
currentDate: new Date(),
|
|
|
|
userMenuActive: false,
|
|
|
|
authTypes: authTypes,
|
|
|
|
keyboardShortcutsActive: false,
|
2019-12-18 22:30:20 +01:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
// Service Worker stuff
|
|
|
|
updateAvailable: false,
|
|
|
|
registration: null,
|
|
|
|
refreshing: false,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeMount() {
|
|
|
|
// Check if the user is offline, show a message then
|
|
|
|
this.$store.commit(ONLINE, navigator.onLine)
|
|
|
|
window.addEventListener('online', () => this.$store.commit(ONLINE, navigator.onLine))
|
|
|
|
window.addEventListener('offline', () => this.$store.commit(ONLINE, navigator.onLine))
|
2019-10-16 23:27:21 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
// Password reset
|
|
|
|
if (this.$route.query.userPasswordReset !== undefined) {
|
|
|
|
localStorage.removeItem('passwordResetToken') // Delete an eventually preexisting old token
|
|
|
|
localStorage.setItem('passwordResetToken', this.$route.query.userPasswordReset)
|
|
|
|
router.push({name: 'user.password-reset.reset'})
|
|
|
|
}
|
|
|
|
// Email verification
|
|
|
|
if (this.$route.query.userEmailConfirm !== undefined) {
|
|
|
|
localStorage.removeItem('emailConfirmToken') // Delete an eventually preexisting old token
|
|
|
|
localStorage.setItem('emailConfirmToken', this.$route.query.userEmailConfirm)
|
|
|
|
router.push({name: 'user.login'})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeCreate() {
|
|
|
|
this.$store.dispatch('config/update')
|
|
|
|
this.$store.dispatch('auth/checkAuth')
|
|
|
|
.then(() => {
|
|
|
|
// Check if the user is already logged in, if so, redirect them to the homepage
|
|
|
|
if (
|
|
|
|
!this.userAuthenticated &&
|
|
|
|
this.$route.name !== 'user.login' &&
|
|
|
|
this.$route.name !== 'user.password-reset.request' &&
|
|
|
|
this.$route.name !== 'user.password-reset.reset' &&
|
|
|
|
this.$route.name !== 'user.register' &&
|
|
|
|
this.$route.name !== 'link-share.auth'
|
|
|
|
) {
|
|
|
|
router.push({name: 'user.login'})
|
|
|
|
}
|
2020-05-08 20:43:51 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
if (this.userAuthenticated && this.userInfo.type === authTypes.USER && (this.$route.params.name === 'home' || this.namespaces.length === 0)) {
|
|
|
|
this.loadNamespaces()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
created() {
|
2019-12-18 22:30:20 +01:00
|
|
|
|
2020-10-08 22:17:41 +02:00
|
|
|
// Make sure to always load the home route when running with electron
|
|
|
|
if(this.$route.fullPath.endsWith('frontend/index.html')) {
|
|
|
|
this.$router.push({name: 'home'})
|
|
|
|
}
|
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
// Service worker communication
|
|
|
|
document.addEventListener(swEvents.SW_UPDATED, this.showRefreshUI, {once: true})
|
2019-12-18 22:30:20 +01:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
if (navigator && navigator.serviceWorker) {
|
|
|
|
navigator.serviceWorker.addEventListener(
|
|
|
|
'controllerchange', () => {
|
|
|
|
if (this.refreshing) return
|
|
|
|
this.refreshing = true
|
|
|
|
window.location.reload()
|
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|
2019-12-19 21:50:07 +01:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
// Hide the menu by default on mobile
|
|
|
|
if (window.innerWidth < 770) {
|
|
|
|
this.menuActive = false
|
|
|
|
}
|
2020-06-25 23:56:41 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
// 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')
|
2020-06-12 20:02:32 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
// Check if the token is still valid if the window gets focus again to maybe renew it
|
|
|
|
window.addEventListener('focus', () => {
|
2020-06-12 20:11:23 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
if (!this.userAuthenticated) {
|
|
|
|
return
|
|
|
|
}
|
2020-06-12 20:11:23 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
const expiresIn = this.userInfo.exp - +new Date() / 1000
|
2020-06-12 20:11:23 +02:00
|
|
|
|
2020-09-05 22:35:52 +02: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')
|
|
|
|
router.push({name: 'user.login'})
|
|
|
|
return
|
|
|
|
}
|
2020-06-12 20:11:23 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
// 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.log('renewed token')
|
|
|
|
}
|
|
|
|
})
|
2020-07-29 22:01:54 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
// This will hide the menu once clicked outside of it
|
|
|
|
this.$nextTick(() => document.addEventListener('click', () => this.userMenuActive = false))
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
// call the method again if the route changes
|
|
|
|
'$route': 'doStuffAfterRoute',
|
|
|
|
},
|
|
|
|
computed: mapState({
|
|
|
|
userInfo: state => state.auth.info,
|
|
|
|
userAvatar: state => state.auth.avatarUrl,
|
|
|
|
userAuthenticated: state => state.auth.authenticated,
|
|
|
|
motd: state => state.config.motd,
|
|
|
|
online: ONLINE,
|
|
|
|
fullpage: IS_FULLPAGE,
|
|
|
|
namespaces(state) {
|
|
|
|
return state.namespaces.namespaces.filter(n => !n.isArchived)
|
2019-03-02 11:25:10 +01:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
currentList: CURRENT_LIST,
|
|
|
|
background: 'background',
|
|
|
|
imprintUrl: state => state.config.legal.imprintUrl,
|
|
|
|
privacyPolicyUrl: state => state.config.legal.privacyPolicyUrl,
|
|
|
|
canWriteCurrentList: state => state.currentList.maxRight > Rights.READ,
|
|
|
|
}),
|
|
|
|
methods: {
|
|
|
|
logout() {
|
|
|
|
this.$store.dispatch('auth/logout')
|
|
|
|
router.push({name: 'user.login'})
|
2019-03-02 11:25:10 +01:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
loadNamespaces() {
|
|
|
|
this.$store.dispatch('namespaces/loadNamespaces')
|
|
|
|
},
|
|
|
|
loadNamespacesIfNeeded(e) {
|
|
|
|
if (this.userAuthenticated && (this.userInfo && this.userInfo.type === authTypes.USER) && (e.name === 'home' || this.namespaces.length === 0)) {
|
|
|
|
this.loadNamespaces()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
doStuffAfterRoute(e) {
|
|
|
|
// this.setTitle('') // Reset the title if the page component does not set one itself
|
2020-07-07 22:07:13 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
if (this.$store.state[IS_FULLPAGE]) {
|
|
|
|
this.$store.commit(IS_FULLPAGE, false)
|
|
|
|
}
|
2020-05-09 22:31:33 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
this.loadNamespacesIfNeeded(e)
|
|
|
|
this.userMenuActive = false
|
2020-05-08 21:07:33 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
// If the menu is active on desktop, don't hide it because that would confuse the user
|
|
|
|
if (window.innerWidth < 770) {
|
|
|
|
this.menuActive = false
|
|
|
|
}
|
2020-06-25 23:56:41 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
// 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' ||
|
|
|
|
this.$route.name === 'user.settings' ||
|
|
|
|
this.$route.name === 'namespaces.index'
|
|
|
|
) {
|
|
|
|
this.$store.commit(CURRENT_LIST, {})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
showRefreshUI(e) {
|
|
|
|
console.log('recieved refresh event', e)
|
|
|
|
this.registration = e.detail
|
|
|
|
this.updateAvailable = true
|
|
|
|
},
|
|
|
|
refreshApp() {
|
|
|
|
this.updateExists = false
|
|
|
|
if (!this.registration || !this.registration.waiting) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// Notify the service worker to actually do the update
|
|
|
|
this.registration.waiting.postMessage('skipWaiting')
|
2019-03-02 11:25:10 +01:00
|
|
|
},
|
2020-09-06 16:20:48 +02:00
|
|
|
toggleFavoriteList(list) {
|
|
|
|
// The favorites pseudo list is always favorite
|
|
|
|
// Archived lists cannot be marked favorite
|
|
|
|
if (list.id === -1 || list.isArchived) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
this.$store.dispatch('lists/toggleListFavorite', list)
|
|
|
|
.catch(e => this.error(e, this))
|
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
}
|
2018-08-28 22:50:22 +02:00
|
|
|
</script>
|