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/common/bottomBox/bottomBox.vue

306 lines
17 KiB
Vue
Raw Normal View History

2020-03-27 15:41:26 +08:00
<template>
<div class="sub-box bottom-box" :style="{height: isFullScreen ? '100%' : ''}">
<div class="resize-modal">
<div class="sub-list-resize-copy"></div>
</div>
<!-- 副列表 -->
<div @mousedown="listResize" class="sub-list-resize" v-if="!isFullScreen"></div>
<div class="sub-list">
<!--窗口大小控制-->
2020-03-27 15:41:26 +08:00
<div class="sub-list-window-control">
<!--退出全屏-->
2021-02-04 11:21:00 +08:00
<div class="window-control-btn" v-if="isFullScreen" @click="exitFullScreen" :id="from+'-bottom-exit-full'"><i class="nz-icon nz-icon-exit-full-screen" ></i></div>
2020-03-27 15:41:26 +08:00
<!--全屏-->
2021-04-14 18:35:42 +08:00
<div v-if="!isFullScreen" :id="from+'-bottom-full'" class="window-control-btn" @click="fullScreen"><i class="nz-icon nz-icon-full-screen"></i></div>
2020-03-27 15:41:26 +08:00
<!--关闭-->
2021-02-04 11:21:00 +08:00
<div class="window-control-btn" @click="closeSubList" :id="from+'-bottom-close'"><i class="nz-icon nz-icon-close"></i></div>
2020-03-27 15:41:26 +08:00
</div>
2021-04-14 18:35:42 +08:00
<!------TAB区------>
<div class="sub-list__tabs">
<!--机柜-->
<cabinet-tab v-if="from === fromRoute.dc && targetTab === 'cabinet'" :tabs="tabs.dc.cabinet" v-show="subResizeShow" :obj="obj" @changeTab="changeTab" :targetTab.sync="targetTab"></cabinet-tab>
<alertMessageTabNew v-if="from === fromRoute.dc && targetTab === 'alertMessageTab'" v-show="subResizeShow" :from="from" :obj="obj" :tabs="tabs.dc.alertMessage" @changeTab="changeTab" :targetTab.sync="targetTab"></alertMessageTabNew>
2021-04-14 18:35:42 +08:00
<!--告警信息-->
<alert-message-tab v-if="((from === fromRoute.alertRule || from === fromRoute.asset || from === fromRoute.endpoint || from === fromRoute.project ) && targetTab === 'alertMessage')" v-show="subResizeShow" :from="from" :obj="obj" @changeTab="changeTab" :targetTab.sync="targetTab"></alert-message-tab>
2021-04-14 18:35:42 +08:00
<!--asset页的endpoint列表-->
<endpoint-tab v-if="from === fromRoute.asset && targetTab === fromRoute.endpoint" v-show="subResizeShow" :from="from" :obj="obj" @changeTab="changeTab" :targetTab.sync="targetTab"></endpoint-tab>
2021-04-14 18:35:42 +08:00
<!--terminal-log的记录和回放-->
<terminal-log-cmd-tab v-if="from === fromRoute.terminalLog && targetTab === 'cmdTab'" :from="from" :obj="obj" :tabs="tabs.terminalLog.cmd" @changeTab="changeTab" :targetTab.sync="targetTab"></terminal-log-cmd-tab>
<terminal-log-record-tab v-if="from === fromRoute.terminalLog && targetTab === 'recordTab'" :from="from" :obj="obj" :tabs="tabs.terminalLog.record" @changeTab="changeTab" :targetTab.sync="targetTab"></terminal-log-record-tab>
<terminal-log-monitor-tab v-if="from === fromRoute.terminalLog && targetTab === 'monitorTab'" :from="from" :obj="obj" :tabs="tabs.terminalLog.monitor" @changeTab="changeTab" @exit="closeSubList" :targetTab.sync="targetTab"></terminal-log-monitor-tab>
2021-03-04 16:11:11 +08:00
<asset-tab v-if="from === fromRoute.dc && targetTab === 'asset'" :tabs="tabs.dc.asset" ref="assetTab" :from="from" :obj="obj" @changeTab="changeTab" @exit="closeSubList" :targetTab.sync="targetTab"></asset-tab>
2021-04-14 18:35:42 +08:00
<!--user列表的两个日志-->
<operation-log-tab v-if="from === fromRoute.user && targetTab === 'operationLogTab'" :from="from" :obj="obj" :tabs="tabs.user.operationLog" @changeTab="changeTab" :targetTab.sync="targetTab"></operation-log-tab>
<terminal-log-tab v-if="from === fromRoute.user && targetTab === 'terminalLogTab'" :from="from" :obj="obj" :tabs="tabs.user.terminalLog" @changeTab="changeTab" :targetTab.sync="targetTab"></terminal-log-tab>
2021-04-26 21:42:15 +08:00
<!-- asset列表的3个 -->
<panel-tab-new @getTableData="getTableData" :paramsType="'asset'" v-if="from === fromRoute.asset && targetTab === 'panelTab'" v-show="subResizeShow" :from="from" :obj="obj" :tabs="tabs.asset.panel" :targetTab.sync="targetTab" @changeTab="changeTab"></panel-tab-new>
<alertMessageTabNew v-if="from === fromRoute.asset && targetTab === 'alertMessageTab'" v-show="subResizeShow" :from="from" :obj="obj" :tabs="tabs.asset.alertMessage" :targetTab.sync="targetTab" @changeTab="changeTab" ></alertMessageTabNew>
<endpointTabNew v-if="from === fromRoute.asset && targetTab === 'endpointTab'" v-show="subResizeShow" :from="from" :obj="obj" :tabs="tabs.asset.endpoint" :targetTab.sync="targetTab" @changeTab="changeTab"></endpointTabNew>
2021-08-05 22:31:36 +08:00
<log-bottom-tab v-if="from === fromRoute.asset && targetTab === 'log'" v-show="subResizeShow" :from="from" :obj="obj" :tabs="tabs.asset.log" :targetTab.sync="targetTab" @changeTab="changeTab"></log-bottom-tab>
<assetSubTab v-if="from === fromRoute.asset && targetTab === 'assetSubTab' && obj.childrenNum" v-show="subResizeShow" :from="from" :obj="obj" :tabs="tabs.asset.alertMessageSub" @changeTab="changeTab" :targetTab.sync="targetTab"></assetSubTab>
2021-04-20 15:31:57 +08:00
<!--module列表的tab-->
2021-04-26 21:42:15 +08:00
<endpointTabNew v-if="from === fromRoute.module && targetTab === 'endpoint'" v-show="subResizeShow" :from="from" :obj="obj" :tabs="tabs.module.moduleTabTitle" :targetTab="targetTab" @changeTab="changeTab"></endpointTabNew>
2021-04-20 15:31:57 +08:00
<alertMessageTabNew v-if="from === fromRoute.module && targetTab === 'moduleAlertMessage'" v-show="subResizeShow" :from="from" :obj="obj" :tabs="tabs.module.moduleTabTitle" @changeTab="changeTab" :targetTab="targetTab"></alertMessageTabNew>
<panel-tab-new @getTableData="getTableData" :paramsType="'module'" v-if="from === fromRoute.module && targetTab === 'panel'" v-show="subResizeShow" :from="from" :obj="obj" :tabs="tabs.module.moduleTabTitle" :targetTab.sync="targetTab" @changeTab="changeTab"></panel-tab-new>
2021-04-20 15:31:57 +08:00
<!--endpoint列表的tab-->
<panel-tab-new v-if="from === fromRoute.endpoint && targetTab === 'panelTab'" v-show="subResizeShow" :from="from" :obj="obj" :paramsType="'endpoint'" :tabs="endpointTabs" :targetTab.sync="targetTab" @changeTab="changeTab" @getTableData="getTableData"></panel-tab-new>
<endpointQuery v-if="from === fromRoute.endpoint && targetTab === 'Metrics'" v-show="subResizeShow" :from="from" :obj="obj" :tabs="endpointTabs" :targetTab.sync="targetTab" @changeTab="changeTab"></endpointQuery>
<log-bottom-tab v-if="from === fromRoute.endpoint && targetTab === 'log' && hasLogConfig" v-show="subResizeShow" :from="from" :obj="obj" :tabs="endpointTabs" :targetTab.sync="targetTab" @changeTab="changeTab"></log-bottom-tab>
2021-11-02 18:34:00 +08:00
<alertMessageTabNew v-if="from === fromRoute.endpoint && targetTab === 'endpointAlertMessage'" v-show="subResizeShow" :from="from" :obj="obj" :tabs="endpointTabs" :targetTab.sync="targetTab" @changeTab="changeTab"></alertMessageTabNew>
<!--chartTemp的Tab-->
<panel-tab-new @getTableData="getTableData" :paramsType="'template'" v-if="from === fromRoute.chartTemp && targetTab === 'panel'" v-show="subResizeShow" :from="from" :obj="obj" :tabs="tabs.chartTemp.chartTempTabTitle" :targetTab.sync="targetTab" @changeTab="changeTab"></panel-tab-new>
<!--alertRule Tab-->
2021-11-02 18:34:00 +08:00
<alertMessageTabNew v-if="from === fromRoute.alertRule && targetTab === 'alertRuleAlertMessage'" v-show="subResizeShow" :from="from" :obj="obj" :tabs="tabs.alertRule.alertRule" @changeTab="changeTab" :targetTab.sync="targetTab"></alertMessageTabNew>
<alertRuleEvalLog v-if="from === fromRoute.alertRule && targetTab === 'evalLog'" v-show="subResizeShow" :from="from" :obj="obj" :tabs="tabs.alertRule.alertRule" @changeTab="changeTab" :targetTab.sync="targetTab"></alertRuleEvalLog>
<!--model 下滑-->
<asset-tab v-if="(from === fromRoute.model) && targetTab === 'asset'" :tabs="tabs.model" ref="assetTab" :from="from" :obj="obj" @changeTab="changeTab" @exit="closeSubList" :targetTab.sync="targetTab"></asset-tab>
<!-- agent 下滑-->
<scrape-endpoint v-if="from === fromRoute.agent && targetTab === 'agent'" :from="from" :obj="obj" :tabs="tabs.agent" @changeTab="changeTab" :targetTab.sync="targetTab"></scrape-endpoint>
2021-04-14 18:35:42 +08:00
</div>
2020-03-27 15:41:26 +08:00
</div>
</div>
2020-03-27 15:41:26 +08:00
</template>
<script>
2021-03-19 18:52:19 +08:00
import cabinetTab from './tabs/cabinetTab'
import alertMessageTab from './tabs/alertMessageTab'
2021-04-20 15:31:57 +08:00
import alertMessageTabNew from './tabs/alertMessageTabNew'
2021-11-02 18:34:00 +08:00
import alertRuleEvalLog from './tabs/alertRuleEvalLog'
2021-07-15 14:38:55 +08:00
import assetSubTab from './tabs/assetSubTab'
2021-04-20 19:27:49 +08:00
import endpointQuery from './tabs/endpointQuery'
2021-03-19 18:52:19 +08:00
import endpointTab from './tabs/endpointTab'
import endpointTabNew from './tabs/endpointTabNew'
import panelTabNew from './tabs/panelTabNew'
2021-03-19 18:52:19 +08:00
import terminalLogRecordTab from './tabs/terminalLogRecordTab'
import terminalLogMonitorTab from './tabs/terminalLogMonitorTab'
import terminalLogCMDTab from './tabs/terminalLogCMDTab'
import operationLogTab from './tabs/operationLogTab'
import terminalLogTab from './tabs/terminalLogTab'
import assetTab from '@/components/common/bottomBox/tabs/assetTab'
import { fromRoute } from '@/components/common/js/constants'
2021-08-05 22:25:55 +08:00
import LogBottomTab from '@/components/common/bottomBox/tabs/logBottomTab'
import scrapeEndpoint from '@/components/common/bottomBox/tabs/scrapeEndpoint'
2020-03-27 15:41:26 +08:00
2021-03-19 18:52:19 +08:00
export default {
name: 'bottomBox',
components: {
scrapeEndpoint,
2021-08-05 22:25:55 +08:00
LogBottomTab,
cabinetTab,
alertMessageTab,
endpointTab,
2021-03-19 18:52:19 +08:00
terminalLogRecordTab,
terminalLogMonitorTab,
operationLogTab,
terminalLogTab,
'terminal-log-cmd-tab': terminalLogCMDTab,
2021-04-20 15:31:57 +08:00
endpointTabNew,
2021-04-20 19:27:49 +08:00
alertMessageTabNew,
endpointQuery,
panelTabNew,
2021-07-15 14:38:55 +08:00
assetTab,
2021-11-02 18:34:00 +08:00
assetSubTab,
alertRuleEvalLog
2021-03-19 18:52:19 +08:00
},
props: {
isFullScreen: Boolean, // 是否全屏
subResizeShow: Boolean, // resize时用v-show="subResizeShow"控制页面内容是否显示
obj: Object, // 关联的实体对象
from: String, // 来自哪个页面
tabList: Array, // 动态页签列表
2021-07-15 14:38:55 +08:00
targetTab: String // 展示哪个页签
},
watch: {
obj: {
immediate: true,
handler (n) {
if ((this.from === fromRoute.asset) && n) {
const assetSub = { prop: 'assetSubTab', name: this.$t('overall.assetSubTab'), active: false }
2021-07-15 14:38:55 +08:00
if (n.childrenNum) {
if (!this.tabs.asset.panel.find(item => item.prop === assetSub.prop)) {
this.tabs.asset.panel.push(assetSub)
this.tabs.asset.alertMessage.push(assetSub)
this.tabs.asset.endpoint.push(assetSub)
2021-08-10 09:37:37 +08:00
this.tabs.asset.log.push(assetSub)
}
} else if (this.tabs.asset.panel.find(item => item.prop === assetSub.prop)) {
this.tabs.asset.panel = this.tabs.asset.panel.filter(item => item.prop !== assetSub.prop)
this.tabs.asset.alertMessage = this.tabs.asset.alertMessage.filter(item => item.prop !== assetSub.prop)
this.tabs.asset.endpoint = this.tabs.asset.endpoint.filter(item => item.prop !== assetSub.prop)
2021-08-10 09:37:37 +08:00
this.tabs.asset.log = this.tabs.asset.log.filter(item => item.prop !== assetSub.prop)
2021-07-15 14:38:55 +08:00
}
}
}
}
2021-03-19 18:52:19 +08:00
},
data () {
return {
2021-04-14 18:35:42 +08:00
fromRoute: fromRoute,
tabs: {
terminalLog: {
monitor: [
{ prop: 'monitorTab', name: this.$t('config.terminallog.monitor.monitor'), active: true }
],
cmd: [
{ prop: 'cmdTab', name: this.$t('config.terminallog.cmd.cmd'), active: true },
{ prop: 'recordTab', name: this.$t('config.terminallog.record.record'), active: false }
],
record: [
{ prop: 'cmdTab', name: this.$t('config.terminallog.cmd.cmd'), active: false },
{ prop: 'recordTab', name: this.$t('config.terminallog.record.record'), active: true }
]
},
2021-04-14 18:35:42 +08:00
user: {
operationLog: [
{ prop: 'operationLogTab', name: this.$t('config.operationlog.operationlog'), active: true },
{ prop: 'terminalLogTab', name: this.$t('config.terminallog.terminallog'), active: false }
],
terminalLog: [
{ prop: 'operationLogTab', name: this.$t('config.operationlog.operationlog'), active: false },
{ prop: 'terminalLogTab', name: this.$t('config.terminallog.terminallog'), active: true }
2021-04-20 15:31:57 +08:00
]
// module tab
},
2021-04-26 21:42:15 +08:00
asset: {
panel: [
{ prop: 'panelTab', name: this.$t('overall.detail'), active: true },
{ prop: 'alertMessageTab', name: this.$t('overall.alert'), active: false },
2021-08-05 22:31:36 +08:00
{ prop: 'endpointTab', name: 'Endpoint', active: false },
{ prop: 'log', name: 'Log', active: false }
2021-04-26 21:42:15 +08:00
],
alertMessage: [
{ prop: 'panelTab', name: this.$t('overall.detail'), active: false },
{ prop: 'alertMessageTab', name: this.$t('overall.alert'), active: true },
2021-08-05 22:31:36 +08:00
{ prop: 'endpointTab', name: 'Endpoint', active: false },
{ prop: 'log', name: 'Log', active: false }
2021-04-26 21:42:15 +08:00
],
endpoint: [
{ prop: 'panelTab', name: this.$t('overall.detail'), active: false },
{ prop: 'alertMessageTab', name: this.$t('overall.alert'), active: false },
2021-08-05 22:31:36 +08:00
{ prop: 'endpointTab', name: 'Endpoint', active: true },
{ prop: 'log', name: 'Log', active: false }
],
log: [
{ prop: 'panelTab', name: this.$t('overall.detail'), active: false },
{ prop: 'alertMessageTab', name: this.$t('overall.alert'), active: false },
{ prop: 'endpointTab', name: 'Endpoint', active: false },
{ prop: 'log', name: 'Log', active: true }
2021-07-15 14:38:55 +08:00
],
alertMessageSub: [
{ prop: 'panelTab', name: this.$t('overall.detail'), active: false },
{ prop: 'alertMessageTab', name: this.$t('overall.alert'), active: false },
{ prop: 'endpointTab', name: 'Endpoint', active: false },
2021-08-05 22:31:36 +08:00
{ prop: 'log', name: 'Log', active: false },
2021-07-15 14:38:55 +08:00
{ prop: 'assetSubTab', name: this.$t('overall.assetSubTab'), active: true }
2021-04-26 21:42:15 +08:00
]
},
2021-04-20 15:31:57 +08:00
module: {
moduleTabTitle: [
// { prop: 'panel', name: 'Detail' },
{ prop: 'endpoint', name: this.$t('asset.endpoint') },
{ prop: 'moduleAlertMessage', name: this.$t('overall.alert') }
2021-04-20 15:31:57 +08:00
]
},
endpoint: {
endpointTabTitle: [
2021-05-19 23:17:24 +08:00
{ prop: 'panelTab', name: this.$t('overall.detail') },
{ prop: 'endpointAlertMessage', name: this.$t('overall.alert') },
{ prop: 'Metrics', name: 'Metrics' },
2021-11-02 18:34:00 +08:00
{ prop: 'log', name: 'Log' }
2021-04-14 18:35:42 +08:00
]
},
chartTemp: {
chartTempTabTitle: [
{ prop: 'panel', name: this.$t('overall.tempPrev') }
]
},
alertRule: {
alertRule: [
2021-11-02 18:34:00 +08:00
{ prop: 'alertRuleAlertMessage', name: this.$t('overall.alert') },
{ prop: 'evalLog', name: this.$t('overall.alertRuleEvalLog') }
]
},
model: [
{ prop: 'asset', name: this.$t('asset.assets'), active: true }
],
dc: {
cabinet: [
{ prop: 'cabinet', name: this.$t('config.dc.cabinets'), active: true },
2021-05-08 09:40:53 +08:00
{ prop: 'asset', name: this.$t('asset.assets'), active: false },
{ prop: 'alertMessageTab', name: this.$t('overall.alert'), active: false }
],
asset: [
{ prop: 'cabinet', name: this.$t('config.dc.cabinets'), active: false },
2021-05-08 09:40:53 +08:00
{ prop: 'asset', name: this.$t('asset.assets'), active: true },
{ prop: 'alertMessageTab', name: this.$t('overall.alert'), active: false }
],
alertMessage: [
{ prop: 'cabinet', name: this.$t('config.dc.cabinets'), active: false },
{ prop: 'asset', name: this.$t('asset.assets'), active: false },
{ prop: 'alertMessageTab', name: this.$t('overall.alert'), active: true }
]
},
agent: [
{ prop: 'agent', name: this.$t('config.agent.scrapeEndpoint'), active: true }
]
2021-04-14 18:35:42 +08:00
}
}
2021-03-19 18:52:19 +08:00
},
computed: {
hasLogConfig () {
const config = this.obj.configs.find(c => c.type === 'logs')
return config && config.enable === 1
},
endpointTabs () {
const config = this.obj.configs.find(c => c.type === 'logs')
const hasLog = config && config.enable === 1
const tabs = [
{ prop: 'panelTab', name: this.$t('overall.detail') },
{ prop: 'endpointAlertMessage', name: this.$t('overall.alert') },
{ prop: 'Metrics', name: 'Metrics' }
]
if (hasLog) {
tabs.push({ prop: 'log', name: 'Log' })
}
return tabs
}
},
2021-03-19 18:52:19 +08:00
methods: {
exitFullScreen () {
this.$emit('exitFullScreen')
this.$nextTick(() => { this.afterResize() })
2020-03-27 15:41:26 +08:00
},
2021-03-19 18:52:19 +08:00
fullScreen () {
this.$emit('fullScreen')
this.$nextTick(() => { this.afterResize() })
2020-03-27 15:41:26 +08:00
},
2021-03-19 18:52:19 +08:00
closeSubList () {
this.$emit('closeSubList')
},
listResize (e) {
this.$emit('listResize', e)
this.$nextTick(() => { this.afterResize() })
},
2021-03-19 18:52:19 +08:00
changeTab (tab) {
this.$emit('update:targetTab', tab)
},
afterResize () {
if (this.from === this.fromRoute.endpoint && this.targetTab === 'endpointQuery') {
2021-03-19 18:52:19 +08:00
this.$refs.endpointQuery.tableReload()
} else if (this.from === this.fromRoute.terminalLog && this.targetTab === 'record') {
2021-03-19 18:52:19 +08:00
setTimeout(() => {
this.$refs.reminalLogRecordTab.consoleResize()
}, 600)
}
},
getTableData () {
this.$emit('getTableData')
2021-03-19 18:52:19 +08:00
}
2020-03-27 15:41:26 +08:00
}
2021-03-19 18:52:19 +08:00
}
2020-03-27 15:41:26 +08:00
</script>