Monitor.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <div>
  3. <a-tabs v-if="resType === 'guest'" @change="handleTabChange">
  4. <a-tab-pane key="basic" :tab="$t('compute.monitor.basic')">
  5. <base-monitor :data="data" :constants="monitorConstants" :resId="serverId" monitorType="basic" :currentMonitorType="currentMonitorType" />
  6. </a-tab-pane>
  7. <a-tab-pane key="agent" :tab="$t('compute.monitor.agent')">
  8. <div>
  9. <install-agent-form-visible
  10. :data="installData"
  11. :serverColumns="serverColumns"
  12. :isPageDestroyed="isPageDestroyed" />
  13. <agent-monitor
  14. :data="data"
  15. key="monitor-agent"
  16. :constants="agentMonitor"
  17. :resId="serverId" />
  18. </div>
  19. </a-tab-pane>
  20. </a-tabs>
  21. <div v-else>
  22. <!-- <install-agent-form-visible
  23. :data="data"
  24. :serverColumns="serverColumns" /> -->
  25. <agent-monitor
  26. :data="data"
  27. key="monitor-agent"
  28. :constants="agentMonitor"
  29. :currentMonitorType="currentMonitorType"
  30. monitorType="agent"
  31. :resId="serverId"
  32. idKey="host_id" />
  33. </div>
  34. </div>
  35. </template>
  36. <script>
  37. import * as R from 'ramda'
  38. import BaseMonitor from '@Compute/sections/monitor/BaseMonitor'
  39. import AgentMonitor from '@Compute/sections/monitor/AgentMonitor.vue'
  40. import InstallAgentFormVisible from '@Compute/views/vminstance/components/InstallAgentFormVisible'
  41. import { HYPERVISORS_MAP } from '@/constants'
  42. import WindowsMixin from '@/mixins/windows'
  43. import { ONECLOUD_MONITOR, VMWARE_MONITOR, OTHER_MONITOR, AGENT_MONITOR, HOST_AGENT_MONITOR } from '../constants'
  44. export default {
  45. name: 'VminstanceMonitorSidepage',
  46. components: {
  47. BaseMonitor,
  48. AgentMonitor,
  49. InstallAgentFormVisible,
  50. },
  51. mixins: [WindowsMixin],
  52. props: {
  53. data: { // listItemData
  54. type: Object,
  55. required: true,
  56. },
  57. serverColumns: {
  58. type: Array,
  59. required: true,
  60. },
  61. resType: {
  62. type: String,
  63. required: true,
  64. },
  65. isPageDestroyed: Boolean,
  66. },
  67. data () {
  68. return {
  69. currentMonitorType: 'basic',
  70. alertType: 'warning',
  71. time: '1h',
  72. timeGroup: '1m',
  73. monitorList: [],
  74. }
  75. },
  76. computed: {
  77. hypervisor () {
  78. return this.data.hypervisor
  79. },
  80. monitorConstants () {
  81. if (this.hypervisor === HYPERVISORS_MAP.esxi.key) {
  82. return VMWARE_MONITOR
  83. } else if (this.hypervisor === HYPERVISORS_MAP.kvm.key) {
  84. return ONECLOUD_MONITOR
  85. } else {
  86. return OTHER_MONITOR
  87. }
  88. },
  89. serverId () {
  90. return this.data.res_id
  91. },
  92. agentMonitor () {
  93. if (this.resType === 'guest') {
  94. return AGENT_MONITOR
  95. }
  96. return HOST_AGENT_MONITOR
  97. },
  98. installData () {
  99. return Object.assign({}, R.clone(this.data), { id: this.data.res_id })
  100. },
  101. },
  102. methods: {
  103. handleTabChange (tab) {
  104. this.currentMonitorType = tab
  105. },
  106. },
  107. }
  108. </script>