ProxyView.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <div>
  3. <el-table
  4. :data="proxies"
  5. :default-sort="{ prop: 'name', order: 'ascending' }"
  6. style="width: 100%"
  7. >
  8. <el-table-column type="expand">
  9. <template #default="props">
  10. <el-popover
  11. placement="right"
  12. width="600"
  13. style="margin-left: 0px"
  14. trigger="click"
  15. >
  16. <template #default>
  17. <Traffic :proxy_name="props.row.name" />
  18. </template>
  19. <template #reference>
  20. <el-button
  21. type="primary"
  22. size="large"
  23. :name="props.row.name"
  24. style="margin-bottom: 10px"
  25. >Traffic Statistics
  26. </el-button>
  27. </template>
  28. </el-popover>
  29. <ProxyViewExpand :row="props.row" :proxyType="proxyType" />
  30. </template>
  31. </el-table-column>
  32. <el-table-column label="Name" prop="name" sortable> </el-table-column>
  33. <el-table-column label="Port" prop="port" sortable> </el-table-column>
  34. <el-table-column label="Connections" prop="conns" sortable>
  35. </el-table-column>
  36. <el-table-column
  37. label="Traffic In"
  38. prop="traffic_in"
  39. :formatter="formatTrafficIn"
  40. sortable
  41. >
  42. </el-table-column>
  43. <el-table-column
  44. label="Traffic Out"
  45. prop="traffic_out"
  46. :formatter="formatTrafficOut"
  47. sortable
  48. >
  49. </el-table-column>
  50. <el-table-column label="ClientVersion" prop="client_version" sortable>
  51. </el-table-column>
  52. <el-table-column label="Status" prop="status" sortable>
  53. <template #default="scope">
  54. <el-tag v-if="scope.row.status === 'online'" type="success">{{
  55. scope.row.status
  56. }}</el-tag>
  57. <el-tag v-else type="danger">{{ scope.row.status }}</el-tag>
  58. </template>
  59. </el-table-column>
  60. </el-table>
  61. </div>
  62. </template>
  63. <script setup lang="ts">
  64. import * as Humanize from 'humanize-plus'
  65. import type { TableColumnCtx } from 'element-plus'
  66. import type { BaseProxy } from '../utils/proxy.js'
  67. import ProxyViewExpand from './ProxyViewExpand.vue'
  68. defineProps<{
  69. proxies: BaseProxy[]
  70. proxyType: string
  71. }>()
  72. const formatTrafficIn = (row: BaseProxy, _: TableColumnCtx<BaseProxy>) => {
  73. return Humanize.fileSize(row.traffic_in)
  74. }
  75. const formatTrafficOut = (row: BaseProxy, _: TableColumnCtx<BaseProxy>) => {
  76. return Humanize.fileSize(row.traffic_out)
  77. }
  78. </script>