From 710eadc49bfa11c8128dd3c5a282c5f15ebe1aa5 Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Fri, 17 Mar 2023 16:02:55 +0000 Subject: [PATCH] add data connection error --- src/CMCApp.vue | 27 ++++++++++++++++++++++----- src/components/MyNav.vue | 8 ++++---- src/views/LoginPage.vue | 14 ++++++++++++-- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/CMCApp.vue b/src/CMCApp.vue index 26bc71f..efe37b4 100644 --- a/src/CMCApp.vue +++ b/src/CMCApp.vue @@ -2,7 +2,12 @@ - + + + @@ -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() { diff --git a/src/components/MyNav.vue b/src/components/MyNav.vue index 6fdb4e5..7eaed21 100644 --- a/src/components/MyNav.vue +++ b/src/components/MyNav.vue @@ -7,9 +7,9 @@ @@ -70,7 +70,7 @@ export default{ } else { this.items = [] } - } + }, }, computed: { user_items() { diff --git a/src/views/LoginPage.vue b/src/views/LoginPage.vue index 7f4591f..6b6a640 100644 --- a/src/views/LoginPage.vue +++ b/src/views/LoginPage.vue @@ -4,7 +4,7 @@ id="login-box" title="Welcome!" subtitle="Please Log In"> - + - Login + Login {{ error_message }} @@ -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 = ""