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

37 lines
936 B
Vue
Raw Normal View History

2017-03-26 18:15:31 +00:00
<template>
2021-01-25 08:04:33 +00:00
<div :id="proxy_name" style="width: 600px;height:400px;"></div>
2017-03-26 18:15:31 +00:00
</template>
<script>
2021-01-25 08:04:33 +00:00
import {DrawProxyTrafficChart} from '../utils/chart.js'
2017-03-26 18:15:31 +00:00
export default {
2021-01-25 08:04:33 +00:00
props: ['proxy_name'],
created() {
this.fetchData()
},
//watch: {
//'$route': 'fetchData'
//},
methods: {
fetchData() {
let url = '/api/traffic/' + this.proxy_name
fetch(url, {credentials: 'include'})
.then(res => {
return res.json()
}).then(json => {
DrawProxyTrafficChart(this.proxy_name, json.traffic_in, json.traffic_out)
}).catch( err => {
this.$message({
showClose: true,
message: 'Get server info from frps failed!' + err,
type: 'warning'
})
})
}
2017-03-26 18:15:31 +00:00
}
}
</script>
2021-01-25 08:04:33 +00:00
<style>
</style>