feat: 支持暂停会话操作

This commit is contained in:
Eric
2023-08-01 14:32:57 +08:00
committed by Bryan
parent fc1aefbb54
commit 0f6fd0ed70
7 changed files with 92 additions and 19 deletions

View File

@@ -8,24 +8,11 @@ export function terminateSession(data) {
})
}
export function getSessionDetail(id) {
export function toggleLockSession(data) {
return request({
url: `/api/v1/terminal/sessions/${id}/`,
method: 'get'
})
}
export function getSessionCommands(id) {
return request({
url: `/api/v1/terminal/commands/?session_id=${id}`,
method: 'get'
})
}
export function getTerminalDetail(id) {
return request({
url: `/api/v1/terminal/terminals/${id}/`,
method: 'get'
url: '/api/v1/terminal/tasks/toggle-lock-session/',
method: 'post',
data: data
})
}

View File

@@ -1484,6 +1484,8 @@
"terminalUpdate": "Update terminal",
"terminalUpdateStorage": "Update terminal storage",
"terminate": "Terminate",
"resume": "Resume",
"pause": "Pause",
"sessionTerminate": "Session Terminate",
"test": "Test",
"type": "Type",
@@ -1499,6 +1501,8 @@
"RazorNotSupport": "RDP Client session not support now",
"sessionMonitor": "Session Monitor",
"TerminateTaskSendSuccessMsg": "Terminate task has been send, Please check later",
"PauseTaskSendSuccessMsg": "Pause task has been send, Please check later",
"ResumeTaskSendSuccessMsg": "Resume task has been send, Please check later",
"helpText": {
"esUrl": "Tip: If you have multiple hosts, use comma (, ) to split (eg: http://www.jumpserver.a.com, http://www.jumpserver.b.com)",
"esIndex": "Es provides the default index: jumpserver. If you choose to build an index by date, this blank is the index prefix",

View File

@@ -1479,6 +1479,8 @@
"terminalUpdate": "端末の更新",
"terminalUpdateStorage": "端末ストレージの更新",
"terminate": "終断",
"resume": "再開",
"pause": "一時停止",
"sessionTerminate": "会話が終わる",
"test": "テスト",
"type": "タイプ",
@@ -1494,6 +1496,8 @@
"RazorNotSupport": "RDPクライアントセッションは、監視をサポートしていません",
"sessionMonitor": "モニタリング",
"TerminateTaskSendSuccessMsg": "最終タスクが発行されました。後で更新して確認してください。",
"PauseTaskSendSuccessMsg": "一時停止タスクが発行されました。後で更新して確認してください。",
"ResumeTaskSendSuccessMsg": "再開タスクが発行されました。後で更新して確認してください。",
"helpText": {
"esUrl": "ヒント: 複数のホストがある場合は、カンマ ( , ) で分割します。 (Eg: http://www.jumpserver.a.com:3000、http://www.jumpserver.b.com:3000)",
"esIndex": "Esはデフォルトindexを提供します。日付による索引の作成を選択した場合、この空は索引接頭辞です。",

View File

@@ -1468,6 +1468,8 @@
"terminalUpdate": "更新终端",
"terminalUpdateStorage": "更新终端存储",
"terminate": "终断",
"resume": "恢复",
"pause": "暂停",
"sessionTerminate": "会话终断",
"test": "测试",
"type": "类型",
@@ -1483,6 +1485,8 @@
"RazorNotSupport": "RDP 客户端会话, 暂不支持监控",
"sessionMonitor": "监控",
"TerminateTaskSendSuccessMsg": "终断任务已下发,请稍后刷新查看",
"PauseTaskSendSuccessMsg": "暂停任务已下发,请稍后刷新查看",
"ResumeTaskSendSuccessMsg": "恢复任务已下发,请稍后刷新查看",
"helpText": {
"esUrl": "提示:如果有多台主机,请使用逗号 ( , ) 进行分割。eg: http://www.jumpserver.a.com:3000,http://www.jumpserver.b.com:3000",
"esIndex": "es 提供默认 indexjumpserver。如果开启按日期建立索引那么输入的值会作为索引前缀",

View File

@@ -32,7 +32,8 @@ export default {
min: ['id', 'actions'],
default: [
'id', 'user', 'asset', 'account', 'remote_addr', 'protocol', 'login_from',
'command_amount', 'date_start', 'duration', 'terminal_display', 'actions'
'command_amount', 'date_start', 'duration', 'terminal_display', 'actions',
'is_locked'
]
},
columnsMeta: {

View File

@@ -4,7 +4,7 @@
<script>
import BaseList from './BaseList'
import { terminateSession } from '@/api/sessions'
import { terminateSession, toggleLockSession } from '@/api/sessions'
export default {
name: 'OnlineList',
components: {
@@ -33,6 +33,47 @@ export default {
)
}
},
{
name: 'pause',
title: this.$t('sessions.pause'),
type: 'warning',
can: ({ row }) => row['can_join'] && vm.$hasPerm('terminal.terminate_session'),
has: ({ row }) => !row['is_locked'],
callback: function({ reload, row }) {
const data = {
'session_id': row.id,
'task_name': 'lock_session'
}
toggleLockSession(data).then(res => {
const msg = vm.$t('sessions.PauseTaskSendSuccessMsg')
this.$message.success(msg)
window.setTimeout(function() {
reload()
}, 50000)
}
)
}
},
{
name: 'resume',
title: this.$t('sessions.resume'),
type: 'warning',
can: ({ row }) => row['can_join'] && vm.$hasPerm('terminal.terminate_session'),
has: ({ row }) => row['is_locked'],
callback: function({ reload, row }) {
const data = {
'session_id': row.id,
'task_name': 'unlock_session'
}
toggleLockSession(data).then(res => {
const msg = vm.$t('sessions.ResumeTaskSendSuccessMsg')
this.$message.success(msg)
window.setTimeout(function() {
reload()
}, 50000)
})
}
},
{
name: 'join',
title: this.$t('sessions.Monitor'),

View File

@@ -42,6 +42,19 @@
>
{{ $t('sessions.terminate') }}
</el-button>
<el-button
type="warning"
size="small"
:disabled="!session.can_join"
@click="onToggleLock"
>
<template v-if="session.is_locked">
{{ $t('sessions.resume') }}
</template>
<template v-else>
{{ $t('sessions.pause') }}
</template>
</el-button>
<el-button
type="primary"
size="small"
@@ -117,6 +130,25 @@ export default {
onMonitor() {
const joinUrl = `/luna/monitor/${this.session.id}`
window.open(joinUrl, 'height=600, width=800, top=400, left=400, toolbar=no, menubar=no, scrollbars=no, location=no, status=no')
},
onToggleLock() {
const url = '/api/v1/terminal/tasks/toggle-lock-session-for-ticket/'
const task_name = this.session.is_locked ? 'unlock_session' : 'lock_session'
const data = {
'session_id': this.session.id,
'task_name': task_name
}
const resumeMsg = this.$tc('sessions.ResumeTaskSendSuccessMsg')
const pauseMsg = this.$tc('sessions.PauseTaskSendSuccessMsg')
const msg = this.session.is_locked ? resumeMsg : pauseMsg
this.$axios.post(url, data).then(res => {
this.$message.success(msg)
this.curTimer = setTimeout(() => {
this.init()
}, 50000)
}).catch(err => {
this.$message.error(err)
})
}
}