singleActions.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. export default {
  2. created () {
  3. this.singleActions = [
  4. {
  5. label: this.$t('compute.repo.terminal'),
  6. action: async (obj) => {
  7. const connectRes = await this.fetchConnectUrl(obj)
  8. this.openWebConsole(connectRes)
  9. },
  10. meta: (obj) => {
  11. const ret = { validate: true }
  12. if (obj.status !== 'running' && obj.status !== 'probing') {
  13. ret.tooltip = this.$t('compute.repo.helper.terminal', [this.$t('dictionary.container')])
  14. ret.validate = false
  15. }
  16. return ret
  17. },
  18. },
  19. {
  20. label: this.$t('common.more'),
  21. actions: (obj) => {
  22. return [
  23. // 同步状态
  24. {
  25. label: this.$t('compute.perform_sync_status'),
  26. permission: 'containers_perform_syncstatus',
  27. action: () => {
  28. this.onManager('performAction', {
  29. steadyStatus: ['running', 'ready'],
  30. id: obj.id,
  31. managerArgs: {
  32. action: 'syncstatus',
  33. },
  34. })
  35. },
  36. },
  37. {
  38. label: this.$t('compute.repo.start'),
  39. action: () => {
  40. this.onManager('performAction', {
  41. steadyStatus: 'running',
  42. id: obj.id,
  43. managerArgs: {
  44. action: 'start',
  45. },
  46. })
  47. },
  48. meta: () => {
  49. return {
  50. validate: obj.status === 'exited',
  51. }
  52. },
  53. },
  54. {
  55. label: this.$t('compute.repo.stop'),
  56. action: () => {
  57. this.createDialog('ContainerShutDownDialog', {
  58. data: [obj],
  59. columns: this.columns,
  60. onManager: this.onManager,
  61. })
  62. },
  63. meta: () => {
  64. return {
  65. validate: obj.status === 'running',
  66. }
  67. },
  68. },
  69. {
  70. label: this.$t('table.action.modify'),
  71. action: (obj) => {
  72. this.createDialog('ContainerUpdateDialog', {
  73. data: [obj],
  74. columns: this.columns,
  75. onManager: this.onManager,
  76. })
  77. },
  78. meta: (obj) => {
  79. const ret = { validate: true }
  80. if (obj.status !== 'exited') {
  81. ret.tooltip = this.$t('compute.repo.helper.modify')
  82. ret.validate = false
  83. }
  84. return ret
  85. },
  86. },
  87. ]
  88. },
  89. },
  90. ]
  91. },
  92. methods: {
  93. openWebConsole (data) {
  94. this.$openWebConsole(data)
  95. },
  96. async fetchConnectUrl (obj) {
  97. const { data } = await new this.$Manager('webconsole', 'v1').objectRpc({
  98. methodname: 'DoContainerExec',
  99. params: {
  100. container_id: obj.id,
  101. },
  102. })
  103. return Promise.resolve(data)
  104. },
  105. },
  106. }