index.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <div style="height: 400px">
  3. <!-- <component-form v-if="resData.config" @submit="submit" :config="resData.config" /> -->
  4. <component :is="component" v-if="loaded" @submit="submit" :updateData="resData" :isUpdate="true" />
  5. <a-alert v-else :message="$t('k8s.text_265')" banner />
  6. </div>
  7. </template>
  8. <script>
  9. import Ceph from '../components/Ceph'
  10. import Fluentbit from '../components/Fluentbit'
  11. import Monitor from '../components/Monitor'
  12. import { componentMap } from '../constants/componentMap'
  13. export default {
  14. name: 'K8SKubeComponentUpdate',
  15. components: {
  16. Ceph,
  17. Fluentbit,
  18. Monitor,
  19. },
  20. data () {
  21. return {
  22. loading: false,
  23. loaded: false,
  24. resData: {},
  25. component: componentMap[this.$route.query.kubeComponent],
  26. }
  27. },
  28. created () {
  29. this.manager = new this.$Manager('kubeclusters', 'v1')
  30. this.fetchData()
  31. },
  32. methods: {
  33. async fetchData () {
  34. try {
  35. const { cluster = 'default', kubeComponent } = this.$route.query
  36. this.loading = true
  37. const { data = {} } = await this.manager.getSpecific({
  38. id: cluster,
  39. spec: 'component-setting',
  40. params: {
  41. type: kubeComponent,
  42. },
  43. })
  44. this.resData = data[kubeComponent]
  45. this.loaded = true
  46. } catch (error) {
  47. throw error
  48. } finally {
  49. this.loading = false
  50. }
  51. },
  52. async submit (data) {
  53. try {
  54. this.loading = true
  55. const { cluster = 'default', kubeComponent } = this.$route.query
  56. await this.manager.performAction({
  57. id: cluster,
  58. action: 'update-component',
  59. data: {
  60. [kubeComponent]: data,
  61. type: kubeComponent,
  62. },
  63. })
  64. this.$store.commit('keepAlive/ADD_DELAY_EVENT', { name: 'ResourceListSingleRefresh', params: cluster })
  65. this.loading = false
  66. this.$message.success(this.$t('k8s.text_46'))
  67. this.$router.push('/k8s-kubecomponent')
  68. } catch (error) {
  69. this.loading = false
  70. throw error
  71. }
  72. },
  73. },
  74. }
  75. </script>
  76. <style>
  77. </style>