You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
uptime-kuma/src/pages/DashboardHome.vue

194 lines
5.2 KiB

3 years ago
<template>
<div v-if="$route.name === 'DashboardHome'">
3 years ago
<h1 class="mb-3">
Quick Stats
</h1>
3 years ago
<div class="shadow-box big-padding text-center">
<div class="row">
3 years ago
<div class="col">
3 years ago
<h3>Up</h3>
3 years ago
<span class="num">{{ stats.up }}</span>
3 years ago
</div>
3 years ago
<div class="col">
3 years ago
<h3>Down</h3>
3 years ago
<span class="num text-danger">{{ stats.down }}</span>
</div>
<div class="col">
<h3>Unknown</h3>
<span class="num text-secondary">{{ stats.unknown }}</span>
3 years ago
</div>
<div class="col">
<h3>Pause</h3>
3 years ago
<span class="num text-secondary">{{ stats.pause }}</span>
3 years ago
</div>
</div>
3 years ago
<div v-if="false" class="row">
<div class="col-3">
<h3>Uptime</h3>
<p>(24-hour)</p>
3 years ago
<span class="num" />
3 years ago
</div>
<div class="col-3">
<h3>Uptime</h3>
<p>(30-day)</p>
3 years ago
<span class="num" />
3 years ago
</div>
</div>
</div>
3 years ago
<div class="shadow-box" style="margin-top: 25px;">
<table class="table table-borderless table-hover">
<thead>
3 years ago
<tr>
<th>Name</th>
<th>Status</th>
<th>DateTime</th>
<th>Message</th>
</tr>
</thead>
<tbody>
3 years ago
<tr v-for="(beat, index) in displayedRecords" :key="index">
<td>{{ beat.name }}</td>
<td><Status :status="beat.status" /></td>
<td><Datetime :value="beat.time" /></td>
<td>{{ beat.msg }}</td>
</tr>
<tr v-if="importantHeartBeatList.length === 0">
<td colspan="4">
No important events
</td>
</tr>
</tbody>
</table>
3 years ago
<div class="d-flex justify-content-center kuma_pagination">
<pagination
v-model="page"
3 years ago
:records="importantHeartBeatList.length"
:per-page="perPage"
/>
3 years ago
</div>
3 years ago
</div>
</div>
<router-view ref="child" />
</template>
<script>
import Status from "../components/Status.vue";
import Datetime from "../components/Datetime.vue";
3 years ago
import Pagination from "v-pagination-3";
3 years ago
export default {
3 years ago
components: {
Datetime,
Status,
Pagination,
},
data() {
return {
page: 1,
perPage: 25,
heartBeatList: [],
}
},
3 years ago
computed: {
3 years ago
stats() {
let result = {
up: 0,
down: 0,
unknown: 0,
pause: 0,
};
for (let monitorID in this.$root.monitorList) {
let beat = this.$root.lastHeartbeatList[monitorID];
let monitor = this.$root.monitorList[monitorID]
if (monitor && ! monitor.active) {
result.pause++;
} else if (beat) {
if (beat.status === 1) {
result.up++;
} else if (beat.status === 0) {
result.down++;
} else if (beat.status === 2) {
3 years ago
result.up++;
3 years ago
} else {
result.unknown++;
}
} else {
result.unknown++;
}
}
return result;
},
importantHeartBeatList() {
let result = [];
for (let monitorID in this.$root.importantHeartbeatList) {
3 years ago
let list = this.$root.importantHeartbeatList[monitorID]
result = result.concat(list);
}
for (let beat of result) {
let monitor = this.$root.monitorList[beat.monitorID];
if (monitor) {
beat.name = monitor.name
}
}
result.sort((a, b) => {
if (a.time > b.time) {
return -1;
3 years ago
}
if (a.time < b.time) {
return 1;
}
3 years ago
return 0;
});
3 years ago
this.heartBeatList = result;
return result;
3 years ago
},
displayedRecords() {
const startIndex = this.perPage * (this.page - 1);
const endIndex = startIndex + this.perPage;
return this.heartBeatList.slice(startIndex, endIndex);
},
3 years ago
},
3 years ago
}
</script>
<style scoped lang="scss">
@import "../assets/vars";
.num {
font-size: 30px;
color: $primary;
font-weight: bold;
display: block;
}
.shadow-box {
padding: 20px;
}
table {
font-size: 14px;
tr {
transition: all ease-in-out 0.2ms;
}
3 years ago
}
</style>