columns.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import { sizestr } from '@/utils/utils'
  2. import { getTimeTableColumn, getNameDescriptionTableColumn } from '@/utils/common/tableColumn'
  3. import i18n from '@/locales'
  4. export default {
  5. created () {
  6. this.columns = [
  7. getNameDescriptionTableColumn({
  8. onManager: this.onManager,
  9. hideField: true,
  10. edit: false,
  11. showDesc: false,
  12. slotCallback: row => {
  13. const ret = [<side-page-trigger onTrigger={ () => this.handleOpenSidepage(row) }>{ row.name }</side-page-trigger>]
  14. if (row.taints) {
  15. row.taints.forEach(taint => {
  16. const effect = <div style="color: #999">{ taint.key }:{ taint.effect }</div>
  17. ret.push(effect)
  18. })
  19. }
  20. return ret
  21. },
  22. }),
  23. {
  24. field: 'addresses',
  25. title: 'IP',
  26. minWidth: 100,
  27. slots: {
  28. default: ({ row }, h) => {
  29. if (row.addresses) {
  30. const ret = []
  31. row.addresses.filter(val => val.type === 'InternalIP').map(item => {
  32. const ip = <div>{item.address}</div>
  33. ret.push(ip)
  34. })
  35. return ret
  36. }
  37. return '-'
  38. },
  39. },
  40. },
  41. {
  42. field: 'status',
  43. title: i18n.t('k8s.text_35'),
  44. minWidth: 70,
  45. slots: {
  46. default: ({ row }, h) => {
  47. return [<span style={{ color: row.ready ? '#67C23A' : '#F56C6C' }}>{ row.ready ? 'Ready' : 'UnReady' }</span>]
  48. },
  49. },
  50. },
  51. {
  52. field: 'cpuRequests/cpuCapacity',
  53. title: i18n.t('k8s.text_282'),
  54. minWidth: 70,
  55. formatter: ({ row }) => {
  56. if (row.allocatedResources) {
  57. return (row.allocatedResources.cpuRequests / 1000) + ' / ' + (row.allocatedResources.cpuCapacity / 1000)
  58. }
  59. return '-'
  60. },
  61. },
  62. {
  63. field: 'memoryRequests/memoryCapacity',
  64. title: i18n.t('k8s.text_101'),
  65. minWidth: 70,
  66. formatter: ({ row }) => {
  67. if (row.allocatedResources) {
  68. return sizestr(row.allocatedResources.memoryRequests, 'B', 1024) + ' / ' + sizestr(row.allocatedResources.memoryCapacity, 'B', 1024)
  69. }
  70. return '-'
  71. },
  72. },
  73. {
  74. field: 'allocatedPods/podCapacity',
  75. title: i18n.t('k8s.text_9'),
  76. minWidth: 70,
  77. formatter: ({ row }) => {
  78. if (row.allocatedResources) {
  79. return row.allocatedResources.allocatedPods + ' / ' + row.allocatedResources.podCapacity
  80. }
  81. return '-'
  82. },
  83. },
  84. {
  85. field: 'unschedulable',
  86. title: i18n.t('k8s.text_296'),
  87. minWidth: 70,
  88. formatter: ({ cellValue }) => {
  89. return !cellValue ? i18n.t('k8s.text_296') : i18n.t('k8s.text_297')
  90. },
  91. },
  92. getTimeTableColumn({ field: 'creationTimestamp', fromNow: true, sortable: true }),
  93. ]
  94. },
  95. }