Add a loader

This commit is contained in:
Conor McNamara
2023-02-16 20:48:01 +00:00
parent a6dafabae5
commit 893573c1b1
4 changed files with 35 additions and 4 deletions

12
package-lock.json generated
View File

@ -11,6 +11,7 @@
"axios": "^1.3.1", "axios": "^1.3.1",
"ol": "^7.2.2", "ol": "^7.2.2",
"vue": "^3.2.45", "vue": "^3.2.45",
"vue-loading-overlay": "^6.0.3",
"vue3-openlayers": "^0.1.71" "vue3-openlayers": "^0.1.71"
}, },
"devDependencies": { "devDependencies": {
@ -1324,6 +1325,17 @@
"@vue/shared": "3.2.45" "@vue/shared": "3.2.45"
} }
}, },
"node_modules/vue-loading-overlay": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/vue-loading-overlay/-/vue-loading-overlay-6.0.3.tgz",
"integrity": "sha512-Ab0hqnVKasVS2mNUo8Wkm95mSbk5fXp/karZmMou5yP0hTUOox/kZuBLNwgzJ4kFP829wFJl7O7FN1Dr0kRaVQ==",
"engines": {
"node": ">=12.13.0"
},
"peerDependencies": {
"vue": "^3.2.0"
}
},
"node_modules/vue3-openlayers": { "node_modules/vue3-openlayers": {
"version": "0.1.71", "version": "0.1.71",
"resolved": "https://registry.npmjs.org/vue3-openlayers/-/vue3-openlayers-0.1.71.tgz", "resolved": "https://registry.npmjs.org/vue3-openlayers/-/vue3-openlayers-0.1.71.tgz",

View File

@ -11,6 +11,7 @@
"axios": "^1.3.1", "axios": "^1.3.1",
"ol": "^7.2.2", "ol": "^7.2.2",
"vue": "^3.2.45", "vue": "^3.2.45",
"vue-loading-overlay": "^6.0.3",
"vue3-openlayers": "^0.1.71" "vue3-openlayers": "^0.1.71"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,5 +1,5 @@
<template> <template>
<button @click="getLiveTrainData">Show</button> <button @click="getLiveTrainData">Fetch Data</button>
<button @click="postLiveTrainData">Populate Database</button> <button @click="postLiveTrainData">Populate Database</button>
<!--Sidebar, fades out on click of X button--> <!--Sidebar, fades out on click of X button-->
@ -75,11 +75,26 @@ export default {
} }
}, },
created() {
// initial request of fata
this.getLiveTrainData()
// request new data every 60 seconds
// window.setInterval(this.getLiveTrainData, 60000);
},
methods: { methods: {
// fetch live train data from the Firestore database // fetch live train data from the Firestore database
getLiveTrainData() { getLiveTrainData() {
let loader = this.$loading.show({
loader: 'dots',
container: this.$refs.container,
canCancel: false
});
axios.get('https://us-central1-concept-d5be1.cloudfunctions.net/getLiveTrainData') axios.get('https://us-central1-concept-d5be1.cloudfunctions.net/getLiveTrainData')
.then((response) => { .then((response) => {
loader.hide();
this.dbLiveTrainData = response.data; this.dbLiveTrainData = response.data;
// create an array of coordinates and hashmap with the key-values {index: JSON obj} // create an array of coordinates and hashmap with the key-values {index: JSON obj}

View File

@ -4,7 +4,10 @@ import App from './App.vue'
import OpenLayersMap from 'vue3-openlayers' import OpenLayersMap from 'vue3-openlayers'
import 'vue3-openlayers/dist/vue3-openlayers.css' import 'vue3-openlayers/dist/vue3-openlayers.css'
import { LoadingPlugin } from 'vue-loading-overlay'
import 'vue-loading-overlay/dist/css/index.css'
const app = createApp(App); const app = createApp(App);
app.use(OpenLayersMap) app.use(OpenLayersMap)
app.use(LoadingPlugin)
app.mount('#app') app.mount('#app')