1
0

Overview.vue 6.4 KB

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