Files
gatus/web/app/src/views/Home.vue
T

59 lines
1.5 KiB
Vue
Raw Normal View History

2021-01-27 18:25:37 -05:00
<template>
<Services
:serviceStatuses="serviceStatuses"
:showStatusOnHover="true"
@showTooltip="showTooltip"
@toggleShowAverageResponseTime="toggleShowAverageResponseTime" :showAverageResponseTime="showAverageResponseTime"
/>
<Pagination @page="changePage"/>
2021-01-27 18:25:37 -05:00
<Settings @refreshData="fetchData"/>
</template>
<script>
import Settings from '@/components/Settings.vue'
import Services from '@/components/Services.vue';
import Pagination from "@/components/Pagination";
2021-01-27 18:25:37 -05:00
import {SERVER_URL} from "@/main.js";
export default {
name: 'Home',
components: {
Pagination,
2021-01-27 18:25:37 -05:00
Services,
Settings,
},
emits: ['showTooltip', 'toggleShowAverageResponseTime'],
2021-01-27 18:25:37 -05:00
methods: {
fetchData() {
2021-01-30 21:17:17 -05:00
//console.log("[Home][fetchData] Fetching data");
fetch(`${SERVER_URL}/api/v1/statuses?page=${this.currentPage}`)
2021-01-27 18:25:37 -05:00
.then(response => response.json())
.then(data => {
if (JSON.stringify(this.serviceStatuses) !== JSON.stringify(data)) {
this.serviceStatuses = data;
}
});
},
changePage(page) {
this.currentPage = page;
this.fetchData();
},
showTooltip(result, event) {
this.$emit('showTooltip', result, event);
},
toggleShowAverageResponseTime() {
this.showAverageResponseTime = !this.showAverageResponseTime;
},
2021-01-27 18:25:37 -05:00
},
data() {
return {
serviceStatuses: {},
currentPage: 1,
showAverageResponseTime: true
2021-01-27 18:25:37 -05:00
}
},
created() {
this.fetchData();
}
}
</script>