Overview.vue 5.1 KB

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