fix: endpoint table调整

This commit is contained in:
zhangyu
2021-08-10 09:30:12 +08:00
parent 6f6df771b6
commit 0fb427fc00
4 changed files with 171 additions and 50 deletions

View File

@@ -13,6 +13,7 @@
> >
<template v-slot:default="slotProps"> <template v-slot:default="slotProps">
<endpoint-table <endpoint-table
style="height: calc(100% - 200px)"
ref="dataTable" ref="dataTable"
v-loading="tools.loading" v-loading="tools.loading"
:api="url" :api="url"
@@ -85,28 +86,26 @@ export default {
pageSize: this.$CONSTANTS.defaultPageSize, pageSize: this.$CONSTANTS.defaultPageSize,
total: 0 total: 0
}, },
mainTableHeight: '100%', mainTableHeight: 'calc(100% - 70px)',
tableTitle: [ tableTitle: [
{ {
label: this.$t('project.endpoint.endpointId'), label: this.$t('project.endpoint.endpointId'),
prop: 'id', prop: 'id',
show: true, show: true,
width: 150 width: 100
}, { }, {
label: this.$t('project.endpoint.asset'), label: this.$t('project.endpoint.asset'),
prop: 'asset', prop: 'asset',
show: true show: true,
width: 150
}, { }, {
label: this.$t('project.endpoint.port'), label: this.$t('project.endpoint.port'),
prop: 'port', prop: 'port',
show: true show: true
}, {
label: this.$t('project.endpoint.path'),
prop: 'path',
show: true
}, { }, {
label: this.$t('alert.list.state'), label: this.$t('alert.list.state'),
prop: 'state', prop: 'state',
width: 200,
show: true show: true
} }
], ],

View File

