Skip to content

Commit

Permalink
Merge pull request #6705 from easy-mj/feature/mj-r-master-vmcontainer…
Browse files Browse the repository at this point in the history
…_terminal

feat: 容器主机支持终端
  • Loading branch information
easy-mj committed Jun 17, 2024
2 parents f08e9d4 + bba3fa3 commit fa7c1d7
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 11 deletions.
47 changes: 37 additions & 10 deletions containers/Compute/views/vminstance-container/constants/actions.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,53 @@
import { disableDeleteAction } from '@/utils/common/tableActions'
import i18n from '@/locales'
// import { POLICY_RES_NAME_KEY_MAP } from '@/constants/policy'

const getSingleActions = function () {
return [
// 同步状态
// 终端
{
label: i18n.t('compute.perform_sync_status'),
action: (obj) => {
this.onManager('batchPerformAction', {
steadyStatus: ['running', 'ready'],
id: [obj.id],
managerArgs: {
action: 'syncstatus',
},
label: i18n.t('compute.repo.terminal'),
actions: (obj) => {
const containers = obj.containers || []
return containers.map(item => {
return {
label: item.name,
action: async () => {
const connectRes = await this.fetchConnectUrl(item.id)
this.openWebConsole(connectRes)
},
}
})
},
meta: (obj) => {
const ret = { validate: true }
if (!obj.containers?.length) {
ret.validate = false
return ret
}
if (obj.status !== 'running') {
ret.tooltip = this.$t('compute.repo.helper.terminal', [this.$t('compute.vminstance-container')])
ret.validate = false
}
return ret
},
},
{
label: i18n.t('compute.text_352'),
actions: (obj) => {
return [
// 同步状态
{
label: i18n.t('compute.repo.terminal'),
action: (obj) => {
this.onManager('batchPerformAction', {
steadyStatus: ['running', 'ready'],
id: [obj.id],
managerArgs: {
action: 'syncstatus',
},
})
},
},
// 开机
{
label: i18n.t('compute.text_272'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,18 @@ export default {
created () {
this.singleActions = Actions.getSingleActions.call(this)
},
methods: {},
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)
},
},
}

0 comments on commit fa7c1d7

Please sign in to comment.