Added page for if database connection is unavailable.

This commit is contained in:
neviyn 2018-10-09 13:51:12 +01:00
parent f09dd79754
commit 69204b4234
8 changed files with 81 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import NewSite from "./views/NewSite.vue";
import NewTutor from "./views/NewTutor.vue"; import NewTutor from "./views/NewTutor.vue";
import ViewObservations from "./views/ViewObservations.vue"; import ViewObservations from "./views/ViewObservations.vue";
import ObservationComplete from "./views/ObservationComplete.vue"; import ObservationComplete from "./views/ObservationComplete.vue";
import DBError from "./views/DatabaseUnavailable.vue"
Vue.use(Router); Vue.use(Router);
@ -52,6 +53,11 @@ export default new Router({
path: "/complete", path: "/complete",
name: "complete", name: "complete",
component: ObservationComplete component: ObservationComplete
},
{
path: "/dberror",
name: "dberror",
component: DBError
} }
] ]
}); });

View File

@ -0,0 +1,35 @@
<template>
<b-container>
<b-row class="my-3">
<b-col>
<v-icon label="Database Error" scale="5">
<v-icon name="database" style="color: black"></v-icon>
<v-icon name="ban" scale="2" style="color: red"></v-icon>
</v-icon>
</b-col>
</b-row>
<b-row class="my-3">
<b-col>
<h1>Database Unavailable</h1>
</b-col>
</b-row>
<b-row>
<b-col class="text-center">
<p>The database is currently unavailable.</p>
<p>Try again later or contact your System Administrator.</p>
</b-col>
</b-row>
</b-container>
</template>
<script>
import 'vue-awesome/icons/database'
import 'vue-awesome/icons/ban'
export default {
name: "DatabaseUnavailable"
}
</script>
<style scoped>
</style>

View File

@ -7,7 +7,7 @@
</b-row> </b-row>
<b-row class="my-3"> <b-row class="my-3">
<b-col> <b-col>
<b-button size="lg" to="/new">Start a new observation</b-button> <b-button size="lg" to="/new" variant="primary">Start a new observation</b-button>
</b-col> </b-col>
</b-row> </b-row>
<b-row class="my-3"> <b-row class="my-3">

View File

@ -33,6 +33,20 @@
submissionPassword: "" submissionPassword: ""
}; };
}, },
mounted() {
Vue.axios
.get("/site")
.then(response => {
})
.catch(error => {
if(error.response.status === 404){
this.$router.push("/dberror");
return;
}
this.alertText = error.response.data;
this.alertVariant = "danger";
});
},
methods: { methods: {
countDownChanged: function (dismissCountDown) { countDownChanged: function (dismissCountDown) {
this.dismissCountDown = dismissCountDown; this.dismissCountDown = dismissCountDown;

View File

@ -43,6 +43,10 @@ export default {
this.siteOptions = response.data; this.siteOptions = response.data;
}) })
.catch(error => { .catch(error => {
if(error.response.status === 404){
this.$router.push("/dberror");
return;
}
this.alertText = error.response.data; this.alertText = error.response.data;
this.alertVariant = "danger"; this.alertVariant = "danger";
}); });

View File

@ -106,6 +106,10 @@
this.loaded = true; this.loaded = true;
}) })
.catch(error => { .catch(error => {
if(error.response.status === 404){
this.$router.push("/dberror");
return;
}
this.errorStatus = error.response.status; this.errorStatus = error.response.status;
this.errorMessage = error.response.data; this.errorMessage = error.response.data;
this.$refs.errorModal.show(); this.$refs.errorModal.show();
@ -136,6 +140,15 @@
Vue.axios.get("/site/" + this.site + "/tutors").then(response => { Vue.axios.get("/site/" + this.site + "/tutors").then(response => {
this.tutorOptions = response.data; this.tutorOptions = response.data;
this.loadingTutors = false; this.loadingTutors = false;
}).catch(error => {
if(error.response.status === 404){
this.$router.push("/dberror");
return;
}
this.errorStatus = error.response.status;
this.errorMessage = error.response.data;
this.$refs.errorModal.show();
}); });
} }
}, },

View File

@ -161,6 +161,10 @@
this.siteOptions = response.data; this.siteOptions = response.data;
}) })
.catch(error => { .catch(error => {
if(error.response.status === 404){
this.$router.push("/dberror");
return;
}
this.errorStatus = error.response.status; this.errorStatus = error.response.status;
this.errorMessage = error.response.data; this.errorMessage = error.response.data;
this.$refs.errorModal.show(); this.$refs.errorModal.show();

View File

@ -101,6 +101,10 @@
this.siteOptions = response.data; this.siteOptions = response.data;
}) })
.catch(error => { .catch(error => {
if(error.response.status === 404){
this.$router.push("/dberror");
return;
}
console.log(error); console.log(error);
}); });
}, },