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/Dashboard.vue

165 lines
4.4 KiB

3 years ago
<template>
<div class="container-fluid">
<div class="row">
<div class="col-12 col-md-5 col-xl-4">
<div v-if="! $root.isMobile">
<router-link to="/add" class="btn btn-primary mb-3"><font-awesome-icon icon="plus" /> Add New Monitor</router-link>
3 years ago
</div>
3 years ago
<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>.
3 years ago
</div>
3 years ago
3 years ago
<router-link v-for="(item, index) in sortedMonitorList" :key="index" :to="monitorURL(item.id)" class="item" :class="{ 'disabled': ! item.active }" @click="$root.cancelActiveList">
3 years ago
<div class="row">
<div class="col-6 col-md-8 small-padding" v-bind:class="{ 'monitorItem': $root.userHeartbeatBar == 'bottom' || $root.userHeartbeatBar == 'none' }">
3 years ago
<div class="info">
3 years ago
<Uptime :monitor="item" type="24" :pill="true" />
3 years ago
{{ item.name }}
</div>
</div>
<div class="col-6 col-md-4" v-bind:class="{ 'hideHeartbeatBar': $root.userHeartbeatBar == 'bottom' || $root.userHeartbeatBar == 'none' }">
<HeartbeatBar size="small" :monitor-id="item.id" />
</div>
</div>
<div class="row" v-if="$root.userHeartbeatBar == 'bottom'">
<div class="col-12">
3 years ago
<HeartbeatBar size="small" :monitor-id="item.id" />
3 years ago
</div>
</div>
</router-link>
3 years ago
</div>
</div>
<div class="col-12 col-md-7 col-xl-8">
3 years ago
<router-view />
</div>
</div>
</div>
</template>
<script>
3 years ago
import HeartbeatBar from "../components/HeartbeatBar.vue";
3 years ago
import Uptime from "../components/Uptime.vue";
3 years ago
3 years ago
export default {
components: {
3 years ago
Uptime,
3 years ago
HeartbeatBar,
3 years ago
},
data() {
3 years ago
return {}
3 years ago
},
3 years ago
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;
},
showList() {
return ! this.$root.isMobile || this.$root.showListMobile;
},
3 years ago
},
3 years ago
methods: {
monitorURL(id) {
return "/dashboard/" + id;
3 years ago
},
},
3 years ago
}
</script>
<style lang="scss" scoped>
3 years ago
@import "../assets/vars.scss";
.container-fluid {
width: 98%
}
.list {
3 years ago
height: auto;
min-height: calc(100vh - 240px);
3 years ago
.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;
3 years ago
overflow: hidden;
text-overflow: ellipsis;
3 years ago
}
&:hover {
background-color: $highlight-white;
3 years ago
}
&.active {
background-color: #cdf8f4;
3 years ago
}
}
}
3 years ago
.small-padding {
padding-left: 5px !important;
padding-right: 5px !important;
3 years ago
}
.dark {
.list {
.item {
&:hover {
background-color: $dark-bg2;
}
&.active {
background-color: $dark-bg2;
}
}
}
}
.hideHeartbeatBar {
display: none;
}
.monitorItem {
width: 100%;
}
3 years ago
</style>