ShowKubeConfigDialog.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{$t('k8s.text_19')}}</div>
  4. <div slot="body">
  5. <code-mirror v-model="configText" :options="cmOptions" />
  6. </div>
  7. <div slot="footer">
  8. <a-button
  9. type="primary"
  10. v-clipboard:copy="configText"
  11. v-clipboard:success="_ => $message.success($t('k8s.text_31'))"
  12. v-clipboard:error="_ => $message.error($t('k8s.text_32'))">{{$t('k8s.text_176')}}</a-button>
  13. </div>
  14. </base-dialog>
  15. </template>
  16. <script>
  17. import DialogMixin from '@/mixins/dialog'
  18. import WindowsMixin from '@/mixins/windows'
  19. export default {
  20. name: 'ClusterShowKubeConfigDialog',
  21. mixins: [DialogMixin, WindowsMixin],
  22. data () {
  23. return {
  24. loading: false,
  25. scope: this.$store.getters.scope,
  26. configText: '',
  27. cmOptions: {
  28. tabSize: 4,
  29. styleActiveLine: true,
  30. lineNumbers: true,
  31. line: true,
  32. mode: 'text/x-yaml',
  33. lineWrapping: true,
  34. readOnly: true,
  35. theme: 'material',
  36. },
  37. }
  38. },
  39. created () {
  40. this.loadSchedTags()
  41. },
  42. methods: {
  43. loadSchedTags (query) {
  44. new this.$Manager('kubeclusters', 'v1').getSpecific({ id: this.params.data[0].id, spec: 'kubeconfig' })
  45. .then(({ data }) => {
  46. this.configText = data.kubeconfig
  47. })
  48. },
  49. },
  50. }
  51. </script>