fix: npm event 部分组件接口调试
This commit is contained in:
@@ -2,58 +2,46 @@
|
||||
<div class="npm-header">
|
||||
<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-icon" :class="iconClass(item)"></div>
|
||||
<div class="npm-header-body-severity-value">{{item.severity}}</div>
|
||||
<div class="npm-header-body-severity-icon" :class="item.eventSeverity"></div>
|
||||
<div class="npm-header-body-severity-value">{{item.eventSeverity}}</div>
|
||||
</div>
|
||||
<div class="npm-header-body-total">{{item.total}}</div>
|
||||
<div class="npm-header-body-total">{{item.count}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getSecond } from '@/utils/date-util'
|
||||
import { get } from '@/utils/http'
|
||||
import { api } from '@/utils/api'
|
||||
|
||||
export default {
|
||||
name: 'NpmEventsHeader',
|
||||
props: {
|
||||
chart: Object,
|
||||
timeFilter: Object
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
chartData: [
|
||||
{ severity: 'Critical', total: 12 },
|
||||
{ severity: 'High', total: 32 },
|
||||
{ severity: 'Medium', total: 12 },
|
||||
{ severity: 'Low', total: 21 },
|
||||
{ severity: 'Info', total: 18 }
|
||||
]
|
||||
chartData: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
iconClass () {
|
||||
return function (row) {
|
||||
let className
|
||||
switch (row.severity) {
|
||||
case ('Critical'): {
|
||||
className = 'critical'
|
||||
break
|
||||
}
|
||||
case ('High'): {
|
||||
className = 'high'
|
||||
break
|
||||
}
|
||||
case ('Info'): {
|
||||
className = 'info'
|
||||
break
|
||||
}
|
||||
case ('Medium'): {
|
||||
className = 'medium'
|
||||
break
|
||||
}
|
||||
case ('Low'): {
|
||||
className = 'low'
|
||||
break
|
||||
}
|
||||
default: break
|
||||
}
|
||||
return className
|
||||
methods: {
|
||||
recentEventsListData () {
|
||||
const params = {
|
||||
startTime: getSecond(this.timeFilter.startTime),
|
||||
endTime: getSecond(this.timeFilter.endTime),
|
||||
type: 'severity'
|
||||
}
|
||||
get(api.npm.events.list, params).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.chartData = res.data.result
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.recentEventsListData()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user