Detail.vue 7.9 KB

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