Topology.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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-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" :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. created () {
  36. this.fetchVpcTopology()
  37. },
  38. methods: {
  39. fetchVpcTopology () {
  40. const wireManager = new this.$Manager('wires')
  41. this.loading = true
  42. this.dataSource = null
  43. wireManager.get({ id: `${this.resId}/topology` }).then((res) => {
  44. this.dataSource = res.data
  45. this.loading = false
  46. }).catch((err) => {
  47. this.loading = false
  48. throw err
  49. })
  50. },
  51. refreshHandle () {
  52. this.fetchVpcTopology()
  53. },
  54. handleChange (e) {
  55. this.physical = e.target.value === 'physical'
  56. },
  57. },
  58. }
  59. </script>