Detail.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <detail
  3. :showDesc="false"
  4. :showName="false"
  5. :hiddenKeys="['project_domain', 'tenant', 'created_at', 'updated_at']"
  6. :onManager="onManager"
  7. :data="data"
  8. :base-info="baseInfo" />
  9. </template>
  10. <script>
  11. import { k8sStatusColumn, k8sLabelColumn } from '@K8S/utils/tableColumns'
  12. import expectStatus from '@/constants/expectStatus'
  13. import WindowsMixin from '@/mixins/windows'
  14. export default {
  15. name: 'K8sPersistentvolumeclaimDetail',
  16. mixins: [WindowsMixin],
  17. props: {
  18. data: {
  19. type: Object,
  20. required: true,
  21. },
  22. onManager: {
  23. type: Function,
  24. required: true,
  25. },
  26. },
  27. data () {
  28. return {
  29. baseInfo: [
  30. {
  31. field: 'name',
  32. title: this.$t('k8s.text_41'),
  33. slots: {
  34. default: ({ row }) => {
  35. return [
  36. <div class='text-truncate'>
  37. <list-body-cell-wrap copy row={ this.data } onManager={ this.onManager } field='name' title={ row.name } />
  38. </div>,
  39. ]
  40. },
  41. },
  42. },
  43. {
  44. field: 'mountedBy',
  45. title: this.$t('k8s.text_314'),
  46. slots: {
  47. default: ({ row }) => {
  48. const handleOpenSidepage = (name) => {
  49. this.sidePageTriggerHandle(this, 'K8SPodSidePage', {
  50. id: name,
  51. resource: 'pods',
  52. getParams: () => {
  53. const params = {
  54. scope: this.$store.getters.scope,
  55. details: true,
  56. cluster: row.cluster,
  57. namespace: row.namespace,
  58. }
  59. return params
  60. },
  61. apiVersion: 'v1',
  62. steadyStatus: {
  63. status: Object.values(expectStatus.k8s_resource).flat(),
  64. },
  65. }, {
  66. list: this.list,
  67. })
  68. }
  69. if (!row.mountedBy || !row.mountedBy.length) return '-'
  70. return row.mountedBy.map(val => {
  71. return (<side-page-trigger onTrigger={() => handleOpenSidepage(val)}>{ val }</side-page-trigger>)
  72. })
  73. },
  74. },
  75. },
  76. k8sStatusColumn(),
  77. {
  78. field: 'cluster',
  79. title: this.$t('k8s.text_19'),
  80. },
  81. {
  82. field: 'namespace',
  83. title: this.$t('k8s.text_23'),
  84. },
  85. {
  86. field: 'accessModes',
  87. title: this.$t('k8s.text_313'),
  88. formatter: ({ row }) => row.accessModes && (row.accessModes || []).join(', '),
  89. },
  90. {
  91. field: 'volume',
  92. title: this.$t('k8s.text_311'),
  93. },
  94. {
  95. field: 'storageClass',
  96. title: this.$t('k8s.text_22'),
  97. },
  98. {
  99. field: 'capacity.storage',
  100. title: this.$t('k8s.text_312'),
  101. width: 70,
  102. formatter: ({ row }) => {
  103. return row.capacity ? (row.capacity.storage || '0Gi') : '-'
  104. },
  105. },
  106. {
  107. field: 'unused',
  108. title: this.$t('k8s.text_301'),
  109. slots: {
  110. default: ({ row }, h) => {
  111. let text = this.$t('k8s.text_303')
  112. let className = 'success-color'
  113. if (row.mountedBy && row.mountedBy.length > 0) {
  114. text = this.$t('k8s.text_302')
  115. className = 'error-color'
  116. }
  117. return [<div class={className}>{text}</div>]
  118. },
  119. },
  120. },
  121. {
  122. field: 'creationTimestamp',
  123. title: this.$t('k8s.text_74'),
  124. formatter: ({ row }) => {
  125. return (row.creationTimestamp && this.$moment(row.creationTimestamp).format()) || '-'
  126. },
  127. },
  128. k8sLabelColumn({ field: 'annotations', title: this.$t('k8s.text_142') }),
  129. ],
  130. }
  131. },
  132. }
  133. </script>