add data connection error

This commit is contained in:
Paul Wilde 2023-03-17 16:02:55 +00:00
parent b80bba3d3d
commit 710eadc49b
3 changed files with 38 additions and 11 deletions

View file

@ -2,7 +2,12 @@
<v-app>
<MyNav :user="user" :site_info="site_info" />
<v-main class="ma-4">
<router-view :site_info="site_info" :user_info="user_info"></router-view>
<v-banner v-if="!site_info.backend_connected"
icon="mdi-exclamation"
color="error"
text="Cannot connect to the data service. Please contact support." >
</v-banner>
<router-view :site_info="site_info" :user_info="user_info"></router-view>
</v-main>
</v-app>
</template>
@ -19,8 +24,9 @@ export default {
data() {
return {
site_info: {
name: "Loading...",
features: {}
name: "",
features: {},
backend_connected: false
},
user: {
first_name: "",
@ -67,10 +73,21 @@ export default {
},
async getSiteInfo() {
console.log("Trying to get site Info...")
axios
.get(this.$api_url + "/info")
.then(response => {this.site_info = response.data})
.catch(error => (console.log(error)))
.then(response => {
this.site_info = response.data
this.site_info.backend_connected = true
})
.catch(error => {
this.site_info.name = "Error getting data connection"
this.site_info.backend_connected = false
console.log(error)
setTimeout(() => {
this.getSiteInfo()
},5000)
})
},
async getUserInfo() {

View file

@ -7,9 +7,9 @@
<v-menu>
<template v-slot:activator="{ props }">
<v-btn
variant="text"
v-if="user.logged_in"
v-bind="props">
variant="text"
v-if="user.logged_in"
v-bind="props">
Hi {{ user.first_name }}
</v-btn>
</template>
@ -70,7 +70,7 @@ export default{
} else {
this.items = []
}
}
},
},
computed: {
user_items() {

View file

@ -4,7 +4,7 @@
id="login-box"
title="Welcome!"
subtitle="Please Log In">
<v-form>
<v-form :disabled="!my_site_info.backend_connected">
<v-responsive class="mx-auto" max-width="475">
<v-text-field label="Username"
@keyup.enter="submitLogin"
@ -14,7 +14,7 @@
@keyup.enter="submitLogin"
v-model="user.password" clearable
type="password"></v-text-field>
<v-btn color="blue" :loading="logging_in" @click="submitLogin">Login</v-btn>
<v-btn :disabled="!my_site_info.backend_connected" color="blue" :loading="logging_in" @click="submitLogin">Login</v-btn>
<v-banner v-if="show_error" color="error" icon="mdi-exclamation-thick" theme="dark">
<v-banner-text>{{ error_message }}</v-banner-text>
</v-banner>
@ -27,9 +27,13 @@
import axios from 'axios'
export default {
props: {
site_info: {}
},
name: 'LoginPage',
data() {
return {
my_site_info: this.site_info,
user: {
email: "",
password: ""
@ -40,6 +44,12 @@ export default {
logging_in: false
}
},
watch: {
'site_info.backend_connected'(new_val) {
console.log(new_val)
this.my_site_info.backend_connected = new_val
}
},
methods: {
submitLogin() {
this.error_message = ""