InstallAgentFormVisible.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <div>
  3. <a-alert class="mb-2" :type="alertType">
  4. <install-agent-form slot="message" :data="data" :serverColumns="serverColumns" :isPageDestroyed="isPageDestroyed" @onInstall="handleInstallResult" />
  5. </a-alert>
  6. </div>
  7. </template>
  8. <script>
  9. import _ from 'lodash'
  10. import InstallAgentForm from '@Compute/views/vminstance/components/InstallAgentForm'
  11. export default {
  12. name: 'InstallAgentFormVisible',
  13. components: {
  14. InstallAgentForm,
  15. },
  16. props: {
  17. data: {
  18. type: Object,
  19. required: true,
  20. },
  21. serverColumns: {
  22. type: Array,
  23. required: true,
  24. },
  25. isPageDestroyed: Boolean,
  26. },
  27. data () {
  28. let ok = _.get(this.data, ['metadata', 'sys:monitor_agent']) || _.get(this.data, ['metadata', '__monitor_agent'])
  29. const deploy = _.get(this.data, ['metadata', 'telegraf_deployed'])
  30. if (this.data.hasOwnProperty('agent_status') || deploy) {
  31. ok = this.data.agent_status === 'succeed' || deploy
  32. }
  33. // const visible = this.data.status === 'running' && !ok
  34. return {
  35. visible: !ok,
  36. alertType: 'warning',
  37. }
  38. },
  39. methods: {
  40. handleInstallResult (ret) {
  41. if (ret && ret.status === 'succeed') {
  42. this.alertType = 'success'
  43. this.$nextTick(() => {
  44. setTimeout(() => { this.visible = false }, 3000)
  45. })
  46. }
  47. },
  48. },
  49. }
  50. </script>