fix: npm event 部分组件接口调试

This commit is contained in:
@changcode
2022-08-11 16:45:48 +08:00
parent ff0648d23d
commit d55cdcb709
9 changed files with 244 additions and 276 deletions

View File

@@ -1,13 +1,11 @@
.line.network { .line.network {
height: 100%; height: 100%;
width: 100%; width: 100%;
position: relative;
border: 1px solid #E2E5EC; border: 1px solid #E2E5EC;
border-radius: 4px; border-radius: 4px;
.chart-drawing { .chart-drawing {
height: 80%; height: 80%;
width: 100%; width: 100%;
top: 70px;
.echarts-tooltip.echarts-tooltip-dark { .echarts-tooltip.echarts-tooltip-dark {
.cn-chart-tooltip { .cn-chart-tooltip {
display: flex; display: flex;
@@ -21,18 +19,19 @@
} }
} }
} }
.line-select { .line-header {
top: 20px;
right: 20px;
display: flex; display: flex;
position: absolute; justify-content: space-between;
.line-select-metric {} .line-select.line-header-right {
display: flex;
//flex: 1;
.line-select__operation { .line-select__operation {
.el-input__inner { .el-input__inner {
width: 100px; width: 100px;
} }
} }
.line-select-reference-line { .line-select-reference-line {
margin-right: 20px;
.line-select__operation { .line-select__operation {
.el-input__inner { .el-input__inner {
width: 127px; width: 127px;
@@ -78,6 +77,7 @@
margin-left: 20px; margin-left: 20px;
} }
} }
.line-header-left {
.line-value-active { .line-value-active {
position: absolute; position: absolute;
height: 3px; height: 3px;
@@ -88,9 +88,9 @@
transition: all linear .2s; transition: all linear .2s;
} }
.line-value { .line-value {
position: absolute; //position: absolute;
top: 0; //top: 0;
left: 0; //left: 0;
display: flex; display: flex;
.line-value-mpackets.mousemove-cursor { .line-value-mpackets.mousemove-cursor {
border-top: 4px solid #D3D0D8; border-top: 4px solid #D3D0D8;
@@ -152,6 +152,9 @@
} }
} }
} }
}
}
} }
.metric.el-select__popper,.reference-line.el-select__popper { .metric.el-select__popper,.reference-line.el-select__popper {
top: 216px !important; top: 216px !important;

View File

@@ -39,6 +39,9 @@
height: 8px; height: 8px;
margin-right: 5px; margin-right: 5px;
} }
.npm-event-pie-legend-type-severity {
text-transform: capitalize;
}
.critical { .critical {
background: rgb(226,97,84); background: rgb(226,97,84);
} }

View File

@@ -43,6 +43,7 @@
font-size: 12px; font-size: 12px;
color: #575757; color: #575757;
font-weight: 900; font-weight: 900;
text-transform: capitalize;
} }
} }
.npm-header-body-total { .npm-header-body-total {

View File

@@ -37,6 +37,7 @@
font-weight: 500; font-weight: 500;
border-radius: 4px; border-radius: 4px;
padding: 0 6px; padding: 0 6px;
text-transform: capitalize;
} }
.critical { .critical {
color: #E26154; color: #E26154;

View File

@@ -161,10 +161,18 @@ export const api = {
appPacketRetransPercent: '/interface/application/performance/overview/appPacketRetransPercent' appPacketRetransPercent: '/interface/application/performance/overview/appPacketRetransPercent'
}, },
location: { location: {
// 折线图
thoughput: '/interface/application/performance/location/thoughput',
tcpConnectionEstablishLatency: '/interface/application/performance/location/tcpConnectionEstablishLatency',
httpResponseLatency: '/interface/application/performance/location/httpResponseLatency',
sslHandshakeLatency: '/interface/application/performance/location/sslHandshakeLatency',
packetsLoss: '/interface/application/performance/location/packetsLoss',
packetsRetrains: '/interface/application/performance/location/packetsRetrains',
}, },
events: { events: {
list: '/interface/overview/event/list',
recentEvents: '/interface/overview/event/recentEvents',
dimensionEvents: '/interface/overview/event/dimensionEvents'
} }
} }
} }

View File

@@ -477,7 +477,7 @@ export function stackedLineTooltipFormatter (params) {
</span>` </span>`
str += '</span>' str += '</span>'
str += `<span class="cn-chart-tooltip-value cn-chart-tooltip__color"> str += `<span class="cn-chart-tooltip-value cn-chart-tooltip__color">
${unitConvert(item.data[1], 'number').join(' ')} ${unitConvert(item.data[1], item.value[2]).join(' ')}
</span>` </span>`
str += '</div>' str += '</div>'
}) })

View File

@@ -2,7 +2,8 @@
<div class="line network"> <div class="line network">
<chart-no-data v-if="isNoData"></chart-no-data> <chart-no-data v-if="isNoData"></chart-no-data>
<template v-else> <template v-else>
<div class="chart-drawing" v-show="showMarkLine" id="chart"></div> <div class="line-header">
<div class="line-header-left">
<div class="line-value-active" v-if="activeShow"></div> <div class="line-value-active" v-if="activeShow"></div>
<div class="line-value"> <div class="line-value">
<div class="line-value-mpackets" <div class="line-value-mpackets"
@@ -25,7 +26,8 @@
</div> </div>
</div> </div>
</div> </div>
<div class="line-select"> </div>
<div class="line-select line-header-right">
<div class="line-select-metric"> <div class="line-select-metric">
<span>{{$t('network.metric')}}:</span> <span>{{$t('network.metric')}}:</span>
<div class="line-select__operation"> <div class="line-select__operation">
@@ -54,6 +56,8 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="chart-drawing" v-show="showMarkLine" id="chart"></div>
</template> </template>
</div> </div>
</template> </template>

