Topology.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <div>
  3. <div class="d-flex">
  4. <a-button @click="refreshHandle">
  5. <a-icon v-if="loading" type="sync" spin />
  6. <a-icon v-else type="sync" />
  7. </a-button>
  8. <a-radio-group v-if="classic" v-model="view" @change="handleChange" class="ml-2">
  9. <a-radio-button value="virtual">{{ $t('network.topology.view.virtual') }}</a-radio-button>
  10. <a-radio-button value="physical">{{ $t('network.topology.view.pysical') }}</a-radio-button>
  11. </a-radio-group>
  12. </div>
  13. <res-topology v-if="dataSource" :classic="classic" :physical="physical" :dataSource="dataSource" />
  14. <a-skeleton active v-if="!dataSource" />
  15. </div>
  16. </template>
  17. <script>
  18. import ResTopology from '../components/ResTopology'
  19. export default {
  20. name: 'Topology',
  21. components: {
  22. ResTopology,
  23. },
  24. props: {
  25. resId: String,
  26. },
  27. data () {
  28. return {
  29. loading: false,
  30. dataSource: null,
  31. physical: false,
  32. view: 'virtual',
  33. }
  34. },
  35. computed: {
  36. classic () {
  37. return this.resId === 'default'
  38. },
  39. },
  40. created () {
  41. this.fetchVpcTopology()
  42. },
  43. methods: {
  44. fetchVpcTopology () {
  45. const vpcManager = new this.$Manager('vpcs')
  46. this.loading = true
  47. this.dataSource = null
  48. vpcManager.get({ id: `${this.resId}/topology` }).then((res) => {
  49. this.dataSource = res.data
  50. this.loading = false
  51. }).catch((err) => {
  52. this.loading = false
  53. throw err
  54. })
  55. },
  56. refreshHandle () {
  57. this.fetchVpcTopology()
  58. },
  59. handleChange (e) {
  60. this.physical = e.target.value === 'physical'
  61. },
  62. },
  63. }
  64. </script>