2021-09-13 07:21:39 -04:00
|
|
|
<template>
|
|
|
|
<!-- Group List -->
|
|
|
|
<Draggable
|
|
|
|
v-model="$root.publicGroupList"
|
|
|
|
:disabled="!editMode"
|
|
|
|
item-key="id"
|
|
|
|
:animation="100"
|
|
|
|
>
|
2021-09-15 02:34:30 -04:00
|
|
|
<template #item="group">
|
2021-09-13 07:21:39 -04:00
|
|
|
<div>
|
2021-09-14 11:27:11 -04:00
|
|
|
<!-- Group Title -->
|
|
|
|
<h2 class="mt-5">
|
2021-09-15 02:34:30 -04: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 11:27:11 -04:00
|
|
|
</h2>
|
2021-09-13 07:21:39 -04:00
|
|
|
|
|
|
|
<div class="shadow-box monitor-list mt-4 position-relative">
|
2021-09-15 02:34:30 -04:00
|
|
|
<div v-if="group.element.monitorList.length === 0" class="text-center no-monitor-msg">
|
2021-09-13 07:21:39 -04:00
|
|
|
{{ $t("No Monitors") }}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Monitor List -->
|
2021-09-15 02:34:30 -04:00
|
|
|
<!-- animation is not working, no idea why -->
|
2021-09-13 07:21:39 -04:00
|
|
|
<Draggable
|
2021-09-15 02:34:30 -04:00
|
|
|
v-model="group.element.monitorList"
|
2021-09-13 07:21:39 -04:00
|
|
|
class="monitor-list"
|
|
|
|
group="same-group"
|
|
|
|
:disabled="!editMode"
|
|
|
|
:animation="100"
|
2021-09-14 02:12:27 -04:00
|
|
|
item-key="id"
|
2021-09-13 07:21:39 -04:00
|
|
|
>
|
2021-09-15 02:34:30 -04:00
|
|
|
<template #item="monitor">
|
2021-09-13 07:21:39 -04:00
|
|
|
<div class="item">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-6 col-md-8 small-padding">
|
|
|
|
<div class="info">
|
2021-09-15 02:34:30 -04:00
|
|
|
<font-awesome-icon v-if="editMode && showMonitorDrag(group.index)" icon="arrows-alt-v" class="action drag me-3" />
|
|
|
|
<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" />
|
|
|
|
{{ monitor.element.name }}
|
2021-09-13 07:21:39 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div :key="$root.userHeartbeatBar" class="col-6 col-md-4">
|
2021-09-15 02:34:30 -04:00
|
|
|
<HeartbeatBar size="small" :monitor-id="monitor.element.id" />
|
2021-09-13 07:21:39 -04: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";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "GroupList",
|
|
|
|
components: {
|
|
|
|
Draggable,
|
|
|
|
HeartbeatBar,
|
|
|
|
Uptime,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
editMode: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
2021-09-15 02:34:30 -04:00
|
|
|
computed: {
|
|
|
|
showGroupDrag() {
|
|
|
|
return (this.$root.publicGroupList.length >= 2);
|
|
|
|
}
|
|
|
|
},
|
2021-09-13 07:21:39 -04:00
|
|
|
created() {
|
|
|
|
|
2021-09-15 02:34:30 -04:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
removeGroup(index) {
|
|
|
|
this.$root.publicGroupList.splice(index, 1);
|
|
|
|
},
|
|
|
|
|
|
|
|
removeMonitor(groupIndex, index) {
|
|
|
|
this.$root.publicGroupList[groupIndex].monitorList.splice(index, 1);
|
|
|
|
},
|
|
|
|
|
|
|
|
showMonitorDrag(groupIndex) {
|
|
|
|
return this.$root.publicGroupList[groupIndex].monitorList.length >= 2
|
|
|
|
}
|
2021-09-13 07:21:39 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-09-15 02:34:30 -04:00
|
|
|
@import "../assets/vars";
|
2021-09-13 07:21:39 -04:00
|
|
|
|
2021-09-15 02:34:30 -04:00
|
|
|
.no-monitor-msg {
|
|
|
|
position: absolute;
|
|
|
|
width: 100%;
|
|
|
|
top: 20px;
|
|
|
|
left: 0;
|
|
|
|
}
|
2021-09-13 07:21:39 -04:00
|
|
|
|
2021-09-15 02:34:30 -04:00
|
|
|
.monitor-list {
|
|
|
|
min-height: 46px;
|
|
|
|
}
|
2021-09-13 07:21:39 -04:00
|
|
|
|
2021-09-15 02:34:30 -04:00
|
|
|
.flip-list-move {
|
|
|
|
transition: transform 0.5s;
|
|
|
|
}
|
|
|
|
|
|
|
|
.no-move {
|
|
|
|
transition: transform 0s;
|
|
|
|
}
|
|
|
|
|
|
|
|
.drag {
|
|
|
|
color: #bbb;
|
|
|
|
cursor: grab;
|
|
|
|
}
|
|
|
|
|
|
|
|
.remove {
|
|
|
|
color: $danger;
|
|
|
|
}
|
2021-09-13 07:21:39 -04:00
|
|
|
</style>
|