2020-06-12 17:40:18 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<button @click="refreshAll()" class="btn btn-secondary">
|
|
|
|
Refresh all
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<b-form-checkbox class="float-right" v-model="autoRefresh" size="lg" switch
|
|
|
|
>AutoRefresh</b-form-checkbox
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapActions } from 'vuex';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'reloadcontrol',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
autoRefresh: true,
|
2020-06-20 15:46:08 +00:00
|
|
|
refreshInterval: null,
|
|
|
|
refreshIntervalSlow: null,
|
2020-06-12 17:40:18 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.refreshOnce();
|
|
|
|
this.refreshAll();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions(['refreshSlow', 'refreshFrequent', 'refreshAll', 'refreshOnce']),
|
|
|
|
startRefresh() {
|
|
|
|
console.log('Starting automatic refresh.');
|
|
|
|
this.refreshFrequent();
|
2020-06-29 18:23:09 +00:00
|
|
|
if (this.autoRefresh) {
|
|
|
|
this.refreshInterval = setInterval(() => {
|
|
|
|
console.log('refreshing_interval');
|
|
|
|
this.refreshFrequent();
|
|
|
|
}, 5000);
|
|
|
|
}
|
2020-06-12 17:40:18 +00:00
|
|
|
this.refreshSlow();
|
2020-06-29 18:23:09 +00:00
|
|
|
if (this.autoRefresh) {
|
|
|
|
this.refreshIntervalSlow = setInterval(() => {
|
|
|
|
this.refreshSlow();
|
|
|
|
}, 60000);
|
|
|
|
}
|
2020-06-12 17:40:18 +00:00
|
|
|
},
|
|
|
|
stopRefresh() {
|
|
|
|
console.log('Stopping automatic refresh.');
|
2020-06-20 17:19:30 +00:00
|
|
|
clearInterval(this.refreshInterval);
|
2020-06-20 15:46:08 +00:00
|
|
|
clearInterval(this.refreshIntervalSlow);
|
2020-06-12 17:40:18 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.startRefresh();
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
this.stopRefresh();
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
autoRefresh(val) {
|
|
|
|
if (val) {
|
|
|
|
this.startRefresh();
|
|
|
|
} else {
|
|
|
|
this.stopRefresh();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
</style>
|