columns.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. import i18n from '@/locales'
  2. import { sizestr } from '@/utils/utils'
  3. export const getPackageNameTableColumn = () => {
  4. return {
  5. field: 'package',
  6. title: i18n.t('aice.mounted_apps.package'),
  7. width: 180,
  8. slots: {
  9. default: ({ row }, h) => {
  10. return [
  11. <list-body-cell-wrap copy hideField={true} field='package' row={row} message={row.package}>
  12. {row.package}
  13. </list-body-cell-wrap>,
  14. ]
  15. },
  16. },
  17. }
  18. }
  19. export const getAppIdTableColumn = () => {
  20. return {
  21. field: 'app_id',
  22. title: i18n.t('aice.mounted_apps.app_id'),
  23. width: 180,
  24. slots: {
  25. default: ({ row }, h) => {
  26. return [
  27. <list-body-cell-wrap copy hideField={true} field='app_id' row={row} message={row.app_id}>
  28. {row.app_id}
  29. </list-body-cell-wrap>,
  30. ]
  31. },
  32. },
  33. }
  34. }
  35. export const getPackageVersionTableColumn = () => {
  36. return {
  37. field: 'version',
  38. title: i18n.t('aice.mounted_apps.version'),
  39. width: 120,
  40. slots: {
  41. default: ({ row }, h) => {
  42. return [
  43. <list-body-cell-wrap copy hideField={true} field='version' row={row} message={row.version}>
  44. {row.version}
  45. </list-body-cell-wrap>,
  46. ]
  47. },
  48. },
  49. }
  50. }
  51. export const getAppImageTableColumn = ({ vm = {} } = {}) => {
  52. return {
  53. field: 'image_id',
  54. title: i18n.t('aice.template'),
  55. width: 120,
  56. slots: {
  57. default: ({ row }, h) => {
  58. return [
  59. <list-body-cell-wrap copy hideField={true} field='image_id' row={row} message={row.image}>
  60. <side-page-trigger permission='images_get' name='SystemImageSidePage' list={vm.list} id={row.image_id} vm={vm} tab="system-image-detail">{row.image}</side-page-trigger>
  61. </list-body-cell-wrap>,
  62. ]
  63. },
  64. },
  65. }
  66. }
  67. export const getAppSizeTableColumn = () => {
  68. return {
  69. field: 'size',
  70. title: i18n.t('table.title.image_size'),
  71. minWidth: 100,
  72. formatter: ({ cellValue, row }) => {
  73. return sizestr(cellValue, 'B', 1024)
  74. },
  75. }
  76. }
  77. export const getAppCacheStatusColumn = () => {
  78. return {
  79. field: 'cached_count',
  80. title: i18n.t('aice.mounted_apps.auto_cache.status'),
  81. minWidth: 100,
  82. slots: {
  83. default: ({ row }, h) => {
  84. if (!row.hasOwnProperty('cached_count')) {
  85. return '-'
  86. }
  87. const title = `${row.cached_count}/${row.cache_count}`
  88. const colorHigh = '#52C41A'
  89. const colorLow = '#FFC145'
  90. const colorMedium = '#FFC145'
  91. return [<UsedPercent colorHigh={colorHigh} colorLow={colorLow} colorMedium={colorMedium} title={title} used={row.cached_count} total={row.cache_count} usedLabel={i18n.t('aice.mounted_apps.auto_cache.on')} />]
  92. },
  93. },
  94. formatter: ({ row }) => {
  95. const title = `${i18n.t('aice.mounted_apps.auto_cache.on')}: ${row.cached_count}/${row.cache_count}`
  96. return title
  97. },
  98. }
  99. }
  100. export const getIconTableColumn = () => {
  101. return {
  102. field: 'icon_base64',
  103. title: i18n.t('aice.mounted_apps.icon'),
  104. width: 80,
  105. slots: {
  106. default: ({ row }, h) => {
  107. if (!row.icon_base64) {
  108. return '-'
  109. }
  110. const imgData = `data:image/webp;base64,${row.icon_base64}`
  111. return [
  112. <img src={imgData} width="64" />,
  113. ]
  114. },
  115. },
  116. }
  117. }
  118. export const getModelIdTableColumn = () => {
  119. return {
  120. field: 'model_id',
  121. title: 'Model ID',
  122. formatter: ({ row }) => {
  123. return row.model_id || '-'
  124. },
  125. }
  126. }
  127. export const getModelNameTableColumn = () => {
  128. return {
  129. field: 'model_name',
  130. title: 'Model Name',
  131. formatter: ({ row }) => {
  132. return row.model_name || '-'
  133. },
  134. }
  135. }
  136. export const getLlmTypeTableColumn = () => {
  137. return {
  138. field: 'llm_type',
  139. title: i18n.t('aice.llm_type.llm'),
  140. formatter: ({ row }) => {
  141. return row.llm_type || '-'
  142. },
  143. }
  144. }