2021-08-19 10:05:14 +00:00
|
|
|
<template>
|
2021-09-08 18:10:32 +00:00
|
|
|
<div class="shadow-box mb-3">
|
|
|
|
<div class="list-header">
|
|
|
|
<div class="placeholder"></div>
|
|
|
|
<div class="search-wrapper">
|
2021-10-07 13:47:11 +00:00
|
|
|
<a v-if="searchText == ''" class="search-icon">
|
2021-09-08 18:10:32 +00:00
|
|
|
<font-awesome-icon icon="search" />
|
|
|
|
</a>
|
2021-10-07 13:47:11 +00:00
|
|
|
<a v-if="searchText != ''" class="search-icon" @click="clearSearchText">
|
2021-09-08 18:10:32 +00:00
|
|
|
<font-awesome-icon icon="times" />
|
|
|
|
</a>
|
|
|
|
<input v-model="searchText" class="form-control search-input" :placeholder="$t('Search...')" />
|
|
|
|
</div>
|
2021-08-19 10:05:14 +00:00
|
|
|
</div>
|
2021-09-14 07:05:04 +00:00
|
|
|
<div class="monitor-list" :class="{ scrollbar: scrollbar }">
|
2021-09-08 18:10:32 +00:00
|
|
|
<div v-if="Object.keys($root.monitorList).length === 0" class="text-center mt-3">
|
|
|
|
{{ $t("No Monitors, please") }} <router-link to="/add">{{ $t("add one") }}</router-link>
|
|
|
|
</div>
|
2021-08-19 10:05:14 +00:00
|
|
|
|
2021-09-08 18:10:32 +00:00
|
|
|
<router-link v-for="(item, index) in sortedMonitorList" :key="index" :to="monitorURL(item.id)" class="item" :class="{ 'disabled': ! item.active }">
|
|
|
|
<div class="row">
|
2021-10-07 14:53:13 +00:00
|
|
|
<div class="col-9 col-md-8 small-padding" :class="{ 'monitorItem': $root.userHeartbeatBar == 'bottom' || $root.userHeartbeatBar == 'none' }">
|
2021-09-08 18:10:32 +00:00
|
|
|
<div class="info">
|
|
|
|
<Uptime :monitor="item" type="24" :pill="true" />
|
2021-10-07 13:47:11 +00:00
|
|
|
{{ item.name }}
|
2021-09-08 18:10:32 +00:00
|
|
|
</div>
|
|
|
|
<div class="tags">
|
|
|
|
<Tag v-for="tag in item.tags" :key="tag" :item="tag" :size="'sm'" />
|
|
|
|
</div>
|
2021-08-19 10:05:14 +00:00
|
|
|
</div>
|
2021-10-07 14:53:13 +00:00
|
|
|
<div v-show="$root.userHeartbeatBar == 'normal'" :key="$root.userHeartbeatBar" class="col-3 col-md-4">
|
2021-09-08 18:10:32 +00:00
|
|
|
<HeartbeatBar size="small" :monitor-id="item.id" />
|
2021-08-19 10:05:14 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2021-10-07 13:47:11 +00:00
|
|
|
<div v-if="$root.userHeartbeatBar == 'bottom'" class="row">
|
2021-09-08 18:10:32 +00:00
|
|
|
<div class="col-12">
|
|
|
|
<HeartbeatBar size="small" :monitor-id="item.id" />
|
|
|
|
</div>
|
2021-08-19 10:05:14 +00:00
|
|
|
</div>
|
2021-09-08 18:10:32 +00:00
|
|
|
</router-link>
|
|
|
|
</div>
|
2021-08-19 10:05:14 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import HeartbeatBar from "../components/HeartbeatBar.vue";
|
|
|
|
import Uptime from "../components/Uptime.vue";
|
2021-08-26 10:55:19 +00:00
|
|
|
import Tag from "../components/Tag.vue";
|
2021-10-07 09:39:58 +00:00
|
|
|
import { getMonitorRelativeURL } from "../util.ts";
|
2021-08-26 10:55:19 +00:00
|
|
|
|
2021-08-19 10:05:14 +00:00
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
Uptime,
|
|
|
|
HeartbeatBar,
|
2021-08-26 10:55:19 +00:00
|
|
|
Tag,
|
2021-08-19 10:05:14 +00:00
|
|
|
},
|
2021-08-29 18:22:49 +00:00
|
|
|
props: {
|
|
|
|
scrollbar: {
|
|
|
|
type: Boolean,
|
|
|
|
},
|
|
|
|
},
|
2021-09-08 18:10:32 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
searchText: "",
|
2021-10-07 14:53:13 +00:00
|
|
|
};
|
2021-09-08 18:10:32 +00:00
|
|
|
},
|
2021-08-19 10:05:14 +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);
|
2021-10-07 14:53:13 +00:00
|
|
|
});
|
2021-08-19 10:05:14 +00:00
|
|
|
|
2021-09-08 18:10:32 +00:00
|
|
|
// Simple filter by search text
|
|
|
|
// finds monitor name, tag name or tag value
|
2021-10-07 13:47:11 +00:00
|
|
|
if (this.searchText != "") {
|
2021-09-08 18:10:32 +00:00
|
|
|
const loweredSearchText = this.searchText.toLowerCase();
|
|
|
|
result = result.filter(monitor => {
|
|
|
|
return monitor.name.toLowerCase().includes(loweredSearchText)
|
|
|
|
|| monitor.tags.find(tag => tag.name.toLowerCase().includes(loweredSearchText)
|
2021-10-07 14:53:13 +00:00
|
|
|
|| tag.value?.toLowerCase().includes(loweredSearchText));
|
|
|
|
});
|
2021-09-08 18:10:32 +00:00
|
|
|
}
|
|
|
|
|
2021-08-19 10:05:14 +00:00
|
|
|
return result;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
monitorURL(id) {
|
2021-10-07 09:39:58 +00:00
|
|
|
return getMonitorRelativeURL(id);
|
2021-08-19 10:05:14 +00:00
|
|
|
},
|
2021-09-08 18:10:32 +00:00
|
|
|
clearSearchText() {
|
|
|
|
this.searchText = "";
|
|
|
|
}
|
2021-08-19 10:05:14 +00:00
|
|
|
},
|
2021-10-07 14:53:13 +00:00
|
|
|
};
|
2021-08-19 10:05:14 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import "../assets/vars.scss";
|
|
|
|
|
|
|
|
.small-padding {
|
|
|
|
padding-left: 5px !important;
|
|
|
|
padding-right: 5px !important;
|
|
|
|
}
|
|
|
|
|
2021-09-08 18:10:32 +00:00
|
|
|
.list-header {
|
|
|
|
border-bottom: 1px solid #dee2e6;
|
|
|
|
border-radius: 10px 10px 0 0;
|
|
|
|
margin: -10px;
|
|
|
|
margin-bottom: 10px;
|
2021-09-09 02:31:46 +00:00
|
|
|
padding: 10px;
|
2021-09-08 18:10:32 +00:00
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
|
|
.dark & {
|
2021-10-20 10:54:20 +00:00
|
|
|
background-color: $dark-header-bg;
|
2021-09-08 18:10:32 +00:00
|
|
|
border-bottom: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-09 02:31:46 +00:00
|
|
|
@media (max-width: 770px) {
|
|
|
|
.list-header {
|
|
|
|
margin: -20px;
|
|
|
|
margin-bottom: 10px;
|
|
|
|
padding: 5px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-08 18:10:32 +00:00
|
|
|
.search-wrapper {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.search-icon {
|
|
|
|
padding: 10px;
|
|
|
|
color: #c0c0c0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.search-input {
|
|
|
|
max-width: 15em;
|
|
|
|
}
|
|
|
|
|
2021-08-19 10:05:14 +00:00
|
|
|
.monitorItem {
|
|
|
|
width: 100%;
|
|
|
|
}
|
2021-08-26 10:55:19 +00:00
|
|
|
|
|
|
|
.tags {
|
|
|
|
padding-left: 62px;
|
|
|
|
display: flex;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
gap: 0;
|
|
|
|
}
|
2021-08-19 10:05:14 +00:00
|
|
|
</style>
|