frp/web/frps/src/components/ProxiesUdp.vue

127 lines
3.5 KiB
Vue
Raw Normal View History

2017-03-27 02:15:31 +08:00
<template>
<div>
2021-01-25 16:04:33 +08:00
<el-table :data="proxies" :default-sort="{prop: 'name', order: 'ascending'}" style="width: 100%">
2017-03-27 02:15:31 +08:00
<el-table-column type="expand">
2018-05-16 02:51:02 +08:00
<template slot-scope="props">
2021-01-25 16:04:33 +08:00
<el-popover
ref="popover4"
placement="right"
width="600"
style="margin-left:0px"
trigger="click">
<my-traffic-chart :proxy_name="props.row.name"></my-traffic-chart>
2017-03-27 02:15:31 +08:00
</el-popover>
2021-01-25 16:04:33 +08:00
<el-button v-popover:popover4 type="primary" size="small" icon="view" style="margin-bottom:10px">Traffic Statistics</el-button>
2017-03-27 02:15:31 +08:00
<el-form label-position="left" inline class="demo-table-expand">
<el-form-item label="Name">
<span>{{ props.row.name }}</span>
</el-form-item>
<el-form-item label="Type">
<span>{{ props.row.type }}</span>
</el-form-item>
<el-form-item label="Addr">
<span>{{ props.row.addr }}</span>
</el-form-item>
<el-form-item label="Encryption">
<span>{{ props.row.encryption }}</span>
</el-form-item>
<el-form-item label="Compression">
<span>{{ props.row.compression }}</span>
</el-form-item>
<el-form-item label="Last Start">
<span>{{ props.row.last_start_time }}</span>
</el-form-item>
<el-form-item label="Last Close">
<span>{{ props.row.last_close_time }}</span>
</el-form-item>
2021-01-25 16:04:33 +08:00
</el-form>
</template>
</el-table-column>
<el-table-column
label="Name"
prop="name"
sortable>
</el-table-column>
<el-table-column
label="Port"
prop="port"
sortable>
</el-table-column>
<el-table-column
label="Connections"
prop="conns"
sortable>
</el-table-column>
<el-table-column
label="Traffic In"
prop="traffic_in"
:formatter="formatTrafficIn"
sortable>
</el-table-column>
<el-table-column
label="Traffic Out"
prop="traffic_out"
:formatter="formatTrafficOut"
sortable>
</el-table-column>
<el-table-column
label="status"
prop="status"
sortable>
<template slot-scope="scope">
<el-tag type="success" v-if="scope.row.status === 'online'">{{ scope.row.status }}</el-tag>
<el-tag type="danger" v-else>{{ scope.row.status }}</el-tag>
</template>
</el-table-column>
</el-table>
</div>
2017-03-27 02:15:31 +08:00
</template>
<script>
2021-01-25 16:04:33 +08:00
import Humanize from 'humanize-plus';
import Traffic from './Traffic.vue'
import {
UdpProxy
} from '../utils/proxy.js'
export default {
data() {
return {
2021-06-09 11:53:39 +08:00
proxies: new Array(),
2021-01-25 16:04:33 +08:00
}
2017-03-27 02:15:31 +08:00
},
2021-01-25 16:04:33 +08:00
created() {
this.fetchData()
2017-03-27 02:15:31 +08:00
},
2021-01-25 16:04:33 +08:00
watch: {
'$route': 'fetchData'
},
methods: {
formatTrafficIn(row, column) {
return Humanize.fileSize(row.traffic_in)
},
formatTrafficOut(row, column) {
return Humanize.fileSize(row.traffic_out)
},
fetchData() {
fetch('../api/proxy/udp', {credentials: 'include'})
2021-01-25 16:04:33 +08:00
.then(res => {
return res.json()
}).then(json => {
this.proxies = new Array()
for (let proxyStats of json.proxies) {
this.proxies.push(new UdpProxy(proxyStats))
}
})
2017-03-27 02:15:31 +08:00
}
2021-01-25 16:04:33 +08:00
},
components: {
'my-traffic-chart': Traffic
2017-03-27 02:15:31 +08:00
}
}
</script>
2021-01-25 16:04:33 +08:00
<style>
</style>