uptime-kuma/src/pages/Dashboard.vue

150 lines
3.8 KiB
Vue
Raw Normal View History

2021-06-25 13:55:49 +00:00
<template>
<div class="container-fluid">
<div class="row">
2021-06-30 13:04:58 +00:00
<div class="col-12 col-md-5 col-xl-4">
2021-07-11 07:23:28 +00:00
<div v-if="! $root.isMobile">
2021-08-08 13:42:37 +00:00
<router-link to="/add" class="btn btn-primary mb-3"><font-awesome-icon icon="plus" /> Add New Monitor</router-link>
2021-06-25 13:55:49 +00:00
</div>
2021-07-27 17:47:13 +00:00
<div v-if="showList" class="shadow-box list mb-4">
<div v-if="Object.keys($root.monitorList).length === 0" class="text-center mt-3">
No Monitors, please <router-link to="/add">add one</router-link>.
2021-07-11 05:47:57 +00:00
</div>
2021-06-25 13:55:49 +00:00
2021-07-27 17:47:13 +00:00
<router-link v-for="(item, index) in sortedMonitorList" :key="index" :to="monitorURL(item.id)" class="item" :class="{ 'disabled': ! item.active }" @click="$root.cancelActiveList">
2021-06-25 13:55:49 +00:00
<div class="row">
2021-07-27 17:47:13 +00:00
<div class="col-6 col-md-8 small-padding">
2021-06-25 13:55:49 +00:00
<div class="info">
2021-07-01 05:11:16 +00:00
<Uptime :monitor="item" type="24" :pill="true" />
2021-06-25 13:55:49 +00:00
{{ item.name }}
</div>
</div>
2021-07-27 17:47:13 +00:00
<div class="col-6 col-md-4">
2021-06-27 08:10:55 +00:00
<HeartbeatBar size="small" :monitor-id="item.id" />
2021-06-25 13:55:49 +00:00
</div>
</div>
</router-link>
</div>
</div>
2021-06-30 13:04:58 +00:00
<div class="col-12 col-md-7 col-xl-8">
2021-06-25 13:55:49 +00:00
<router-view />
</div>
</div>
</div>
</template>
<script>
2021-06-27 08:10:55 +00:00
import HeartbeatBar from "../components/HeartbeatBar.vue";
2021-07-01 05:11:16 +00:00
import Uptime from "../components/Uptime.vue";
2021-06-27 08:10:55 +00:00
2021-06-25 13:55:49 +00:00
export default {
components: {
2021-07-01 05:11:16 +00:00
Uptime,
2021-07-27 17:47:13 +00:00
HeartbeatBar,
2021-06-25 13:55:49 +00:00
},
data() {
2021-07-27 17:47:13 +00:00
return {}
2021-06-25 13:55:49 +00:00
},
2021-07-01 05:11:16 +00:00
computed: {
sortedMonitorList() {
let result = Object.values(this.$root.monitorList);
result.sort((m1, m2) => {
if (m1.active !== m2.active) {
if (m1.active === 0) {
return 1;
}
if (m2.active === 0) {
return -1;
}
}
if (m1.weight !== m2.weight) {
if (m1.weight > m2.weight) {
return -1;
}
if (m1.weight < m2.weight) {
return 1;
}
}
return m1.name.localeCompare(m2.name);
})
return result;
},
2021-07-11 07:23:28 +00:00
showList() {
return ! this.$root.isMobile || this.$root.showListMobile;
},
2021-07-01 05:11:16 +00:00
},
2021-06-25 13:55:49 +00:00
methods: {
monitorURL(id) {
return "/dashboard/" + id;
2021-07-27 17:47:13 +00:00
},
},
2021-06-25 13:55:49 +00:00
}
</script>
<style lang="scss" scoped>
2021-06-25 13:55:49 +00:00
@import "../assets/vars.scss";
.container-fluid {
width: 98%
}
.list {
2021-06-27 08:10:55 +00:00
height: auto;
2021-08-05 11:56:20 +00:00
min-height: calc(100vh - 240px);
2021-06-25 13:55:49 +00:00
.item {
display: block;
text-decoration: none;
padding: 15px 15px 12px 15px;
border-radius: 10px;
transition: all ease-in-out 0.15s;
&.disabled {
opacity: 0.3;
}
.info {
white-space: nowrap;
2021-06-27 08:10:55 +00:00
overflow: hidden;
text-overflow: ellipsis;
2021-06-25 13:55:49 +00:00
}
&:hover {
2021-07-13 04:16:11 +00:00
background-color: $highlight-white;
2021-06-25 13:55:49 +00:00
}
&.active {
2021-07-13 04:16:11 +00:00
background-color: #cdf8f4;
2021-06-25 13:55:49 +00:00
}
}
}
2021-07-01 05:11:16 +00:00
.small-padding {
padding-left: 5px !important;
padding-right: 5px !important;
2021-06-25 13:55:49 +00:00
}
.dark {
.list {
.item {
&:hover {
background-color: $dark-bg2;
}
&.active {
background-color: $dark-bg2;
}
}
}
}
2021-06-25 13:55:49 +00:00
</style>