singleActions.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. export default {
  2. created () {
  3. this.singleActions = [
  4. // 同步状态
  5. {
  6. label: this.$t('common.text00043'),
  7. action: (obj) => {
  8. this.onManager('batchPerformAction', {
  9. steadyStatus: ['running', 'ready'],
  10. id: [obj.id],
  11. managerArgs: {
  12. action: 'syncstatus',
  13. },
  14. })
  15. },
  16. },
  17. {
  18. label: this.$t('compute.repo.terminal'),
  19. actions: (obj) => {
  20. const data = obj.cmp_info || {}
  21. const containers = data.containers || []
  22. return containers.map(item => {
  23. return {
  24. label: item.name,
  25. action: async () => {
  26. const connectRes = await this.fetchConnectUrl(item.id)
  27. this.openWebConsole(connectRes)
  28. },
  29. }
  30. })
  31. },
  32. meta: (obj) => {
  33. const data = obj.cmp_info || {}
  34. const ret = { validate: true }
  35. if (!data.containers?.length) {
  36. ret.validate = false
  37. return ret
  38. }
  39. if (data.status !== 'running' && data.status !== 'probing') {
  40. ret.tooltip = this.$t('compute.repo.helper.terminal', [this.$t('compute.vminstance-container')])
  41. ret.validate = false
  42. }
  43. return ret
  44. },
  45. },
  46. {
  47. label: this.$t('compute.text_352'),
  48. actions: obj => {
  49. return [
  50. {
  51. label: this.$t('aice.llm_spec_update'),
  52. action: (row) => {
  53. this.createDialog('LlmUpdateSpecDialog', {
  54. data: [row],
  55. onManager: this.onManager,
  56. refresh: this.refresh,
  57. })
  58. },
  59. meta: (row) => {
  60. const ret = {
  61. validate: (row.llm_type || '').toLowerCase() === 'openclaw',
  62. tooltip: null,
  63. }
  64. return ret
  65. },
  66. },
  67. // 开机
  68. {
  69. label: this.$t('compute.text_272'),
  70. action: (obj) => {
  71. this.createDialog('LlmBatchConfirmDialog', {
  72. data: [obj],
  73. columns: this.columns,
  74. onManager: this.onManager,
  75. action: 'start',
  76. actionText: this.$t('compute.text_272'),
  77. steadyStatus: 'running',
  78. })
  79. },
  80. meta: (obj) => {
  81. const ret = {
  82. validate: (obj.status === 'ready'),
  83. tooltip: null,
  84. }
  85. return ret
  86. },
  87. // hidden: () => this.$isScopedPolicyMenuHidden('vminstance_hidden_menus.server_perform_start'),
  88. },
  89. {
  90. label: this.$t('aice.install_instant_model'),
  91. action: (obj) => {
  92. this.createDialog('LlmQuickModelDialog', {
  93. data: [obj],
  94. columns: this.columns,
  95. onManager: this.onManager,
  96. actionText: this.$t('aice.install_instant_model'),
  97. })
  98. },
  99. meta: (obj) => {
  100. const ret = {
  101. validate: (obj.status === 'running'),
  102. tooltip: null,
  103. }
  104. return ret
  105. },
  106. hidden: () => this.isApplyType,
  107. },
  108. // 重启
  109. {
  110. label: this.$t('aice.action.restart'),
  111. permission: 'server_perform_restart',
  112. action: (obj) => {
  113. this.createDialog('LlmBatchConfirmDialog', {
  114. data: [obj],
  115. columns: this.columns,
  116. onManager: this.onManager,
  117. action: 'restart',
  118. actionText: this.$t('aice.action.restart'),
  119. steadyStatus: 'running',
  120. })
  121. },
  122. meta: (obj) => {
  123. const ret = {
  124. validate: ['running', 'stop_fail', 'ready'].includes(obj.status),
  125. tooltip: null,
  126. }
  127. return ret
  128. },
  129. },
  130. // 更改项目
  131. {
  132. label: this.$t('compute.perform_change_owner', [this.$t('dictionary.project')]),
  133. permission: 'llms_perform_public',
  134. action: (obj) => {
  135. this.createDialog('ChangeOwenrDialog', {
  136. data: [obj],
  137. columns: this.columns,
  138. onManager: this.onManager,
  139. refresh: this.refresh,
  140. resource: 'llms',
  141. })
  142. },
  143. },
  144. // 关机
  145. {
  146. label: this.$t('compute.text_273'),
  147. permission: 'server_perform_stop',
  148. action: (obj) => {
  149. this.createDialog('LlmBatchConfirmDialog', {
  150. data: [obj],
  151. columns: this.columns,
  152. onManager: this.onManager,
  153. action: 'stop',
  154. actionText: this.$t('compute.text_273'),
  155. steadyStatus: 'ready',
  156. })
  157. },
  158. meta: (obj) => {
  159. const ret = {
  160. validate: (obj.status === 'running'),
  161. tooltip: null,
  162. }
  163. return ret
  164. },
  165. hidden: () => this.$isScopedPolicyMenuHidden('vminstance_hidden_menus.phone_perform_stop'),
  166. },
  167. // 删除
  168. {
  169. label: this.$t('table.action.delete'),
  170. action: (obj) => {
  171. this.createDialog('DeleteResDialog', {
  172. vm: this,
  173. data: [obj],
  174. columns: this.columns,
  175. title: this.$t('table.action.delete'),
  176. name: this.$t('aice.llm'),
  177. onManager: this.onManager,
  178. })
  179. },
  180. meta: obj => this.$getDeleteResult(obj),
  181. },
  182. ]
  183. },
  184. },
  185. ]
  186. },
  187. computed: {
  188. isApplyType () {
  189. return this.$route.path.includes('app-llm')
  190. },
  191. },
  192. methods: {
  193. openWebConsole (data) {
  194. this.$openWebConsole(data)
  195. },
  196. async fetchConnectUrl (containerId) {
  197. const { data } = await new this.$Manager('webconsole', 'v1').objectRpc({
  198. methodname: 'DoContainerExec',
  199. params: {
  200. container_id: containerId,
  201. },
  202. })
  203. return Promise.resolve(data)
  204. },
  205. },
  206. }