-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathApp.vue
84 lines (75 loc) · 2.02 KB
/
App.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<template>
<v-app
v-if="verifiedServerConnection"
class="dandi-app"
>
<AppBar />
<v-main v-if="connectedToServer">
<UserStatusBanner />
<router-view />
<DandiFooter />
</v-main>
<v-main
v-else
class="d-flex align-center text-center"
>
{{ SERVER_DOWNTIME_MESSAGE }}
</v-main>
<v-snackbar
:model-value="showError"
:timeout="-1"
location="top right"
color="error"
>
<span>
Sorry, something went wrong on our side (the developers have been notified).
Please try that operation again later.
</span>
<template #actions>
<v-btn
color="white"
variant="text"
@click="showError = false"
>
Close
</v-btn>
</template>
</v-snackbar>
</v-app>
</template>
<script setup lang="ts">
import { getCurrentInstance, onMounted, ref } from 'vue';
import { dandiRest } from '@/rest';
import { useDandisetStore } from '@/stores/dandiset';
import AppBar from '@/components/AppBar/AppBar.vue';
import DandiFooter from '@/components/DandiFooter.vue';
import UserStatusBanner from '@/components/UserStatusBanner.vue';
const store = useDandisetStore();
const SERVER_DOWNTIME_MESSAGE = import.meta.env.VITE_APP_SERVER_DOWNTIME_MESSAGE || 'Connection to server failed.';
const verifiedServerConnection = ref(false);
const connectedToServer = ref(true);
// Catch any unhandled errors and display a snackbar prompt notifying the user.
const showError = ref(false);
getCurrentInstance().appContext.config.errorHandler = (err: Error) => {
showError.value = true;
throw err;
};
onMounted(() => {
Promise.all([
store.fetchSchema(),
dandiRest.restoreLogin(),
]).then(() => {
connectedToServer.value = true;
}).catch(() => {
connectedToServer.value = false;
}).finally(() => {
verifiedServerConnection.value = true;
});
});
</script>
<style scoped>
.dandi-app {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
</style>