NEZ-956 feat: chart 增加 logs 图表类型(60%)

This commit is contained in:
zhangyu
2021-09-03 11:10:24 +08:00
parent c09ecaadb1
commit fa2920dc9e
10 changed files with 881 additions and 12 deletions

View File

@@ -77,6 +77,20 @@
:chart-index="index"
@dropmenu-change="(show) => {dropmenuChange(item.id, show)}"
:chart-data="item"></line-chart-block>
<logs v-if="item.type === 'logs'" :key="'inner' + item.id"
:from="from" :ref="'editChart'+item.id" :temp-dom="tempDom"
:startTime="filter.start_time" :endTime="filter.end_time"
@on-refresh-data="refreshChart"
@on-remove-chart-block="removeChart"
@on-duplicate-chart-block="duplicateChart"
@on-drag-chart="editChartForDrag"
@on-edit-chart-block="editData"
@sync="()=>{chartBySync(item)}"
:panel-id="filter.panelId"
:is-lock="panelLock"
:chart-index="index"
@dropmenu-change="(show) => {dropmenuChange(item.id, show)}"
:chart-data="item"></logs>
<chart-single-stat :from="from" :key="'inner' + item.id" :ref="'editChart'+item.id" v-if="item.type === 'singleStat'"
@on-refresh-data="refreshChart"
@@ -247,6 +261,7 @@ import diagramChart from './diagram-chart'
import chartPie from './chart-pie'
import chartBarStatis from './chart-bar-statistics'
import chartGroup from './chart-group'
import logs from './logs'
import { fromRoute } from '@/components/common/js/constants'
import chartTempData from '@/components/charts/chartTempData'
import { chartResizeTool } from '@/components/common/js/tools'
@@ -275,7 +290,8 @@ export default {
chartPie,
chartGroup,
chartBarStatis,
diagramChart
diagramChart,
logs
// visNetwork,
},
data () {
@@ -800,6 +816,14 @@ export default {
this.$refs['editChart' + chartItem.id][0].setData(chartItem, null,
panelId, filter, null, '')
}
} else if (chartItem.type === 'logs') {
if (filterType === 'showFullScreen') { // 全屏查询
this.$refs['editChart' + chartItem.id][0].setData(chartItem, null,
panelId, filter, null, filterType)
} else {
this.$refs['editChart' + chartItem.id][0].setData(chartItem, null,
panelId, filter, null, '')
}
}
}
} else {
@@ -868,7 +892,18 @@ export default {
}
return
}
if (chartItem.type == 'logs') {
if (this.$refs['editChart' + chartItem.id] && this.$refs['editChart' + chartItem.id].length > 0) {
if (filterType === 'showFullScreen') { // 全屏查询
this.$refs['editChart' + chartItem.id][0].setData(chartItem, null,
this.filter.panelId, null, filterType)
} else {
this.$refs['editChart' + chartItem.id][0].setData(chartItem, null,
this.filter.panelId, null, '')
}
}
return
}
if (this.isModel) {
this.modelStaticData(chartInfo, filterType)
} else {
@@ -890,6 +925,8 @@ export default {
if (numInterval >= 60000) { // 大于1分钟则start、end均往后移numInterval否则时间不变
startTime = this.getNewTime(this.filter.start_time, numInterval)
endTime = bus.timeFormate(now, 'yyyy-MM-dd hh:mm:ss')
this.filter.start_time = startTime
this.filter.end_time = endTime
} else {
startTime = this.filter.start_time
endTime = this.filter.end_time
@@ -918,6 +955,9 @@ export default {
if (this.from === fromRoute.chartTemp) {
return chartTempData
}
if (chartInfo.type == 'logs') {
return chartTempData
}
return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step)
})
// 一个图表的所有element单独获取数据
@@ -1186,6 +1226,14 @@ export default {
this.$refs['editChart' + chartItem.id][0].setData(chartItem, singleStatRlt,
this.filter.panelId, this.filter, '', errorMsg)
}
} else if (chartItem.type === 'logs') {
if (filterType === 'showFullScreen') { // 全屏查询
this.$refs['editChart' + chartItem.id][0].setData(chartItem, singleStatRlt,
this.filter.panelId, this.filter, filterType, errorMsg)
} else {
this.$refs['editChart' + chartItem.id][0].setData(chartItem, singleStatRlt,
this.filter.panelId, this.filter, '', errorMsg)
}
}
}
} else {
@@ -1215,6 +1263,14 @@ export default {
this.$refs['editChart' + chartItem.id][0].setData(chartItem, '',
this.filter.panelId, this.filter)
}
} else if (chartItem.type === 'logs') {
if (filterType === 'showFullScreen') { // 全屏查询
this.$refs['editChart' + chartItem.id][0].setData(chartItem, '',
this.filter.panelId, this.filter, filterType)
} else {
this.$refs['editChart' + chartItem.id][0].setData(chartItem, '',
this.filter.panelId, this.filter)
}
}
}
}
@@ -1361,6 +1417,14 @@ export default {
this.$refs['editChart' + chartInfo.id][0].setData(chartInfo, singleStatRlt,
this.filter.panelId, this.filter, '', errorMsg)
}
} else if (chartInfo.type === 'logs') {
if (filterType === 'showFullScreen') { // 全屏查询
this.$refs['editChart' + chartInfo.id][0].setData(chartInfo, singleStatRlt,
this.filter.panelId, this.filter, filterType, errorMsg)
} else {
this.$refs['editChart' + chartInfo.id][0].setData(chartInfo, singleStatRlt,
this.filter.panelId, this.filter, '', errorMsg)
}
}
}
},