Skip to content
Snippets Groups Projects
Commit ee19672f authored by Hangzhi Yu's avatar Hangzhi Yu
Browse files

Add basic offline check and indicator

parent 3a46ce16
No related branches found
No related tags found
1 merge request!1123Resolve "Finalise Vuetify app as SPA"
......@@ -185,8 +185,13 @@
</v-app-bar>
<v-main>
<v-container>
<broadcast-channel-notification channel-name="cache-or-not" />
<broadcast-channel-notification channel-name="offline-fallback" />
<broadcast-channel-notification channel-name="cache-or-not"/>
<message-box
type="warning"
v-if="$root.offline"
>{{ $t("network_errors.offline_notification") }}
</message-box>
<message-box
type="error"
......@@ -361,6 +366,7 @@ export default {
sideNavMenu: null,
accountMenu: null,
snackbarItems: null,
ping: null,
};
},
methods: {
......@@ -500,6 +506,24 @@ export default {
},
deep: true,
},
ping: function (ping) {
if (ping === "pong") {
this.$apollo.queries.ping.stopPolling();
this.$apollo.queries.whoAmI.startPolling(10000);
this.$apollo.queries.snackbarItems.startPolling(1000);
this.$apollo.queries.messages.startPolling(1000);
this.$root.offline = false;
}
},
"$root.offline": function (offline) {
if (offline) {
this.ping = null;
this.$apollo.queries.ping.startPolling(1000);
this.$apollo.queries.whoAmI.stopPolling();
this.$apollo.queries.snackbarItems.stopPolling();
this.$apollo.queries.messages.stopPolling();
}
},
},
mounted() {
this.$router.onReady(this.getPermissionNames);
......
......@@ -128,7 +128,7 @@ const errorLink = onError(({ graphQLErrors, networkError }) => {
if (graphQLErrors) addErrorSnackbarItem("graphql.snackbar_error_message");
if (networkError)
addErrorSnackbarItem("network_errors.snackbar_error_message");
app.offline = true;
});
const httpLink = new HttpLink({
......@@ -193,6 +193,7 @@ const app = new Vue({
data: () => ({
showCacheAlert: false,
contentLoading: false,
offline: false,
}),
router,
i18n,
......
......@@ -181,7 +181,8 @@
"error_404": "404",
"page_not_found": "The requested page or resource could not be found.",
"take_me_back": "Take me back",
"snackbar_error_message": "A network error occurred. Please try again."
"snackbar_error_message": "A network error occurred. Please try again.",
"offline_notification": "You are offline. Some features may not work and some data may not be up to date."
},
"service_worker": {
"new_version_available": "A new version of the app is available",
......
{
ping
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment