columns.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. import i18n from '@/locales'
  2. import { sizestr } from '@/utils/utils'
  3. import { getCopyWithContentTableColumn } from '@/utils/common/tableColumn'
  4. export const getLlmTypeTableColumn = (isApplyType = false) => {
  5. return {
  6. field: 'llm_type',
  7. title: isApplyType ? i18n.t('aice.llm_type.app') : i18n.t('aice.llm_type.llm'),
  8. width: 120,
  9. formatter: ({ row }) => {
  10. return row.llm_type || '-'
  11. },
  12. }
  13. }
  14. export const getLlmIpColumn = () => {
  15. return {
  16. field: 'llm_ip',
  17. title: 'IP',
  18. width: 150,
  19. sortable: true,
  20. slots: {
  21. default: ({ row }, h) => {
  22. if (!row.llm_ip) return '-'
  23. const ip = row.llm_ip
  24. return [
  25. <list-body-cell-wrap copy row={{ ip }} hide-field field="ip">{ip}</list-body-cell-wrap>,
  26. ]
  27. },
  28. },
  29. formatter: ({ row }) => {
  30. return row.llm_ip || '-'
  31. },
  32. }
  33. }
  34. export const getLlmSkuColumn = ({ vm = {}, isApplyType = false } = {}) => {
  35. return {
  36. field: 'llm_sku',
  37. title: isApplyType ? i18n.t('aice.app_llm_sku') : i18n.t('aice.llm_sku'),
  38. width: 120,
  39. slots: {
  40. default: ({ row }, h) => {
  41. const text = row.llm_sku || '-'
  42. return [
  43. <list-body-cell-wrap copy hideField={true} field='llm_sku' row={row} message={text}>
  44. <side-page-trigger permission='llm_skus_get' name='LlmSkuSidePage' id={row.llm_sku_id} vm={vm}>{text}</side-page-trigger>
  45. </list-body-cell-wrap>,
  46. ]
  47. },
  48. },
  49. formatter: ({ row }) => {
  50. return row.llm_sku || '-'
  51. },
  52. }
  53. }
  54. export const getLlmImageColumn = ({ vm = {} } = {}) => {
  55. return {
  56. field: 'llm_image',
  57. title: i18n.t('aice.llm_image'),
  58. width: 120,
  59. slots: {
  60. default: ({ row }, h) => {
  61. const text = row.llm_image || '-'
  62. return [
  63. <list-body-cell-wrap copy hideField={true} field='llm_image' row={row} message={text}>
  64. <side-page-trigger permission='llm_images_get' name='LlmImageSidePage' id={row.llm_image_id} vm={vm}>{text}</side-page-trigger>
  65. </list-body-cell-wrap>,
  66. ]
  67. },
  68. },
  69. formatter: ({ row }) => {
  70. return row.llm_image || '-'
  71. },
  72. }
  73. }
  74. export const getCpuTableColumn = () => {
  75. return {
  76. field: 'vcpu_count',
  77. title: 'CPU',
  78. width: 120,
  79. sortable: true,
  80. formatter: ({ row }) => {
  81. return row.vcpu_count || 0
  82. },
  83. }
  84. }
  85. export const getMemoryTableColumn = () => {
  86. return {
  87. field: 'vmem_size_mb',
  88. title: i18n.t('aice.memory'),
  89. width: 120,
  90. formatter: ({ row }) => {
  91. return sizestr(row.vmem_size_mb, 'M', 1024)
  92. },
  93. }
  94. }
  95. export const getDiskTableColumn = () => {
  96. return {
  97. field: 'volume',
  98. title: i18n.t('aice.disk'),
  99. width: 120,
  100. formatter: ({ row }) => {
  101. return sizestr(row.volume?.size_mb, 'M', 1024)
  102. },
  103. }
  104. }
  105. export const getBandwidthTableColumn = () => {
  106. return {
  107. field: 'bandwidth_mb',
  108. title: i18n.t('aice.bandwidth'),
  109. width: 120,
  110. formatter: ({ row }) => {
  111. if (row.bandwidth_mb === 0) return `0(${i18n.t('common.not_limited')})`
  112. return `${row.bandwidth_mb || 0}M`
  113. },
  114. }
  115. }
  116. export const getEffectBandwidthMbpsTableColumn = () => {
  117. return {
  118. field: 'effect_bandwidth_mbps',
  119. title: i18n.t('scope.cloudgame.effect_bandwidth_mbps'),
  120. width: 120,
  121. formatter: ({ row }) => {
  122. return row.effect_bandwidth_mbps || 0
  123. },
  124. }
  125. }
  126. export const getHostTableColumn = (vm) => {
  127. return {
  128. field: 'host',
  129. title: i18n.t('dictionary.host'),
  130. width: 120,
  131. slots: {
  132. default: ({ row }, h) => {
  133. return [
  134. <side-page-trigger permission='hosts_get' name='HostSidePage' id={row.host_id} vm={vm}>{row.host}</side-page-trigger>,
  135. ]
  136. },
  137. },
  138. }
  139. }
  140. export const getImageTableColumn = () => {
  141. return {
  142. field: 'image_name',
  143. title: i18n.t('scope.cloudgame.image'),
  144. width: 120,
  145. formatter: ({ row }) => {
  146. return row.image_name
  147. },
  148. }
  149. }
  150. export const getAppImageTableColumn = (vm) => {
  151. return {
  152. field: 'app_image',
  153. title: 'App Image',
  154. width: 120,
  155. slots: {
  156. default: ({ row }, h) => {
  157. return row.app_image || '-'
  158. // return [
  159. // <side-page-trigger permission='hosts_get' name='AppImageSidePage' id={row.app_image_id} vm={vm} tab="host-detail">{row.app_image}</side-page-trigger>,
  160. // ]
  161. },
  162. },
  163. }
  164. }
  165. export const getDeskopIpTableColumn = () => {
  166. return getCopyWithContentTableColumn({ field: 'desktop_ip', title: 'IP' })
  167. }
  168. export const getStreamEndpointColumn = (endpoint) => {
  169. return getCopyWithContentTableColumn({
  170. field: 'endpoint',
  171. title: i18n.t('scope.stream_endpoint'),
  172. message: endpoint,
  173. hideField: true,
  174. slotCallback: (row) => {
  175. return endpoint || '-'
  176. },
  177. })
  178. }
  179. export const getPortsColumn = (ports) => {
  180. return {
  181. title: i18n.t('scope.cloudgame.access_info'),
  182. field: 'access_info',
  183. slots: {
  184. default: ({ row }, h) => {
  185. if (!ports.length) return '-'
  186. const cls = [
  187. {
  188. title: i18n.t('scope.cloudgame.access_info.protocol'),
  189. field: 'protocol',
  190. formatter: ({ row }) => {
  191. if (!row.protocol) return '-'
  192. return row.protocol.toUpperCase()
  193. },
  194. },
  195. {
  196. title: i18n.t('scope.cloudgame.access_info.desktop_ip'),
  197. field: 'desktop_ip',
  198. slots: {
  199. default: ({ row }, h) => {
  200. return [
  201. <list-body-cell-wrap copy row={{ row }} hide-field field="desktop_ip">{row.desktop_ip}</list-body-cell-wrap>,
  202. ]
  203. },
  204. },
  205. },
  206. {
  207. title: i18n.t('scope.cloudgame.access_info.listen_port'),
  208. field: 'listen_port',
  209. },
  210. {
  211. title: i18n.t('scope.cloudgame.access_info.server_ip'),
  212. field: 'server_ip',
  213. slots: {
  214. default: ({ row }, h) => {
  215. return [
  216. <list-body-cell-wrap copy row={{ row }} hide-field field="server_ip">{row.server_ip}</list-body-cell-wrap>,
  217. <list-body-cell-wrap copy row={{ row }} hide-field field="public_ip">{row.public_ip}</list-body-cell-wrap>,
  218. ]
  219. },
  220. },
  221. },
  222. {
  223. title: i18n.t('scope.cloudgame.access_info.access_port'),
  224. field: 'access_port',
  225. },
  226. {
  227. title: i18n.t('scope.cloudgame.access_info.port_mapping_envs'),
  228. field: 'port_mapping_envs',
  229. formatter: ({ row }) => {
  230. return row.port_mapping_envs.map(item => `${item.key}:${item.value_from}`).join(',')
  231. },
  232. },
  233. ]
  234. return <vxe-grid data={ports || []} columns={cls}></vxe-grid>
  235. },
  236. },
  237. }
  238. }
  239. export const getNetworkTableColumn = () => {
  240. return {
  241. field: 'network',
  242. title: i18n.t('cloudenv.text_7'),
  243. formatter: ({ row }) => {
  244. return row.network || '-'
  245. },
  246. }
  247. }
  248. export const getNetworkTypeTableColumn = () => {
  249. return {
  250. field: 'network_type',
  251. title: i18n.t('common.network.type'),
  252. formatter: ({ row }) => {
  253. return i18n.t('networkServerType')[row.network_type] || '-'
  254. },
  255. }
  256. }