@@ -91,16 +91,22 @@
{{scope.row.module?scope.row.module.name : '' }} {{scope.row.module?scope.row.module.name : '' }}
</template> </template>
<template v-else-if="item.prop == 'configs'"> <template v-else-if="item.prop == 'configs'">
<el-tooltip placement="left" effect="light" :popper-class="'endpointConfigsTips'"> <!-- <el-tooltip placement="left" effect="light" :popper-class="'endpointConfigsTips'">-->
<span class="configs-endpoint metrics">{ Metrics }</span> <!-- <span class="configs-endpoint metrics">{ Metrics }</span>-->
<!-- <div class="endpointConfigsTips" slot="content">-->
<!-- <pre >{{JSON.stringify(scope.row.configs[0].config,null,2)}}</pre>-->
<!-- </div>-->
<!-- </el-tooltip>-->
<!-- <el-tooltip placement="right" effect="light" :popper-class="'endpointConfigsTips'">-->
<!-- <span class="configs-endpoint logs">{ Logs }</span>-->
<!-- <div class="endpointConfigsTips" slot="content">-->
<!-- <pre >{{JSON.stringify(scope.row.configs[1].config,null,2)}}</pre>-->
<!-- </div>-->
<!-- </el-tooltip>-->
<el-tooltip placement="left" effect="light" :popper-class="'endpointConfigsTips'" v-if="scope.row.configs[0].enable || scope.row.configs[1].enable">
<span class="configs-endpoint metrics">[{{scope.row.configs[0].enable ? 'Metrics':''}}{{scope.row.configs[0].enable&&scope.row.configs[1].enable?',':''}}{{scope.row.configs[1].enable ? 'logs' : ''}}]</span>
<div class="endpointConfigsTips" slot="content"> <div class="endpointConfigsTips" slot="content">
<pre >{{JSON.stringify(scope.row.configs[0].config,null,2)}}</pre> <pre >{{JSON.stringify(clConfigs(scope.row),null,2)}}</pre>
</div>
</el-tooltip>
<el-tooltip placement="right" effect="light" :popper-class="'endpointConfigsTips'">
<span class="configs-endpoint logs">{ Logs }</span>
<div class="endpointConfigsTips" slot="content">
<pre >{{JSON.stringify(scope.row.configs[1].config,null,2)}}</pre>
</div> </div>
</el-tooltip> </el-tooltip>
</template> </template>
@@ -274,7 +280,8 @@ export default {
{ {
label: this.$t('project.endpoint.configs'), label: this.$t('project.endpoint.configs'),
prop: 'configs', prop: 'configs',
show: true show: true,
width: 150
} }
] ]
} }
@@ -441,7 +448,16 @@ export default {
// this.object.chartIds = '' // this.object.chartIds = ''
// } // }
this.rightBox.show = true this.rightBox.show = true
this.rightBox.show = true },
clConfigs (item) {
const str = []
if (item.configs[0].enable) {
str.push(item.configs[0])
}
if (item.configs[1].enable) {
str.push(item.configs[1])
}
return str
} }
}, },
created () { created () {

View File

@@ -42,11 +42,35 @@
{{scope.row.module.type}} {{scope.row.module.type}}
</template> </template>
<template v-else-if="item.prop === 'project'"> <template v-else-if="item.prop === 'project'">
<span
class="pointer"
@mouseenter="labelHover(scope.row, item.prop, true, $event)"
@mouseleave="labelHover(scope.row, item.prop, false)"
>
{{scope.row[item.prop].name}} {{scope.row[item.prop].name}}
</span>
<alertLabel
v-if="scope.row[item.prop] && scope.row[item.prop].loading"
:id="scope.row[item.prop].id"
:that="scope.row[item.prop]"
:type="'project'"
></alertLabel>
</template> </template>
<template v-else-if="item.prop === 'module'"> <template v-else-if="item.prop === 'module'">
<span
class="pointer"
@mouseenter="labelHover(scope.row, item.prop, true, $event)"
@mouseleave="labelHover(scope.row, item.prop, false)"
>
<i style="cursor: pointer" class="nz-icon nz-icon-overview-module monitorColor"/> <i style="cursor: pointer" class="nz-icon nz-icon-overview-module monitorColor"/>
{{scope.row[item.prop].name}} {{scope.row[item.prop].name}}
</span>
<alertLabel
v-if="scope.row[item.prop] && scope.row[item.prop].loading"
:id="scope.row[item.prop].id"
:that="scope.row[item.prop]"
:type="'module'"
></alertLabel>
</template> </template>
<template v-else-if="item.prop === 'alerts'"> <template v-else-if="item.prop === 'alerts'">
<span class="alert-num" @click="showBottomBox('endpointAlertMessage', scope.row)"> <span class="alert-num" @click="showBottomBox('endpointAlertMessage', scope.row)">
@@ -55,43 +79,74 @@
</span> </span>
</template> </template>
<template v-else-if="item.prop === 'asset'"> <template v-else-if="item.prop === 'asset'">
<span > <span
class="pointer"
@mouseenter="labelHover(scope.row, item.prop, true, $event)"
@mouseleave="labelHover(scope.row, item.prop, false)"
>
<i class="nz-icon nz-icon-overview-project monitorColor color23BF9A"></i>
{{scope.row.asset.name}} {{scope.row.asset.name}}
</span> </span>
<alertLabel
v-if="scope.row[item.prop] && scope.row[item.prop].loading"
:id="scope.row[item.prop].id"
:that="scope.row[item.prop]"
:type="'asset'"
></alertLabel>
</template> </template>
<template v-else-if="item.prop === 'configs'"> <template v-else-if="item.prop === 'configs'">
<el-tooltip placement="left" effect="light" :popper-class="'endpointConfigsTips'" v-if="scope.row.configs[0].enable"> <!-- <el-tooltip placement="left" effect="light" :popper-class="'endpointConfigsTips'" v-if="scope.row.configs[0].enable">-->
<span class="configs-endpoint metrics">{ Metrics }</span> <!-- <span class="configs-endpoint metrics">{ Metrics }</span>-->
<!-- <div class="endpointConfigsTips" slot="content">-->
<!-- <span class="copy-value-content"> <i class="nz-icon nz-icon-override" @click="copyValue(scope.row.configs[0].config)"></i></span>-->
<!-- <pre >{{JSON.stringify(scope.row.configs[0].config,null,2)}}</pre>-->
<!-- </div>-->
<!-- </el-tooltip>-->
<!-- <el-tooltip placement="right" effect="light" :popper-class="'endpointConfigsTips'" v-if="scope.row.configs[1].enable">-->
<!-- <span class="configs-endpoint logs">{ Logs }</span>-->
<!-- <div class="endpointConfigsTips" slot="content">-->
<!-- <span class="copy-value-content"> <i class="nz-icon nz-icon-override" @click="copyValue(scope.row.configs[1].config)"></i></span>-->
<!-- <pre >{{JSON.stringify(scope.row.configs[1].config,null,2)}}</pre>-->
<!-- </div>-->
<!-- </el-tooltip>-->
<el-tooltip placement="left" effect="light" :popper-class="'endpointConfigsTips'" v-if="scope.row.configs[0].enable || scope.row.configs[1].enable">
<span class="configs-endpoint metrics">[{{scope.row.configs[0].enable ? 'Metrics':''}}{{scope.row.configs[0].enable&&scope.row.configs[1].enable?',':''}}{{scope.row.configs[1].enable ? 'logs' : ''}}]</span>
<div class="endpointConfigsTips" slot="content"> <div class="endpointConfigsTips" slot="content">
<span class="copy-value-content"> <i class="nz-icon nz-icon-override" @click="copyValue(scope.row.configs[0].config)"></i></span> <span class="copy-value-content"> <i class="nz-icon nz-icon-override" @click="copyValue(clConfigs(scope.row))"></i></span>
<pre >{{JSON.stringify(scope.row.configs[0].config,null,2)}}</pre> <pre >{{JSON.stringify(clConfigs(scope.row),null,2)}}</pre>
</div>
</el-tooltip>
<el-tooltip placement="right" effect="light" :popper-class="'endpointConfigsTips'" v-if="scope.row.configs[1].enable">
<span class="configs-endpoint logs">{ Logs }</span>
<div class="endpointConfigsTips" slot="content">
<span class="copy-value-content"> <i class="nz-icon nz-icon-override" @click="copyValue(scope.row.configs[1].config)"></i></span>
<pre >{{JSON.stringify(scope.row.configs[1].config,null,2)}}</pre>
</div> </div>
</el-tooltip> </el-tooltip>
</template> </template>
<template v-else-if="item.prop === 'state'"> <template v-else-if="item.prop === 'state'">
<el-popover placement="right" trigger="hover" width="200" :popper-class="''" :disabled="scope.row[item.prop]<2"> <!-- <el-popover placement="right" trigger="hover" width="200" :popper-class="''" :disabled="scope.row[item.prop]<2">-->
<!-- <div>-->
<!-- <div v-html="suspendedStr(scope.row[item.prop])"></div>-->
<!-- </div>-->
<!-- <div slot="reference" style="width: 100px">-->
<!-- <div v-if="scope.row[item.prop]===0">-->
<!-- <div class="active-icon red-bg inline-block"></div> down-->
<!-- </div>-->
<!-- <div v-else-if="scope.row[item.prop]===1">-->
<!-- <div class="active-icon green-bg inline-block"></div> up-->
<!-- </div>-->
<!-- <div v-else-if="scope.row[item.prop]">-->
<!-- <div class="active-icon gray-bg inline-block"></div> suspended-->
<!-- </div>-->
<!-- </div>-->
<!-- </el-popover>-->
<div> <div>
<div v-html="suspendedStr(scope.row[item.prop])"></div> <div class="state-box">
</div> <div class="state-box-content" ><span class="state-content-text">Metrics </span><div class="active-icon red-bg inline-block" style="margin-right: 5px"></div></div>
<div slot="reference" style="width: 100px"> <div class="state-box-content" ><span class="state-content-text">Logs </span><div class="active-icon red-bg inline-block" style="margin-right: 0px"></div></div>
<div v-if="scope.row[item.prop]===0"> <div class="state-box-content" ><span class="state-content-text">Dc </span><div class="active-icon red-bg inline-block" style="margin-right: 5px"></div></div>
<div class="active-icon red-bg inline-block"></div> down <div class="state-box-content" ><span class="state-content-text">Endpoint </span><div class="active-icon red-bg inline-block" style="margin-right: 0px"></div></div>
</div> <div class="state-box-content" ><span class="state-content-text">Asset </span><div class="active-icon red-bg inline-block" style="margin-right: 5px"></div></div>
<div v-else-if="scope.row[item.prop]===1"> <div class="state-box-content" ><span class="state-content-text">Asset </span><div class="active-icon red-bg inline-block" style="margin-right: 0px"></div></div>
<div class="active-icon green-bg inline-block"></div> up <div class="state-box-content" ><span class="state-content-text">Asset </span><div class="active-icon red-bg inline-block" style="margin-right: 5px"></div></div>
</div> <div class="state-box-content" ><span class="state-content-text">Asset </span><div class="active-icon red-bg inline-block" style="margin-right: 0px"></div></div>
<div v-else-if="scope.row[item.prop]">
<div class="active-icon gray-bg inline-block"></div> suspended
</div> </div>
</div> </div>
</el-popover>
</template> </template>
<template v-else-if="item.prop === 'enabled'"> <template v-else-if="item.prop === 'enabled'">
<span v-if="scope.row[item.prop] === 1">{{$t('project.endpoint.enable')}}</span> <span v-if="scope.row[item.prop] === 1">{{$t('project.endpoint.enable')}}</span>
@@ -127,8 +182,12 @@
<script> <script>
import table from '@/components/common/mixin/table' import table from '@/components/common/mixin/table'
import alertLabel from '../../alert/alertLabel'
export default { export default {
name: 'endpointTable', name: 'endpointTable',
components: {
alertLabel
},
mixins: [table], mixins: [table],
props: { props: {
showOption: { showOption: {
@@ -198,7 +257,14 @@ export default {
} }
}, },
methods: { methods: {
copyValue (str) { copyValue (item) {
const str = []
if (item.configs[0].enabled) {
str.push(item.configs[0])
}
if (item.configs[1].enabled) {
str.push(item.configs[1])
}
const domUrl = document.createElement('input') const domUrl = document.createElement('input')
domUrl.value = JSON.stringify(str) domUrl.value = JSON.stringify(str)
domUrl.id = 'creatDom' domUrl.id = 'creatDom'
@@ -232,6 +298,26 @@ export default {
// } // }
}) })
return str return str
},
// label 鼠标划入
labelHover (item, type, loading, e) {
if (e) {
const dom = e.currentTarget
const position = dom.getBoundingClientRect()
this.$set(item[type], 'position', position)
}
this.$set(item[type], 'loading', loading)
// this.$set(this.tableData,index,item);// 调用父组件
},
clConfigs (item) {
const str = []
if (item.configs[0].enable) {
str.push(item.configs[0])
}
if (item.configs[1].enable) {
str.push(item.configs[1])
}
return str
} }
}, },
computed: {} computed: {}
@@ -274,6 +360,26 @@ export default {
.inline-block{ .inline-block{
display: inline-block; display: inline-block;
} }
.pointer{
cursor: pointer;
}
.state-box{
display: flex;
flex-wrap: wrap;
border: 1px solid #E7EAED;
border-bottom: none;
}
.state-box-content{
padding: 0 5px;
width: 50%;
border-bottom: 1px solid #E7EAED;
}
.state-box-content:nth-of-type(odd){
border-right: 1px solid #E7EAED;
}
.state-content-text{
width:64px;text-align:left;margin-right: 5px;display: inline-block
}
</style> </style>
<style> <style>
.endpointConfigsTips{ .endpointConfigsTips{