Detail.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <template>
  2. <detail
  3. :data="data"
  4. :base-info="baseInfo"
  5. :extra-info="extraInfo"
  6. :on-manager="onManager"
  7. :resource="resource"
  8. status-module="image" />
  9. </template>
  10. <script>
  11. import {
  12. getUserTagColumn,
  13. getExtTagColumn,
  14. } from '@/utils/common/detailColumn'
  15. import { sizestr } from '@/utils/utils'
  16. import {
  17. getStatusTableColumn,
  18. getCopyWithContentTableColumn,
  19. getSwitchTableColumn,
  20. getPublicScopeTableColumn,
  21. getTagTableColumn,
  22. getOsArch,
  23. } from '@/utils/common/tableColumn'
  24. import WindowsMixin from '@/mixins/windows'
  25. export default {
  26. name: 'SystemCachedImageDetail',
  27. mixins: [WindowsMixin],
  28. props: {
  29. data: {
  30. type: Object,
  31. required: true,
  32. },
  33. onManager: {
  34. type: Function,
  35. required: true,
  36. },
  37. resource: String,
  38. columns: Array,
  39. },
  40. data () {
  41. return {
  42. baseInfo: [
  43. getUserTagColumn({ onManager: this.onManager, resource: 'cachedimage', columns: () => this.columns, tipName: this.$t('compute.text_97') }),
  44. getExtTagColumn({ onManager: this.onManager, resource: 'cachedimage', columns: () => this.columns, tipName: this.$t('compute.text_97') }),
  45. getTagTableColumn({ onManager: this.onManager, resource: 'cachedimage', columns: () => this.columns }),
  46. {
  47. field: 'project_domain',
  48. title: this.$t('dictionary.domain'),
  49. formatter: ({ row }) => {
  50. if (!row.domain_id) return '-'
  51. return <side-page-trigger permission="domains_get" name="DomainSidePage" id={row.domain_id} vm={this}>{ row.project_domain }</side-page-trigger>
  52. },
  53. },
  54. {
  55. field: 'tenant',
  56. title: this.$t('dictionary.project'),
  57. formatter: ({ row }) => {
  58. if (!row.tenant_id) return '-'
  59. return <side-page-trigger permission="projects_get" name="ProjectSidePage" id={row.tenant_id} vm={this}>{ row.tenant }</side-page-trigger>
  60. },
  61. },
  62. getPublicScopeTableColumn({ vm: this, resource: 'cachedimages' }),
  63. {
  64. field: 'size',
  65. title: this.$t('compute.text_377'),
  66. formatter: ({ cellValue, row }) => {
  67. return sizestr(cellValue, 'B', 1024)
  68. },
  69. },
  70. ],
  71. extraInfo: [
  72. {
  73. title: this.$t('compute.text_629'),
  74. items: [
  75. getOsArch({ field: 'info.properties.os_arch' }),
  76. {
  77. field: 'info.disk_format',
  78. title: this.$t('compute.text_630'),
  79. },
  80. {
  81. field: 'image_type',
  82. title: this.$t('table.title.image_type'),
  83. formatter: (val) => {
  84. return val === 'custom' ? this.$t('compute.text_620') : this.$t('compute.text_97')
  85. },
  86. },
  87. {
  88. field: 'os_lang',
  89. title: this.$t('compute.text_631'),
  90. formatter: ({ cellValue, row }) => {
  91. return (row.info && row.info.properties && row.info.properties.os_lang) || '-'
  92. },
  93. },
  94. {
  95. field: 'min_ram',
  96. title: this.$t('compute.text_632'),
  97. formatter: ({ row }) => {
  98. return sizestr(row.info.min_ram_mb, 'M', 1024)
  99. },
  100. },
  101. {
  102. field: 'min_disk',
  103. title: this.$t('compute.text_633'),
  104. formatter: ({ cellValue, row }) => {
  105. return sizestr(row.info.min_disk_mb, 'M', 1024)
  106. },
  107. },
  108. {
  109. field: 'disk_driver',
  110. title: this.$t('compute.text_634'),
  111. formatter: ({ cellValue, row }) => {
  112. return (row.info && row.info.properties && row.info.properties.disk_driver) || '-'
  113. },
  114. },
  115. {
  116. field: 'net_driver',
  117. title: this.$t('compute.text_635'),
  118. formatter: ({ cellValue, row }) => {
  119. return (row.info && row.info.properties && row.info.properties.net_driver) || '-'
  120. },
  121. },
  122. {
  123. field: 'uefi_support',
  124. title: this.$t('compute.text_1155'),
  125. formatter: ({ cellValue, row }) => {
  126. const { properties = {} } = row
  127. const { uefi_support, bios_support } = properties
  128. if (uefi_support === 'true' && bios_support === 'true') {
  129. return 'BIOS & UEFI'
  130. } else if (uefi_support === 'true' && bios_support !== 'true') {
  131. return 'UEFI'
  132. }
  133. return 'BIOS'
  134. },
  135. },
  136. {
  137. field: 'vdi_protocol',
  138. title: this.$t('compute.vdi_protocol'),
  139. formatter: ({ cellValue, row }) => {
  140. return (row.info && row.info.properties && row.info.properties.vdi_protocol) || '-'
  141. },
  142. },
  143. {
  144. field: 'hypervisor',
  145. title: this.$t('compute.text_636'),
  146. },
  147. ],
  148. },
  149. {
  150. title: this.$t('compute.title.encryption'),
  151. items: [
  152. {
  153. field: 'encrypt_key_id',
  154. title: this.$t('compute.title.encryption_key'),
  155. formatter: ({ callValue, row }) => {
  156. if (row.encrypt_key_id) {
  157. if (row.encrypt_key && row.encrypt_alg) {
  158. return row.encrypt_key + ' (' + row.encrypt_key_id + ')'
  159. } else {
  160. return row.encrypt_key_id
  161. }
  162. } else {
  163. return this.$t('compute.no_encryption')
  164. }
  165. },
  166. },
  167. {
  168. field: 'encrypt_alg',
  169. title: this.$t('compute.title.encrypt_alg'),
  170. formatter: ({ callValue, row }) => {
  171. if (row.encrypt_alg) {
  172. return row.encrypt_alg.toUpperCase()
  173. } else {
  174. return '-'
  175. }
  176. },
  177. },
  178. {
  179. field: 'encrypt_key_user',
  180. title: this.$t('compute.title.encrypt_key_user'),
  181. formatter: ({ callValue, row }) => {
  182. if (row.encrypt_key_user) {
  183. return row.encrypt_key_user + ' / ' + row.encrypt_key_user_domain
  184. } else {
  185. return '-'
  186. }
  187. },
  188. },
  189. ],
  190. },
  191. // {
  192. // title: this.$t('compute.text_637'),
  193. // field: 'cloudy_mirroring',
  194. // slots: {
  195. // default: ({ row }, h) => {
  196. // return [
  197. // <vxe-grid class="mb-2" data={ this.imgSubformat } columns={ this.imageColumns } />,
  198. // ]
  199. // },
  200. // },
  201. // },
  202. {
  203. title: this.$t('compute.text_497'),
  204. items: [
  205. getSwitchTableColumn({
  206. field: 'protected',
  207. title: this.$t('common.text00076'),
  208. change: val => {
  209. this.onManager('update', {
  210. id: this.data.id,
  211. managerArgs: {
  212. data: { protected: val },
  213. },
  214. })
  215. },
  216. }),
  217. ],
  218. },
  219. ],
  220. imageColumns: [
  221. getCopyWithContentTableColumn({
  222. field: 'checksum',
  223. title: this.$t('compute.text_638'),
  224. }),
  225. {
  226. field: 'format',
  227. title: this.$t('compute.text_398'),
  228. },
  229. {
  230. field: 'size',
  231. title: this.$t('compute.text_377'),
  232. formatter: ({ cellValue, row }) => {
  233. return sizestr(cellValue, 'B', 1024)
  234. },
  235. },
  236. getStatusTableColumn({ statusModule: 'image' }),
  237. ],
  238. imgSubformat: [],
  239. }
  240. },
  241. created () {
  242. // this.updateDetailData()
  243. },
  244. methods: {
  245. updateDetailData () {
  246. new this.$Manager('cachedimages', 'v1').getSpecific({
  247. id: this.data.id,
  248. spec: 'subformats',
  249. }).then(({ data }) => {
  250. this.imgSubformat = data
  251. })
  252. },
  253. },
  254. }
  255. </script>