| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- export default {
- created () {
- this.singleActions = [
- // 同步状态
- {
- label: this.$t('common.text00043'),
- action: (obj) => {
- this.onManager('batchPerformAction', {
- steadyStatus: ['running', 'ready'],
- id: [obj.id],
- managerArgs: {
- action: 'syncstatus',
- },
- })
- },
- },
- {
- label: this.$t('compute.repo.terminal'),
- actions: (obj) => {
- const data = obj.cmp_info || {}
- const containers = data.containers || []
- return containers.map(item => {
- return {
- label: item.name,
- action: async () => {
- const connectRes = await this.fetchConnectUrl(item.id)
- this.openWebConsole(connectRes)
- },
- }
- })
- },
- meta: (obj) => {
- const data = obj.cmp_info || {}
- const ret = { validate: true }
- if (!data.containers?.length) {
- ret.validate = false
- return ret
- }
- if (data.status !== 'running' && data.status !== 'probing') {
- ret.tooltip = this.$t('compute.repo.helper.terminal', [this.$t('compute.vminstance-container')])
- ret.validate = false
- }
- return ret
- },
- },
- {
- label: this.$t('compute.text_352'),
- actions: obj => {
- return [
- {
- label: this.$t('aice.llm_spec_update'),
- action: (row) => {
- this.createDialog('LlmUpdateSpecDialog', {
- data: [row],
- onManager: this.onManager,
- refresh: this.refresh,
- })
- },
- meta: (row) => {
- const ret = {
- validate: (row.llm_type || '').toLowerCase() === 'openclaw',
- tooltip: null,
- }
- return ret
- },
- },
- // 开机
- {
- label: this.$t('compute.text_272'),
- action: (obj) => {
- this.createDialog('LlmBatchConfirmDialog', {
- data: [obj],
- columns: this.columns,
- onManager: this.onManager,
- action: 'start',
- actionText: this.$t('compute.text_272'),
- steadyStatus: 'running',
- })
- },
- meta: (obj) => {
- const ret = {
- validate: (obj.status === 'ready'),
- tooltip: null,
- }
- return ret
- },
- // hidden: () => this.$isScopedPolicyMenuHidden('vminstance_hidden_menus.server_perform_start'),
- },
- {
- label: this.$t('aice.install_instant_model'),
- action: (obj) => {
- this.createDialog('LlmQuickModelDialog', {
- data: [obj],
- columns: this.columns,
- onManager: this.onManager,
- actionText: this.$t('aice.install_instant_model'),
- })
- },
- meta: (obj) => {
- const ret = {
- validate: (obj.status === 'running'),
- tooltip: null,
- }
- return ret
- },
- hidden: () => this.isApplyType,
- },
- // 重启
- {
- label: this.$t('aice.action.restart'),
- permission: 'server_perform_restart',
- action: (obj) => {
- this.createDialog('LlmBatchConfirmDialog', {
- data: [obj],
- columns: this.columns,
- onManager: this.onManager,
- action: 'restart',
- actionText: this.$t('aice.action.restart'),
- steadyStatus: 'running',
- })
- },
- meta: (obj) => {
- const ret = {
- validate: ['running', 'stop_fail', 'ready'].includes(obj.status),
- tooltip: null,
- }
- return ret
- },
- },
- // 更改项目
- {
- label: this.$t('compute.perform_change_owner', [this.$t('dictionary.project')]),
- permission: 'llms_perform_public',
- action: (obj) => {
- this.createDialog('ChangeOwenrDialog', {
- data: [obj],
- columns: this.columns,
- onManager: this.onManager,
- refresh: this.refresh,
- resource: 'llms',
- })
- },
- },
- // 关机
- {
- label: this.$t('compute.text_273'),
- permission: 'server_perform_stop',
- action: (obj) => {
- this.createDialog('LlmBatchConfirmDialog', {
- data: [obj],
- columns: this.columns,
- onManager: this.onManager,
- action: 'stop',
- actionText: this.$t('compute.text_273'),
- steadyStatus: 'ready',
- })
- },
- meta: (obj) => {
- const ret = {
- validate: (obj.status === 'running'),
- tooltip: null,
- }
- return ret
- },
- hidden: () => this.$isScopedPolicyMenuHidden('vminstance_hidden_menus.phone_perform_stop'),
- },
- // 删除
- {
- label: this.$t('table.action.delete'),
- action: (obj) => {
- this.createDialog('DeleteResDialog', {
- vm: this,
- data: [obj],
- columns: this.columns,
- title: this.$t('table.action.delete'),
- name: this.$t('aice.llm'),
- onManager: this.onManager,
- })
- },
- meta: obj => this.$getDeleteResult(obj),
- },
- ]
- },
- },
- ]
- },
- computed: {
- isApplyType () {
- return this.$route.path.includes('app-llm')
- },
- },
- methods: {
- openWebConsole (data) {
- this.$openWebConsole(data)
- },
- async fetchConnectUrl (containerId) {
- const { data } = await new this.$Manager('webconsole', 'v1').objectRpc({
- methodname: 'DoContainerExec',
- params: {
- container_id: containerId,
- },
- })
- return Promise.resolve(data)
- },
- },
- }
|