Overview.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <div>
  3. <el-row>
  4. <el-col :md="12">
  5. <div class="source">
  6. <el-form label-position="left" class="server_info">
  7. <el-form-item label="Version">
  8. <span>{{ version }}</span>
  9. </el-form-item>
  10. <el-form-item label="BindPort">
  11. <span>{{ bind_port }}</span>
  12. </el-form-item>
  13. <el-form-item label="BindUdpPort">
  14. <span>{{ bind_udp_port }}</span>
  15. </el-form-item>
  16. <el-form-item label="Http Port">
  17. <span>{{ vhost_http_port }}</span>
  18. </el-form-item>
  19. <el-form-item label="Https Port">
  20. <span>{{ vhost_https_port }}</span>
  21. </el-form-item>
  22. <el-form-item label="Subdomain Host">
  23. <span>{{ subdomain_host }}</span>
  24. </el-form-item>
  25. <el-form-item label="Max PoolCount">
  26. <span>{{ max_pool_count }}</span>
  27. </el-form-item>
  28. <el-form-item label="Max Ports Per Client">
  29. <span>{{ max_ports_per_client }}</span>
  30. </el-form-item>
  31. <el-form-item label="HeartBeat Timeout">
  32. <span>{{ heart_beat_timeout }}</span>
  33. </el-form-item>
  34. <el-form-item label="Client Counts">
  35. <span>{{ client_counts }}</span>
  36. </el-form-item>
  37. <el-form-item label="Current Connections">
  38. <span>{{ cur_conns }}</span>
  39. </el-form-item>
  40. <el-form-item label="Proxy Counts">
  41. <span>{{ proxy_counts }}</span>
  42. </el-form-item>
  43. </el-form>
  44. </div>
  45. </el-col>
  46. <el-col :md="12">
  47. <div id="traffic" style="width: 400px;height:250px;margin-bottom: 30px;"></div>
  48. <div id="proxies" style="width: 400px;height:250px;"></div>
  49. </el-col>
  50. </el-row>
  51. </div>
  52. </template>
  53. <script>
  54. import {DrawTrafficChart, DrawProxyChart} from '../utils/chart.js'
  55. export default {
  56. data() {
  57. return {
  58. version: '',
  59. bind_port: '',
  60. bind_udp_port: '',
  61. vhost_http_port: '',
  62. vhost_https_port: '',
  63. subdomain_host: '',
  64. max_pool_count: '',
  65. max_ports_per_client: '',
  66. heart_beat_timeout: '',
  67. client_counts: '',
  68. cur_conns: '',
  69. proxy_counts: ''
  70. }
  71. },
  72. created() {
  73. this.fetchData()
  74. },
  75. watch: {
  76. '$route': 'fetchData'
  77. },
  78. methods: {
  79. fetchData() {
  80. fetch('../api/serverinfo', {credentials: 'include'})
  81. .then(res => {
  82. return res.json()
  83. }).then(json => {
  84. this.version = json.version
  85. this.bind_port = json.bind_port
  86. this.bind_udp_port = json.bind_udp_port
  87. if (this.bind_udp_port == 0) {
  88. this.bind_udp_port = "disable"
  89. }
  90. this.vhost_http_port = json.vhost_http_port
  91. if (this.vhost_http_port == 0) {
  92. this.vhost_http_port = "disable"
  93. }
  94. this.vhost_https_port = json.vhost_https_port
  95. if (this.vhost_https_port == 0) {
  96. this.vhost_https_port = "disable"
  97. }
  98. this.subdomain_host = json.subdomain_host
  99. this.max_pool_count = json.max_pool_count
  100. this.max_ports_per_client = json.max_ports_per_client
  101. if (this.max_ports_per_client == 0) {
  102. this.max_ports_per_client = "no limit"
  103. }
  104. this.heart_beat_timeout = json.heart_beat_timeout
  105. this.client_counts = json.client_counts
  106. this.cur_conns = json.cur_conns
  107. this.proxy_counts = 0
  108. if (json.proxy_type_count != null) {
  109. if (json.proxy_type_count.tcp != null) {
  110. this.proxy_counts += json.proxy_type_count.tcp
  111. }
  112. if (json.proxy_type_count.udp != null) {
  113. this.proxy_counts += json.proxy_type_count.udp
  114. }
  115. if (json.proxy_type_count.http != null) {
  116. this.proxy_counts += json.proxy_type_count.http
  117. }
  118. if (json.proxy_type_count.https != null) {
  119. this.proxy_counts += json.proxy_type_count.https
  120. }
  121. if (json.proxy_type_count.stcp != null) {
  122. this.proxy_counts += json.proxy_type_count.stcp
  123. }
  124. if (json.proxy_type_count.sudp != null) {
  125. this.proxy_counts += json.proxy_type_count.sudp
  126. }
  127. if (json.proxy_type_count.xtcp != null) {
  128. this.proxy_counts += json.proxy_type_count.xtcp
  129. }
  130. }
  131. DrawTrafficChart('traffic', json.total_traffic_in, json.total_traffic_out)
  132. DrawProxyChart('proxies', json)
  133. }).catch( err => {
  134. this.$message({
  135. showClose: true,
  136. message: 'Get server info from frps failed!',
  137. type: 'warning'
  138. })
  139. })
  140. }
  141. }
  142. }
  143. </script>
  144. <style>
  145. .source {
  146. border: 1px solid #eaeefb;
  147. border-radius: 4px;
  148. transition: .2s;
  149. padding: 24px;
  150. }
  151. .server_info {
  152. margin-left: 40px;
  153. font-size: 0px;
  154. }
  155. .server_info label {
  156. width: 150px;
  157. color: #99a9bf;
  158. }
  159. .server_info .el-form-item {
  160. margin-right: 0;
  161. margin-bottom: 0;
  162. width: 100%;
  163. }
  164. </style>