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

343 lines
10 KiB
Vue
Raw Normal View History

<template>
2021-04-13 20:33:12 +08:00
<div>
2021-10-21 14:04:07 +08:00
<nzDetailView
v-loading="detailViewLoading || tools.loading"
v-if="detailType !== 'list'"
:api="url"
ref="detailList"
:layout="['searchInput', 'elementSet', 'pagination','detailViewSet']"
:from="fromRoute.terminalLog"
:search-msg="searchMsg"
:detailType="detailType"
:detailViewRightObj="detailViewRightObj"
:dataLength="tableData.length"
@search="search"
@changeDetailType="changeDetailType"
>
<template v-slot:top-tool-left>
<!-- <detailViewTopSearch :selectValue.sync="selectValue" :detailSearchList="detailSearchList" @reload="reloadTable" />-->
</template>
<template v-slot:top-tool-right>
</template>
<template v-slot:nz-detail-view-list>
<terminalLogDetail
class="data-detail"
ref="dataDetail"
:orderByFa="orderBy"
v-loading="tools.loading"
:loading="tools.loading"
2021-10-21 14:04:07 +08:00
:detailViewRightObj="detailViewRightObj"
:api="url"
:table-data="tableData"
@detailViewRightShow = 'detailViewRightShow'
@orderDetail="orderDetail"
>
</terminalLogDetail>
</template>
<!-- 分页组件 -->
<template v-slot:pagination>
<el-pagination
@current-change="pageNo"
:current-page.sync="pageObj.pageNo"
:page-size="20"
:total="pageObj.total"
layout="prev, slot, next"
small
>
<template>
<el-input-number ref="jumpInput" v-model="pageObj.pageNo" :controls="false" :min="1" :max="pageObj.pages" class="jump-input" @change="getTableData" @keyup.enter.native="getTableData" size="mini"/>
<span class="jump-pages">/&nbsp{{pageObj.pages}}</span>
</template>
</el-pagination>
</template>
</nzDetailView>
<nz-data-list
ref="dataList"
2021-04-13 20:33:12 +08:00
:api="url"
2021-10-21 14:04:07 +08:00
v-show="detailType === 'list'"
:layout="['searchInput', 'elementSet', 'pagination','detailViewSet']"
:custom-table-title.sync="tools.customTableTitle"
2021-04-09 10:25:11 +08:00
:from="fromRoute.terminalLog"
@search="search"
2021-10-21 14:04:07 +08:00
:search-msg="searchMsg"
:detailType="detailType"
@changeDetailType="changeDetailType"
@getTableData="getTableData"
>
<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-10-22 17:47:42 +08:00
: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"
:terminalLog="true"
2021-04-13 20:33:12 +08:00
@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'
2021-10-21 14:04:07 +08:00
import nzDetailView from '@/components/common/detailView/nzDetailView'
import detailViewMixin from '@/components/common/mixin/detailViewMixin'
import terminalLogDetail from '@/components/common/detailView/list/terminalLogDetail/terminalLogDetail'
import detailViewTopSearch from '@/components/common/detailView/detailViewTopSearch'
import routerPathParams from '@/components/common/mixin/routerPathParams'
export default {
name: 'terminalLog',
components: {
2021-04-13 20:33:12 +08:00
nzDataList,
2021-10-21 14:04:07 +08:00
terminalLogTable,
nzDetailView,
terminalLogDetail,
detailViewTopSearch
},
mixins: [dataListMixin, detailViewMixin, routerPathParams],
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-24 11:21:04 +08:00
label: 'remoteAddr',
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',
readonly: true,
disabled: false
}, {
id: 17,
name: this.$t('config.terminallog.status'),
type: 'terminalStatus',
label: 'state',
readonly: true,
disabled: false
}
]
},
nowTime: ''
}
},
methods: {
getTableData () {
if (this.orderBy) {
this.$set(this.searchLabel, 'orderBy', this.orderBy)
}
const params = {
...this.searchLabel,
pageNo: this.pageObj.pageNo,
pageSize: this.pageObj.pageSize
}
2021-05-19 11:32:41 +08:00
this.tools.loading = true
const path = this.fromRoute.terminalLog
this.updatePath(params, path)
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)
const globalSearchId = this.$store.getters.getGlobalSearchId
let detailViewRightObj = ''
if (globalSearchId) {
detailViewRightObj = this.tableData.find(item => item.id === globalSearchId)
} else {
detailViewRightObj = this.tableData[0]
}
this.detailViewRightObj = detailViewRightObj
this.pageObj.total = response.data.total
2021-10-21 14:04:07 +08:00
this.pageObj.pages = response.data.pages
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'))
}
})
})
}
},
created () {
const searchKeys = {
// key: path 键
// value: vue set 参数
pageNo: { target: this.pageObj, propertyName: 'pageNo', type: 'number' },
pageSize: { target: this.pageObj, propertyName: 'pageSize', type: 'number' },
orderBy: { target: this.$data, propertyName: 'orderBy', type: 'string' },
host: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'host',
type: 'string',
defaultJson: {
disabled: false,
id: 11,
label: 'host',
name: 'Login host',
type: 'input',
val: ''
},
jsonKey: 'val'
},
username: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'username',
type: 'string',
defaultJson: {
disabled: false,
id: 14,
label: 'username',
name: 'Source user',
type: 'input',
val: ''
},
jsonKey: 'val'
},
loginUser: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'loginUser',
type: 'string',
defaultJson: {
disabled: false,
id: 12,
label: 'loginUser',
name: 'Login user',
type: 'input',
val: ''
},
jsonKey: 'val'
},
remoteAddr: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'remoteAddr',
type: 'string',
defaultJson: {
disabled: false,
id: 13,
label: 'remoteAddr',
name: 'Source IP',
type: 'input',
val: ''
},
jsonKey: 'val'
},
uuid: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'uuid',
type: 'string',
defaultJson: {
disabled: false,
id: 15,
label: 'uuid',
name: 'UUID',
type: 'input',
val: ''
},
jsonKey: 'val'
},
protocol: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'protocol',
type: 'string',
defaultJson: {
disabled: false,
id: 16,
label: 'protocol',
name: 'Protocol',
readonly: true,
type: 'selectString',
val: ''
},
jsonKey: 'val'
},
state: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'state',
type: 'number',
defaultJson: {
disabled: false,
id: 17,
label: 'state',
name: 'State',
readonly: true,
type: 'terminalStatus',
val: ''
},
jsonKey: 'val'
}
}
this.initQueryFromPath(searchKeys)
}
}
</script>