Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Commit

Permalink
Show a 'offline' page when the initial load fails
Browse files Browse the repository at this point in the history
Signed-off-by: Yannick Schaus <habpanel@schaus.net>
  • Loading branch information
ghys committed Apr 10, 2018
1 parent 1f3df23 commit 16d1407
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
5 changes: 3 additions & 2 deletions web/src/pages/404.vue → web/src/pages/Error.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
style="width:30vw;max-width:150px;"
>
</p>
<p class="text-faded">Sorry, nothing here...<strong>(404)</strong></p>
<p class="text-faded" v-if="$route.meta.reason === 'offline'">openHAB is offline</p>
<p class="text-faded" v-else>Sorry, nothing here...<strong>(404)</strong></p>
<q-btn
color="secondary"
style="width:200px;"
@click="$router.push('/')"
>Go back</q-btn>
>{{ $route.meta.reason === 'offline' ? 'Try again' : 'Go back' }}</q-btn>
</div>
</template>
6 changes: 3 additions & 3 deletions web/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ Router.beforeEach((to, from, next) => {
// try to retrieve previously stored credentials
navigator.credentials.get({ password: true }).then((creds) => {
console.log('Using stored credentials to sign in')
store.dispatch('initialLoad', creds).then(() => next())
store.dispatch('initialLoad', creds).then(() => next()).catch(() => next('/offline'))
}).catch(() => {
store.dispatch('initialLoad').then(() => next())
store.dispatch('initialLoad').then(() => next()).catch(() => next('/offline'))
})
} else {
store.dispatch('initialLoad').then(() => next())
store.dispatch('initialLoad').then(() => next()).catch(() => next('/offline'))
}
})

Expand Down
7 changes: 6 additions & 1 deletion web/src/router/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import CardDeckPage from 'pages/CardDeck'
import CardSuggestionsPage from 'pages/CardSuggestions'
import CardRecentPage from 'pages/CardRecent'
import CardBookmarksPage from 'pages/CardBookmarks'
import ErrorPage from 'pages/404'
import ErrorPage from 'pages/Error'

export default [
{
Expand Down Expand Up @@ -36,6 +36,11 @@ export default [
props: true
},

{
path: '/offline',
component: ErrorPage,
meta: { reason: 'offline' }
},
{ // Always leave this as last one
path: '*',
component: ErrorPage
Expand Down

0 comments on commit 16d1407

Please sign in to comment.