Files
WGDashboard/src/static/app/src/components/configurationComponents/peer.vue

144 lines
3.8 KiB
Vue
Raw Normal View History

<script>
2024-03-11 00:11:07 -04:00
import { ref } from 'vue'
import { onClickOutside } from '@vueuse/core'
2024-05-20 22:28:52 +08:00
import "animate.css"
import PeerSettingsDropdown from "@/components/configurationComponents/peerSettingsDropdown.vue";
2024-09-13 16:32:56 +08:00
import LocaleText from "@/components/text/localeText.vue";
export default {
name: "peer",
2024-09-13 16:32:56 +08:00
components: {LocaleText, PeerSettingsDropdown},
props: {
Peer: Object
2024-03-11 00:11:07 -04:00
},
data(){
return {
}
},
setup(){
const target = ref(null);
const subMenuOpened = ref(false)
onClickOutside(target, event => {
subMenuOpened.value = false;
});
return {target, subMenuOpened}
},
computed: {
getLatestHandshake(){
if (this.Peer.latest_handshake.includes(",")){
return this.Peer.latest_handshake.split(",")[0]
}
return this.Peer.latest_handshake;
}
}
}
</script>
<template>
2024-12-18 18:15:02 +08:00
<div class="card shadow-sm rounded-3 peerCard"
:class="{'border-warning': Peer.restricted}">
<div>
<div v-if="!Peer.restricted" class="card-header bg-transparent d-flex align-items-center gap-2 border-0">
<div class="dot ms-0" :class="{active: Peer.status === 'running'}"></div>
<div style="font-size: 0.8rem" class="ms-auto d-flex gap-2">
<span class="text-primary">
<i class="bi bi-arrow-down"></i><strong>
{{(Peer.cumu_receive + Peer.total_receive).toFixed(4)}}</strong> GB
</span>
2024-11-29 23:07:58 +08:00
<span class="text-success">
<i class="bi bi-arrow-up"></i><strong>
{{(Peer.cumu_sent + Peer.total_sent).toFixed(4)}}</strong> GB
</span>
2024-11-29 23:07:58 +08:00
<span class="text-secondary" v-if="Peer.latest_handshake !== 'No Handshake'">
<i class="bi bi-arrows-angle-contract"></i>
{{getLatestHandshake}} ago
</span>
</div>
</div>
<div v-else class="border-0 card-header bg-transparent text-warning fw-bold"
style="font-size: 0.8rem">
<i class="bi-lock-fill me-2"></i>
2024-09-13 16:32:56 +08:00
<LocaleText t="Access Restricted"></LocaleText>
</div>
</div>
<div class="card-body pt-1" style="font-size: 0.9rem">
2024-07-29 18:40:07 -04:00
<h6>
{{Peer.name ? Peer.name : 'Untitled Peer'}}
2024-07-29 18:40:07 -04:00
</h6>
2024-10-05 15:03:27 +08:00
<div class="mb-1">
2024-09-13 16:32:56 +08:00
<small class="text-muted">
2024-11-03 17:36:03 +08:00
<LocaleText t="Public Key"></LocaleText>
2024-10-05 15:03:27 +08:00
</small>
<small class="d-block">
<samp>{{Peer.id}}</samp>
</small>
</div>
<div>
<small class="text-muted">
<LocaleText t="Allowed IPs"></LocaleText>
</small>
<small class="d-block">
<samp>{{Peer.allowed_ip}}</samp>
2024-09-13 16:32:56 +08:00
</small>
</div>
2024-12-03 02:34:45 +08:00
<div v-if="Peer.advanced_security">
<small class="text-muted">
<LocaleText t="Advanced Security"></LocaleText>
</small>
<small class="d-block">
<samp>{{Peer.advanced_security}}</samp>
</small>
</div>
2024-03-11 00:11:07 -04:00
<div class="d-flex align-items-end">
2024-10-05 15:03:27 +08:00
<div class="ms-auto px-2 rounded-3 subMenuBtn"
:class="{active: this.subMenuOpened}"
>
<a role="button" class="text-body"
@click="this.subMenuOpened = true">
2024-03-11 00:11:07 -04:00
<h5 class="mb-0"><i class="bi bi-three-dots"></i></h5>
</a>
<Transition name="slide-fade">
<PeerSettingsDropdown
2025-01-03 13:45:05 +08:00
@qrcode="this.$emit('qrcode')"
@configurationFile="this.$emit('configurationFile')"
2024-03-24 18:24:01 -04:00
@setting="this.$emit('setting')"
2024-06-18 03:16:42 +08:00
@jobs="this.$emit('jobs')"
2024-05-20 22:28:52 +08:00
@refresh="this.$emit('refresh')"
2024-08-06 10:17:14 -04:00
@share="this.$emit('share')"
:Peer="Peer"
v-if="this.subMenuOpened"
ref="target"
></PeerSettingsDropdown>
2024-03-11 00:11:07 -04:00
</Transition>
</div>
</div>
</div>
</div>
</template>
<style scoped>
.slide-fade-leave-active, .slide-fade-enter-active{
transition: all 0.2s cubic-bezier(0.82, 0.58, 0.17, 1.3);
2024-03-11 00:11:07 -04:00
}
.slide-fade-enter-from,
.slide-fade-leave-to {
transform: translateY(20px);
opacity: 0;
2024-07-29 18:40:07 -04:00
filter: blur(3px);
2024-03-11 00:11:07 -04:00
}
.subMenuBtn.active{
background-color: #ffffff20;
}
.peerCard{
2024-07-29 18:40:07 -04:00
transition: box-shadow 0.1s cubic-bezier(0.82, 0.58, 0.17, 0.9);
}
.peerCard:hover{
box-shadow: var(--bs-box-shadow) !important;
}
</style>