Skip to content

Commit

Permalink
fix: 修复会话详情中播放bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuler committed Jun 18, 2021
1 parent c378b2b commit 383a799
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 172 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import ListTable from '@/components/ListTable'
import { OutputExpandFormatter } from '../formatters'
import { toSafeLocalDateStr } from '@/utils/common'
export default {
name: 'SessionCommandList',
name: 'SessionCommands',
components: {
ListTable
},
Expand Down
159 changes: 0 additions & 159 deletions src/views/sessions/SessionDetail/SessionDetailCard.vue

This file was deleted.

158 changes: 158 additions & 0 deletions src/views/sessions/SessionDetail/SessionDetailInfo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<template>
<el-row :gutter="20">
<el-col :span="14">
<DetailCard v-if="object" :items="detailItems" />
</el-col>
<el-col :span="10">
<QuickActions v-if="object" type="primary" :actions="quickActions" />
</el-col>
</el-row>
</template>

<script>
import DetailCard from '@/components/DetailCard/index'
import QuickActions from '@/components/QuickActions'
import { terminateSession } from '@/api/sessions'
import { toSafeLocalDateStr } from '@/utils/common'
export default {
name: 'SessionDetailInfo',
components: {
DetailCard,
QuickActions
},
props: {
object: {
type: Object,
default: null
}
},
data() {
return {
session: this.object
}
},
computed: {
onlineSessionActions() {
const vm = this
return [
{
title: this.$t('sessions.sessionTerminate'),
attrs: {
type: 'danger',
label: this.$t('sessions.terminate'),
disabled: !this.session['can_terminate']
},
callbacks: {
click: function() {
// 终断 session reload
terminateSession(vm.session.id).then(res => {
const msg = vm.$t('sessions.TerminateTaskSendSuccessMsg')
vm.$message.success(msg)
window.setTimeout(function() {
window.location.reload()
}, 50000)
})
}
}
},
{
title: this.$t('sessions.sessionMonitor'),
attrs: {
type: 'primary',
label: this.$t('sessions.Monitor'),
disabled: !this.session['can_join']
},
callbacks: {
click: function() {
// 跳转到luna页面
const joinUrl = '/luna/monitor/' + vm.session.id
window.open(joinUrl, 'height=600, width=800, top=400, left=400, toolbar=no, menubar=no, scrollbars=no, location=no, status=no')
}
}
}
]
},
offlineSessionActions() {
const vm = this
return [
{
title: this.$t('sessions.replaySession'),
attrs: {
type: 'primary',
label: this.$t('sessions.replay'),
disabled: !this.session['can_replay']
},
callbacks: {
click: function() {
const replayUrl = '/luna/replay/' + vm.session.id
window.open(replayUrl)
}
}
},
{
title: this.$t('sessions.downloadReplay'),
attrs: {
type: 'primary',
label: this.$t('sessions.download'),
disabled: !this.session['can_replay']
},
callbacks: {
click: function() {
const downloadUrl = `/api/v1/terminal/sessions/${vm.session.id}/replay/download/`
window.open(downloadUrl)
}
}
}
]
},
detailItems() {
return [
{
key: this.$t('sessions.user'),
value: this.session.user
},
{
key: this.$t('sessions.asset'),
value: this.session.asset
},
{
key: this.$t('sessions.systemUser'),
value: this.session.system_user
},
{
key: this.$t('sessions.protocol'),
value: this.session.protocol
},
{
key: this.$t('sessions.loginFrom'),
value: this.session.login_from
},
{
key: this.$t('sessions.remoteAddr'),
value: this.session.remote_addr
},
{
key: this.$t('sessions.dateStart'),
value: toSafeLocalDateStr(this.session.date_start)
},
{
key: this.$t('sessions.dateEnd'),
value: this.session.date_end ? toSafeLocalDateStr(this.session.date_end) : ''
}
]
},
quickActions() {
const vm = this
if (vm.session.is_finished) {
return this.offlineSessionActions
} else {
return this.onlineSessionActions
}
}
}
}
</script>

<style scoped>
</style>
14 changes: 7 additions & 7 deletions src/views/sessions/SessionDetail/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@

<script>
import { GenericDetailPage } from '@/layout/components'
import SessionCommandList from './SessionCommandList'
import SessionDetailCard from './SessionDetailCard'
import SessionCommands from './SessionCommands'
import SessionDetailInfo from './SessionDetailInfo'
export default {
name: 'SessionDetail',
components: {
GenericDetailPage,
SessionCommandList,
SessionDetailCard
SessionCommands,
SessionDetailInfo
},
data() {
return {
sessionData: {},
activeSubMenu: 'SessionDetailCard',
activeSubMenu: 'SessionDetailInfo',
submenu: [
{
title: this.$t('route.SessionDetail'),
name: 'SessionDetailCard'
name: 'SessionDetailInfo'
},
{
title: this.$t('sessions.command'),
name: 'SessionCommandList'
name: 'SessionCommands'
}
]
}
Expand Down
4 changes: 2 additions & 2 deletions src/views/sessions/SessionList/OfflineList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default {
title: this.$t('sessions.replay'),
type: 'warning',
can: ({ row, cellValue }) => {
return row.can_replay
return row['can_replay']
},
callback: function({ row, tableData }) {
// 跳转到luna页面
Expand All @@ -31,7 +31,7 @@ export default {
title: this.$t('sessions.download'),
type: 'primary',
can: ({ row, cellValue }) => {
return row.can_replay
return row['can_replay']
},
callback: function({ row, tableData }) {
// 跳转下载页面
Expand Down
Loading

0 comments on commit 383a799

Please sign in to comment.