2021-09-13 11:21:39 +00:00
|
|
|
<template>
|
|
|
|
<!-- Group List -->
|
|
|
|
<Draggable
|
|
|
|
v-model="$root.publicGroupList"
|
|
|
|
:disabled="!editMode"
|
|
|
|
item-key="id"
|
|
|
|
:animation="100"
|
|
|
|
>
|
2021-09-15 06:34:30 +00:00
|
|
|
<template #item="group">
|
2021-09-17 06:42:19 +00:00
|
|
|
<div class="mb-5 ">
|
2021-09-14 15:27:11 +00:00
|
|
|
<!-- Group Title -->
|
2021-09-17 06:42:19 +00:00
|
|
|
<h2 class="group-title">
|
2021-09-15 06:34:30 +00:00
|
|
|
<font-awesome-icon v-if="editMode && showGroupDrag" icon="arrows-alt-v" class="action drag me-3" />
|
|
|
|
<font-awesome-icon v-if="editMode" icon="times" class="action remove me-3" @click="removeGroup(group.index)" />
|
|
|
|
<Editable v-model="group.element.name" :contenteditable="editMode" tag="span" />
|
2021-09-14 15:27:11 +00:00
|
|
|
</h2>
|
2021-09-13 11:21:39 +00:00
|
|
|
|
|
|
|
<div class="shadow-box monitor-list mt-4 position-relative">
|
2021-09-15 06:34:30 +00:00
|
|
|
<div v-if="group.element.monitorList.length === 0" class="text-center no-monitor-msg">
|
2021-09-13 11:21:39 +00:00
|
|
|
{{ $t("No Monitors") }}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Monitor List -->
|
2021-09-15 06:34:30 +00:00
|
|
|
<!-- animation is not working, no idea why -->
|
2021-09-13 11:21:39 +00:00
|
|
|
<Draggable
|
2021-09-15 06:34:30 +00:00
|
|
|
v-model="group.element.monitorList"
|
2021-09-13 11:21:39 +00:00
|
|
|
class="monitor-list"
|
|
|
|
group="same-group"
|
|
|
|
:disabled="!editMode"
|
|
|
|
:animation="100"
|
2021-09-14 06:12:27 +00:00
|
|
|
item-key="id"
|
2021-09-13 11:21:39 +00:00
|
|
|
>
|
2021-09-15 06:34:30 +00:00
|
|
|
<template #item="monitor">
|
2021-09-13 11:21:39 +00:00
|
|
|
<div class="item">
|
|
|
|
<div class="row">
|
2022-05-18 12:16:50 +00:00
|
|
|
<div class="col-9 col-md-8 small-padding">
|
|
|
|
<div class="info">
|
2021-09-15 12:40:26 +00:00
|
|
|
<font-awesome-icon v-if="editMode" icon="arrows-alt-v" class="action drag me-3" />
|
2021-09-15 06:34:30 +00:00
|
|
|
<font-awesome-icon v-if="editMode" icon="times" class="action remove me-3" @click="removeMonitor(group.index, monitor.index)" />
|
|
|
|
|
|
|
|
<Uptime :monitor="monitor.element" type="24" :pill="true" />
|
2022-06-11 16:23:12 +00:00
|
|
|
<a
|
|
|
|
v-if="showLink(monitor)"
|
|
|
|
:href="monitor.element.url"
|
|
|
|
class="item-name"
|
|
|
|
target="_blank"
|
2022-09-10 19:35:22 +00:00
|
|
|
rel="noopener noreferrer"
|
2022-06-11 16:23:12 +00:00
|
|
|
>
|
|
|
|
{{ monitor.element.name }}
|
|
|
|
</a>
|
|
|
|
<p v-else class="item-name"> {{ monitor.element.name }} </p>
|
2022-07-04 12:31:05 +00:00
|
|
|
<span
|
|
|
|
v-if="showLink(monitor, true)"
|
|
|
|
title="Toggle Clickable Link"
|
|
|
|
>
|
2022-07-04 10:33:38 +00:00
|
|
|
<font-awesome-icon
|
|
|
|
v-if="editMode"
|
|
|
|
:class="{'link-active': monitor.element.sendUrl, 'btn-link': true}"
|
|
|
|
icon="link" class="action me-3"
|
|
|
|
|
|
|
|
@click="toggleLink(group.index, monitor.index)"
|
|
|
|
/>
|
|
|
|
</span>
|
2021-10-28 01:53:27 +00:00
|
|
|
</div>
|
2022-05-28 15:08:14 +00:00
|
|
|
<div v-if="showTags" class="tags">
|
2021-10-27 10:06:06 +00:00
|
|
|
<Tag v-for="tag in monitor.element.tags" :key="tag" :item="tag" :size="'sm'" />
|
2021-09-13 11:21:39 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-05-18 12:16:50 +00:00
|
|
|
<div :key="$root.userHeartbeatBar" class="col-3 col-md-4">
|
2021-09-15 06:34:30 +00:00
|
|
|
<HeartbeatBar size="small" :monitor-id="monitor.element.id" />
|
2021-09-13 11:21:39 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</Draggable>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</Draggable>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Draggable from "vuedraggable";
|
|
|
|
import HeartbeatBar from "./HeartbeatBar.vue";
|
|
|
|
import Uptime from "./Uptime.vue";
|
2021-10-27 10:06:06 +00:00
|
|
|
import Tag from "./Tag.vue";
|
2021-09-13 11:21:39 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
Draggable,
|
|
|
|
HeartbeatBar,
|
|
|
|
Uptime,
|
2021-10-27 10:06:06 +00:00
|
|
|
Tag,
|
2021-09-13 11:21:39 +00:00
|
|
|
},
|
|
|
|
props: {
|
2022-06-01 23:32:05 +00:00
|
|
|
/** Are we in edit mode? */
|
2021-09-13 11:21:39 +00:00
|
|
|
editMode: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
2022-06-01 23:32:05 +00:00
|
|
|
/** Should tags be shown? */
|
2022-03-18 09:56:46 +00:00
|
|
|
showTags: {
|
|
|
|
type: Boolean,
|
|
|
|
}
|
2021-09-13 11:21:39 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
|
2021-09-17 06:42:19 +00:00
|
|
|
};
|
2021-09-13 11:21:39 +00:00
|
|
|
},
|
2021-09-15 06:34:30 +00:00
|
|
|
computed: {
|
|
|
|
showGroupDrag() {
|
|
|
|
return (this.$root.publicGroupList.length >= 2);
|
|
|
|
}
|
|
|
|
},
|
2021-09-13 11:21:39 +00:00
|
|
|
created() {
|
|
|
|
|
2021-09-15 06:34:30 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2022-06-01 23:32:05 +00:00
|
|
|
/**
|
|
|
|
* Remove the specified group
|
|
|
|
* @param {number} index Index of group to remove
|
|
|
|
*/
|
2021-09-15 06:34:30 +00:00
|
|
|
removeGroup(index) {
|
|
|
|
this.$root.publicGroupList.splice(index, 1);
|
|
|
|
},
|
|
|
|
|
2022-06-01 23:32:05 +00:00
|
|
|
/**
|
|
|
|
* Remove a monitor from a group
|
|
|
|
* @param {number} groupIndex Index of group to remove monitor
|
|
|
|
* from
|
|
|
|
* @param {number} index Index of monitor to remove
|
|
|
|
*/
|
2021-09-15 06:34:30 +00:00
|
|
|
removeMonitor(groupIndex, index) {
|
|
|
|
this.$root.publicGroupList[groupIndex].monitorList.splice(index, 1);
|
|
|
|
},
|
2022-06-11 16:23:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggle the value of sendUrl
|
|
|
|
* @param {number} groupIndex Index of group monitor is member of
|
|
|
|
* @param {number} index Index of monitor within group
|
|
|
|
*/
|
|
|
|
toggleLink(groupIndex, index) {
|
|
|
|
this.$root.publicGroupList[groupIndex].monitorList[index].sendUrl = !this.$root.publicGroupList[groupIndex].monitorList[index].sendUrl;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Should a link to the monitor be shown?
|
|
|
|
* Attempts to guess if a link should be shown based upon if
|
|
|
|
* sendUrl is set and if the URL is default or not.
|
|
|
|
* @param {Object} monitor Monitor to check
|
2022-07-04 12:31:05 +00:00
|
|
|
* @param {boolean} [ignoreSendUrl=false] Should the presence of the sendUrl
|
|
|
|
* property be ignored. This will only work in edit mode.
|
2022-06-11 16:23:12 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-07-04 12:31:05 +00:00
|
|
|
showLink(monitor, ignoreSendUrl = false) {
|
|
|
|
// We must check if there are any elements in monitorList to
|
|
|
|
// prevent undefined errors if it hasn't been loaded yet
|
|
|
|
if (this.$parent.editMode && ignoreSendUrl && Object.keys(this.$root.monitorList).length) {
|
|
|
|
return this.$root.monitorList[monitor.element.id].type === "http" || this.$root.monitorList[monitor.element.id].type === "keyword";
|
|
|
|
}
|
|
|
|
return monitor.element.sendUrl && monitor.element.url && monitor.element.url !== "https://" && !this.editMode;
|
2022-06-11 16:23:12 +00:00
|
|
|
},
|
2021-09-13 11:21:39 +00:00
|
|
|
}
|
2021-09-17 06:42:19 +00:00
|
|
|
};
|
2021-09-13 11:21:39 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-09-15 06:34:30 +00:00
|
|
|
@import "../assets/vars";
|
2021-09-13 11:21:39 +00:00
|
|
|
|
2021-09-15 06:34:30 +00:00
|
|
|
.no-monitor-msg {
|
|
|
|
position: absolute;
|
|
|
|
width: 100%;
|
|
|
|
top: 20px;
|
|
|
|
left: 0;
|
|
|
|
}
|
2021-09-13 11:21:39 +00:00
|
|
|
|
2021-09-15 06:34:30 +00:00
|
|
|
.monitor-list {
|
|
|
|
min-height: 46px;
|
|
|
|
}
|
2021-09-13 11:21:39 +00:00
|
|
|
|
2022-06-11 16:23:12 +00:00
|
|
|
.item-name {
|
|
|
|
padding-left: 5px;
|
|
|
|
padding-right: 5px;
|
|
|
|
margin: 0;
|
|
|
|
display: inline-block;
|
|
|
|
}
|
|
|
|
|
2022-07-04 10:33:38 +00:00
|
|
|
.btn-link {
|
|
|
|
color: #bbbbbb;
|
|
|
|
margin-left: 5px;
|
|
|
|
}
|
|
|
|
|
2022-06-11 16:23:12 +00:00
|
|
|
.link-active {
|
2022-07-04 10:33:38 +00:00
|
|
|
color: $primary;
|
2022-06-11 16:23:12 +00:00
|
|
|
}
|
|
|
|
|
2021-09-15 06:34:30 +00:00
|
|
|
.flip-list-move {
|
|
|
|
transition: transform 0.5s;
|
|
|
|
}
|
|
|
|
|
|
|
|
.no-move {
|
|
|
|
transition: transform 0s;
|
|
|
|
}
|
|
|
|
|
|
|
|
.drag {
|
|
|
|
color: #bbb;
|
|
|
|
cursor: grab;
|
|
|
|
}
|
|
|
|
|
|
|
|
.remove {
|
|
|
|
color: $danger;
|
|
|
|
}
|
2021-09-16 14:48:28 +00:00
|
|
|
|
|
|
|
.group-title {
|
|
|
|
span {
|
|
|
|
display: inline-block;
|
|
|
|
min-width: 15px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-23 08:31:45 +00:00
|
|
|
.mobile {
|
|
|
|
.item {
|
2022-04-13 16:52:07 +00:00
|
|
|
padding: 13px 0 10px;
|
2021-09-23 08:31:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-23 14:22:00 +00:00
|
|
|
.bg-maintenance {
|
|
|
|
background-color: $maintenance;
|
|
|
|
}
|
|
|
|
|
2021-09-13 11:21:39 +00:00
|
|
|
</style>
|