Secgroup.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <div>
  3. <h5 v-if="isKvm">{{ $t('dictionary.guestsecgroup') }}</h5>
  4. <vm-secgroup-list :getParams="params" :id="id" :resId="resId" :serverColumns="serverColumns" :data="data" />
  5. <h5 class="mt-2" v-if="isKvm">{{ $t('compute.nic_secgroups') }}</h5>
  6. <network-secgroup-list v-if="isKvm" :getParams="params" :id="id" :resId="resId" :data="data" />
  7. </div>
  8. </template>
  9. <script>
  10. import { HYPERVISORS_MAP } from '@/constants'
  11. import VmSecgroupList from './VmSecgroup'
  12. import NetworkSecgroupList from './NetSecgroup'
  13. export default {
  14. name: 'SecgroupIndex',
  15. components: {
  16. VmSecgroupList,
  17. NetworkSecgroupList,
  18. },
  19. props: {
  20. resId: String,
  21. getParams: {
  22. type: [Function, Object],
  23. },
  24. data: {
  25. type: Object,
  26. required: true,
  27. },
  28. serverColumns: {
  29. type: Array,
  30. default: () => ([]),
  31. },
  32. },
  33. data () {
  34. return {
  35. currentComponent: 'VmSecgroupList',
  36. }
  37. },
  38. computed: {
  39. isKvm () {
  40. return this.data.hypervisor === HYPERVISORS_MAP.kvm.key
  41. },
  42. tabs () {
  43. const ret = [
  44. {
  45. key: 'VmSecgroupList',
  46. label: this.$t('dictionary.server'),
  47. },
  48. ]
  49. if (this.isKvm) {
  50. ret.push({
  51. key: 'NetworkSecgroupList',
  52. label: this.$t('compute.nic'),
  53. })
  54. }
  55. return ret
  56. },
  57. id () {
  58. switch (this.currentComponent) {
  59. case 'VmSecgroupList':
  60. return 'VmSecgroupListForVminstanceSidepage'
  61. default:
  62. return 'NetworkSecgroupListForVminstanceSidepage'
  63. }
  64. },
  65. params () {
  66. const params = {
  67. ...this.getParams,
  68. }
  69. return params
  70. },
  71. },
  72. methods: {
  73. callback (key) {
  74. this.currentComponent = key
  75. },
  76. },
  77. }
  78. </script>