Files
gatus/web/app/src/components/EndpointGroup.vue
T

101 lines
2.7 KiB
Vue
Raw Normal View History

<template>
2021-10-23 16:47:12 -04:00
<div :class="endpoints.length === 0 ? 'mt-3' : 'mt-4'">
<slot v-if="name !== 'undefined'">
2021-10-23 16:47:12 -04:00
<div class="endpoint-group pt-2 border dark:bg-gray-800 dark:border-gray-500" @click="toggleGroup">
2021-05-09 12:59:22 -04:00
<h5 class='font-mono text-gray-400 text-xl font-medium pb-2 px-3 dark:text-gray-200 dark:hover:text-gray-500 dark:border-gray-500'>
<span v-if="healthy" class='text-green-600'>&#10003;</span>
<span v-else class='text-yellow-400'>~</span>
{{ name }}
2021-10-23 16:47:12 -04:00
<span class='float-right endpoint-group-arrow'>
2021-01-24 05:28:29 -05:00
{{ collapsed ? '&#9660;' : '&#9650;' }}
</span>
</h5>
</div>
</slot>
2021-10-23 16:47:12 -04:00
<div v-if="!collapsed" :class="name === 'undefined' ? '' : 'endpoint-group-content'">
<slot v-for="(endpoint, idx) in endpoints" :key="idx">
<Endpoint
:data="endpoint"
:maximumNumberOfResults="20"
@showTooltip="showTooltip"
@toggleShowAverageResponseTime="toggleShowAverageResponseTime" :showAverageResponseTime="showAverageResponseTime"
/>
</slot>
</div>
</div>
</template>
<script>
2021-10-23 16:47:12 -04:00
import Endpoint from './Endpoint.vue';
export default {
2021-10-23 16:47:12 -04:00
name: 'EndpointGroup',
components: {
2021-10-23 16:47:12 -04:00
Endpoint
},
props: {
name: String,
2021-10-23 16:47:12 -04:00
endpoints: Array,
showAverageResponseTime: Boolean
},
emits: ['showTooltip', 'toggleShowAverageResponseTime'],
methods: {
healthCheck() {
2021-10-23 16:47:12 -04:00
if (this.endpoints) {
for (let i in this.endpoints) {
for (let j in this.endpoints[i].results) {
if (!this.endpoints[i].results[j].success) {
// Set the endpoint group to unhealthy (only if it's currently healthy)
if (this.healthy) {
this.healthy = false;
}
return;
}
}
}
}
2021-10-23 16:47:12 -04:00
// Set the endpoint group to healthy (only if it's currently unhealthy)
if (!this.healthy) {
this.healthy = true;
}
2021-01-24 05:28:29 -05:00
},
toggleGroup() {
this.collapsed = !this.collapsed;
2021-10-23 16:47:12 -04:00
sessionStorage.setItem(`gatus:endpoint-group:${this.name}:collapsed`, this.collapsed);
2021-01-25 20:54:57 -05:00
},
showTooltip(result, event) {
this.$emit('showTooltip', result, event);
},
toggleShowAverageResponseTime() {
this.$emit('toggleShowAverageResponseTime');
}
},
watch: {
2021-10-23 16:47:12 -04:00
endpoints: function () {
this.healthCheck();
}
},
created() {
this.healthCheck();
},
data() {
return {
2021-01-24 05:28:29 -05:00
healthy: true,
2021-10-23 16:47:12 -04:00
collapsed: sessionStorage.getItem(`gatus:endpoint-group:${this.name}:collapsed`) === "true"
}
}
}
</script>
<style>
2021-10-23 16:47:12 -04:00
.endpoint-group {
cursor: pointer;
user-select: none;
}
2021-10-23 16:47:12 -04:00
.endpoint-group h5:hover {
2021-05-09 12:59:22 -04:00
color: #1b1e21;
}
</style>