List.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :group-actions="groupActions"
  6. :single-actions="singleActions"
  7. :export-data-options="exportDataOptions" />
  8. </template>
  9. <script>
  10. import { getNameFilter, getDescriptionFilter, getCreatedAtFilter } from '@/utils/common/tableFilter'
  11. import WindowsMixin from '@/mixins/windows'
  12. import ListMixin from '@/mixins/list'
  13. import SingleActionsMixin from '../mixins/singleActions'
  14. import ColumnsMixin from '../mixins/columns'
  15. export default {
  16. name: 'KeyPairList',
  17. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  18. props: {
  19. id: String,
  20. getParams: {
  21. type: Object,
  22. default: () => ({}),
  23. },
  24. },
  25. data () {
  26. return {
  27. list: this.$list.createList(this, {
  28. id: this.id,
  29. resource: 'keypairs',
  30. getParams: this.getParam,
  31. filterOptions: {
  32. id: {
  33. label: this.$t('table.title.id'),
  34. },
  35. name: getNameFilter(),
  36. description: getDescriptionFilter(),
  37. created_at: getCreatedAtFilter(),
  38. },
  39. hiddenColumns: ['created_at'],
  40. }),
  41. exportDataOptions: {
  42. items: [
  43. { label: 'ID', key: 'id' },
  44. { label: this.$t('compute.text_228'), key: 'name' },
  45. { label: this.$t('compute.text_725'), key: 'public_key' },
  46. { label: this.$t('compute.text_726'), key: 'fingerprint' },
  47. { label: this.$t('compute.text_175'), key: 'scheme' },
  48. { label: this.$t('compute.text_699', [this.$t('dictionary.server')]), key: 'linked_guest_count' },
  49. { label: this.$t('common.createdAt'), key: 'created_at' },
  50. ],
  51. },
  52. groupActions: [
  53. {
  54. label: this.$t('compute.perform_create'),
  55. permission: 'keypairs_create',
  56. action: () => {
  57. this.createDialog('CreateKeyPairDialog', {
  58. title: this.$t('compute.perform_create'),
  59. onManager: this.onManager,
  60. })
  61. },
  62. meta: () => ({
  63. buttonType: 'primary',
  64. }),
  65. },
  66. {
  67. label: this.$t('compute.perform_delete'),
  68. permission: 'keypairs_delete',
  69. action: () => {
  70. this.createDialog('DeleteResDialog', {
  71. vm: this,
  72. data: this.list.selectedItems,
  73. columns: this.columns,
  74. title: this.$t('compute.perform_delete'),
  75. name: this.$t('dictionary.keypair'),
  76. onManager: this.onManager,
  77. })
  78. },
  79. meta: () => {
  80. return {
  81. validate: this.list.allowDelete(),
  82. }
  83. },
  84. },
  85. ],
  86. }
  87. },
  88. created () {
  89. this.initSidePageTab('key-pair-detail')
  90. this.list.fetchData()
  91. },
  92. methods: {
  93. getParam () {
  94. const ret = {
  95. ...this.getParams,
  96. details: true,
  97. scope: 'user',
  98. }
  99. return ret
  100. },
  101. handleOpenSidepage (row) {
  102. this.sidePageTriggerHandle(this, 'KeyPairSidePage', {
  103. id: row.id,
  104. resource: 'keypairs',
  105. getParams: this.getParam,
  106. }, {
  107. list: this.list,
  108. })
  109. },
  110. },
  111. }
  112. </script>