This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nezha-nezha-fronted/nezha-fronted/src/components/page/config/terminalLog.vue

144 lines
4.3 KiB
Vue
Raw Normal View History

<template>
2021-04-13 20:33:12 +08:00
<div>
<nz-data-list
ref="dataList"
2021-04-13 20:33:12 +08:00
:api="url"
:layout="['searchInput', 'elementSet']"
:custom-table-title.sync="tools.customTableTitle"
2021-04-09 10:25:11 +08:00
:from="fromRoute.terminalLog"
@search="search"
2021-04-13 20:33:12 +08:00
:search-msg="searchMsg">
<template v-slot:default="slotProps">
2021-04-13 20:33:12 +08:00
<terminal-log-table
ref="dataTable"
2021-05-18 19:18:14 +08:00
v-loading="tools.loading"
2021-04-13 20:33:12 +08:00
:api="url"
:custom-table-title="tools.customTableTitle"
:height="mainTableHeight"
2021-04-13 20:33:12 +08:00
:now-time="nowTime"
:table-data="tableData"
@del="del"
@edit="edit"
@orderBy="tableDataSort"
@reload="getTableData"
@shutdown="shutdown"
2021-04-13 20:33:12 +08:00
@selectionChange="selectionChange"
@showBottomBox="(targetTab, object) => { $refs.dataList.showBottomBox(targetTab, object) }"></terminal-log-table>
</template>
<!-- 分页组件 -->
<template v-slot:pagination>
<Pagination ref="Pagination" :pageObj="pageObj" :tableId="tableId" @pageNo='pageNo' @pageSize='pageSize'></Pagination>
</template>
</nz-data-list>
</div>
</template>
<script>
import nzDataList from '@/components/common/table/nzDataList'
2021-04-13 20:33:12 +08:00
import dataListMixin from '@/components/common/mixin/dataList'
import terminalLogTable from '@/components/common/table/settings/terminalLogTable'
export default {
name: 'terminalLog',
components: {
2021-04-13 20:33:12 +08:00
nzDataList,
terminalLogTable
},
2021-04-13 20:33:12 +08:00
mixins: [dataListMixin],
data () {
return {
2021-04-13 20:33:12 +08:00
url: 'terminal/session',
tableId: 'terminalLogTable', // 需要分页的table的id用于记录每页数量
searchMsg: { // 给搜索框子组件传递的信息
searchLabelList: [
{
id: 11,
name: this.$t('config.terminallog.loginHost'),
type: 'input',
label: 'host',
disabled: false
}, {
id: 12,
name: this.$t('config.terminallog.loginUser'),
type: 'input',
label: 'loginUser',
disabled: false
}, {
id: 13,
name: this.$t('config.terminallog.sourceIp'),
type: 'input',
2021-05-20 17:59:15 +08:00
label: 'host',
disabled: false
}, {
id: 14,
name: this.$t('config.terminallog.sourceUser'),
type: 'input',
label: 'username',
disabled: false
}, {
id: 15,
name: this.$t('config.terminallog.uuid'),
type: 'input',
label: 'uuid',
disabled: false
}, {
id: 16,
name: this.$t('config.terminallog.protocol'),
type: 'selectString',
label: 'protocol',
disabled: false
}, {
id: 17,
name: this.$t('config.terminallog.status'),
type: 'terminalStatus',
label: 'state',
disabled: false
}
]
},
nowTime: ''
}
},
methods: {
getTableData () {
const params = {
...this.searchLabel,
pageNo: this.pageObj.pageNo,
pageSize: this.pageObj.pageSize
}
2021-05-19 11:32:41 +08:00
this.tools.loading = true
2021-04-13 20:33:12 +08:00
this.$get(this.url, params).then(response => {
this.tools.loading = false
if (response.code === 200) {
this.tableData = response.data.list
this.nowTime = this.utcTimeToTimezoneStr(response.time)
this.pageObj.total = response.data.total
if (!this.scrollbarWrap) {
this.$nextTick(() => {
2021-04-13 20:33:12 +08:00
this.scrollbarWrap = this.$refs.dataTable.$refs.dataTable.bodyWrapper
this.toTopBtnHandler(this.scrollbarWrap)
})
}
}
})
},
shutdown (record) {
this.$confirm(this.$t('tip.killTerm'), {
confirmButtonText: this.$t('tip.yes'),
cancelButtonText: this.$t('tip.no'),
type: 'warning'
}).then(() => {
this.$put('/terminal/kill', { uuid: record.uuid }).then(res => {
if (res.code === 200) {
this.$message.success(this.$t('config.terminallog.success'))
this.$refs.dataList.bottomBox.showSubList = false
this.getTableData()
} else {
this.$message.error(this.$t('config.terminallog.killErrorTip'))
}
})
})
}
}
}
</script>