View File

@@ -2,58 +2,46 @@
<div class="npm-header"> <div class="npm-header">
<div class="npm-header-body" v-for="(item, index) in chartData" :key="index"> <div class="npm-header-body" v-for="(item, index) in chartData" :key="index">
<div class="npm-header-body-severity"> <div class="npm-header-body-severity">
<div class="npm-header-body-severity-icon" :class="iconClass(item)"></div> <div class="npm-header-body-severity-icon" :class="item.eventSeverity"></div>
<div class="npm-header-body-severity-value">{{item.severity}}</div> <div class="npm-header-body-severity-value">{{item.eventSeverity}}</div>
</div> </div>
<div class="npm-header-body-total">{{item.total}}</div> <div class="npm-header-body-total">{{item.count}}</div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { getSecond } from '@/utils/date-util'
import { get } from '@/utils/http'
import { api } from '@/utils/api'
export default { export default {
name: 'NpmEventsHeader', name: 'NpmEventsHeader',
props: {
chart: Object,
timeFilter: Object
},
data () { data () {
return { return {
chartData: [ chartData: []
{ severity: 'Critical', total: 12 },
{ severity: 'High', total: 32 },
{ severity: 'Medium', total: 12 },
{ severity: 'Low', total: 21 },
{ severity: 'Info', total: 18 }
]
} }
}, },
computed: { methods: {
iconClass () { recentEventsListData () {
return function (row) { const params = {
let className startTime: getSecond(this.timeFilter.startTime),
switch (row.severity) { endTime: getSecond(this.timeFilter.endTime),
case ('Critical'): { type: 'severity'
className = 'critical'
break
} }
case ('High'): { get(api.npm.events.list, params).then(res => {
className = 'high' if (res.code === 200) {
break this.chartData = res.data.result
}
case ('Info'): {
className = 'info'
break
}
case ('Medium'): {
className = 'medium'
break
}
case ('Low'): {
className = 'low'
break
}
default: break
}
return className
} }
})
} }
},
mounted () {
this.recentEventsListData()
} }
} }
</script> </script>

View File

@@ -15,10 +15,10 @@
</template> </template>
<template #default="scope" :column="item"> <template #default="scope" :column="item">
<div class="data-recent-table"> <div class="data-recent-table">
<template v-if="item.prop === 'severity'"> <template v-if="item.prop === 'eventSeverity'">
<span class="data-recent-table-severity" :class="iconClass(scope.row)">{{$t(scope.row[item.prop])}}</span> <span class="data-recent-table-severity" :class="scope.row[item.prop]">{{$t(scope.row[item.prop])}}</span>
</template> </template>
<template v-else-if="item.prop === 'entity'"> <template v-else-if="item.prop === 'eventKey'">
<span class="data-recent-table-entity">{{$t(scope.row[item.prop])}}</span> <span class="data-recent-table-entity">{{$t(scope.row[item.prop])}}</span>
</template> </template>
<template v-else-if="item.prop === 'eventType'"> <template v-else-if="item.prop === 'eventType'">
@@ -35,82 +35,42 @@
</template> </template>
<script> <script>
import { get } from '@/utils/http'
import { api } from '@/utils/api'
import { getSecond } from '@/utils/date-util'
export default { export default {
name: 'NpmRecentEvents', name: 'NpmRecentEvents',
props: {
chart: Object,
timeFilter: Object
},
data () { data () {
return { return {
tableData: [ tableData: [],
{
severity: 'Critical',
entity: 'command adn control',
eventType: 'dns error'
}, {
severity: 'High',
entity: 'command adn control',
eventType: 'dns error'
}, {
severity: 'Critical',
entity: 'command adn control',
eventType: 'dns error'
}, {
severity: 'Medium',
entity: 'command adn control',
eventType: 'dns error'
}, {
severity: 'Low',
entity: 'command adn control',
eventType: 'dns error'
}, {
severity: 'Info',
entity: 'command adn control',
eventType: 'dns error'
}, {
severity: 'Critical',
entity: 'command adn control',
eventType: 'dns error'
}, {
severity: 'Critical',
entity: 'command adn control',
eventType: 'dns error'
}
],
customTableTitles: [ customTableTitles: [
{ label: 'network.severity', prop: 'severity' }, { label: 'network.severity', prop: 'eventSeverity' },
{ label: 'network.entity', prop: 'entity' }, { label: 'network.entity', prop: 'eventKey' },
{ label: 'detections.eventType', prop: 'eventType' } { label: 'detections.eventType', prop: 'eventType' }
] ]
} }
}, },
computed: { methods: {
iconClass () { recentEventsListData () {
return function (row) { const params = {
let className startTime: getSecond(this.timeFilter.startTime),
switch (row.severity) { endTime: getSecond(this.timeFilter.endTime),
case ('Critical'): { limit: 1
className = 'critical'
break
} }
case ('High'): { get(api.npm.events.recentEvents, params).then(res => {
className = 'high' if (res.code === 200) {
break this.tableData = res.data.result
}
case ('Info'): {
className = 'info'
break
}
case ('Medium'): {
className = 'medium'
break
}
case ('Low'): {
className = 'low'
break
}
default: break
}
return className
} }
})
} }
},
mounted () {
this.recentEventsListData()
} }
} }
</script> </script>