Added loading state to ViewObservations

This commit is contained in:
neviyn 2019-02-15 16:13:13 +00:00
parent e6f2963e88
commit 15024b3a84

View File

@ -126,6 +126,9 @@
</b-card> </b-card>
<b-button class="mt-2" variant="success" @click="getCSV()">CSV Dump</b-button> <b-button class="mt-2" variant="success" @click="getCSV()">CSV Dump</b-button>
</b-container> </b-container>
<b-container v-else-if="loading">
Loading...
</b-container>
<b-container v-else> <b-container v-else>
<b-row> <b-row>
<b-col> <b-col>
@ -152,7 +155,8 @@ export default {
return { return {
observationData: null, observationData: null,
errorStatus: null, errorStatus: null,
errorMessage: null errorMessage: null,
loading: false
}; };
}, },
computed: { computed: {
@ -175,6 +179,7 @@ export default {
}, },
methods: { methods: {
getFiltered: function() { getFiltered: function() {
this.loading = true
Vue.axios Vue.axios
.post("/observations", { .post("/observations", {
site: this.$store.state.search.site, site: this.$store.state.search.site,
@ -186,11 +191,13 @@ export default {
}) })
.then(response => { .then(response => {
this.observationData = response.data; this.observationData = response.data;
this.loading = false
}) })
.catch(error => { .catch(error => {
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();
this.loading = false
}); });
}, },
getCSV: function() { getCSV: function() {