Detail.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <div>
  3. <a-row class="mb-2" :gutter="{ lg: 24, xl: 12, xxl: 24 }">
  4. <a-col class="mb-3" :lg="12" :xl="6">
  5. <progress-card :progress="cpu" />
  6. </a-col>
  7. <a-col class="mb-3" :lg="12" :xl="6">
  8. <progress-card :progress="memory" />
  9. </a-col>
  10. <a-col class="mb-3" :lg="12" :xl="6">
  11. <progress-card :progress="pod" />
  12. </a-col>
  13. </a-row>
  14. <detail
  15. :on-manager="onManager"
  16. :data="data"
  17. :base-info="baseInfo"
  18. :extra-info="extraInfo"
  19. resource="k8s_nodes"
  20. :nameProps="{edit: false}" />
  21. </div>
  22. </template>
  23. <script>
  24. import { operatingSystemColumn, annotateColumn, tagColumn, taintColumn } from '@K8S/utils/sidePageColumn'
  25. import ProgressCard from '@/sections/ProgressCard'
  26. import { getCopyWithContentTableColumn } from '@/utils/common/tableColumn'
  27. import { sizestr } from '@/utils/utils'
  28. export default {
  29. name: 'K8SNodeDetail',
  30. components: {
  31. ProgressCard,
  32. },
  33. props: {
  34. data: {
  35. type: Object,
  36. required: true,
  37. },
  38. onManager: {
  39. type: Function,
  40. required: true,
  41. },
  42. },
  43. data () {
  44. return {
  45. cpu: {
  46. title: this.$t('k8s.text_282'),
  47. percent: this.data.allocatedResources.cpuRequests / this.data.allocatedResources.cpuCapacity || 0,
  48. msg: {
  49. current: (this.data.allocatedResources.cpuRequests / 1000),
  50. currentLabel: this.$t('k8s.text_300'),
  51. total: (this.data.allocatedResources.cpuCapacity / 1000),
  52. },
  53. },
  54. memory: {
  55. title: this.$t('k8s.text_101'),
  56. percent: this.data.allocatedResources.memoryRequests / this.data.allocatedResources.memoryCapacity || 0,
  57. msg: {
  58. current: sizestr(this.data.allocatedResources.memoryRequests, 'B', 1024),
  59. currentLabel: this.$t('k8s.text_300'),
  60. total: sizestr(this.data.allocatedResources.memoryCapacity, 'B', 1024),
  61. },
  62. },
  63. pod: {
  64. title: this.$t('k8s.text_9'),
  65. percent: this.data.allocatedResources.allocatedPods / this.data.allocatedResources.podCapacity || 0,
  66. msg: {
  67. current: this.data.allocatedResources.allocatedPods,
  68. currentLabel: this.$t('k8s.text_300'),
  69. total: this.data.allocatedResources.podCapacity,
  70. },
  71. },
  72. baseInfo: [
  73. getCopyWithContentTableColumn({ field: 'cluster', title: this.$t('k8s.text_19') }),
  74. {
  75. field: 'status',
  76. title: this.$t('k8s.text_35'),
  77. minWidth: 70,
  78. slots: {
  79. default: ({ row }, h) => {
  80. return [<span style={{ color: row.ready ? '#67C23A' : '#F56C6C' }}>{ row.ready ? 'Ready' : 'UnReady' }</span>]
  81. },
  82. },
  83. },
  84. {
  85. field: 'unschedulable',
  86. title: this.$t('k8s.text_296'),
  87. formatter: ({ cellValue }) => {
  88. return !cellValue ? this.$t('k8s.text_296') : this.$t('k8s.text_297')
  89. },
  90. },
  91. ],
  92. statusColumns: [
  93. {
  94. field: 'type',
  95. title: 'Type',
  96. minWidth: 100,
  97. showOverflow: 'ellipsis',
  98. },
  99. {
  100. field: 'status',
  101. title: 'Status',
  102. width: 75,
  103. },
  104. {
  105. field: 'lastTransitionTime',
  106. title: 'LastTransitionTime',
  107. minWidth: 100,
  108. showOverflow: 'ellipsis',
  109. formatter: ({ cellValue }) => {
  110. return this.$moment(cellValue).format(this.$t('k8s.text_37'))
  111. },
  112. },
  113. {
  114. field: 'reason',
  115. title: 'Reason',
  116. minWidth: 70,
  117. showOverflow: 'ellipsis',
  118. },
  119. {
  120. field: 'message',
  121. title: 'Message',
  122. minWidth: 70,
  123. showOverflow: 'ellipsis',
  124. },
  125. ],
  126. extraInfo: [
  127. operatingSystemColumn(),
  128. annotateColumn(),
  129. tagColumn(),
  130. taintColumn(),
  131. ],
  132. }
  133. },
  134. }
  135. </script>