diff --git a/nezha-fronted/src/components/charts/chart-alert-list.vue b/nezha-fronted/src/components/charts/chart-alert-list.vue index a8e0a7333..ad6c1578d 100644 --- a/nezha-fronted/src/components/charts/chart-alert-list.vue +++ b/nezha-fronted/src/components/charts/chart-alert-list.vue @@ -175,6 +175,7 @@ export default { }, data () { return { + currentMsg: null, tableHeight: 0, data: {}, // 该图表信息,chartItem unit: {}, @@ -338,7 +339,7 @@ export default { const vm = this this.$chartResizeTool.start(vm, this.data, e) }, - formatThreshold: function (value, unit) { + formatThreshold (value, unit) { const unitMethod = chartDataFormat.getUnit(unit) if (unitMethod && value) { return unitMethod.compute(value, null, 2) @@ -346,7 +347,7 @@ export default { return value } }, - computeDistance: function (str) { + computeDistance (str) { let width = 0 const html = document.createElement('span') html.innerText = str @@ -356,7 +357,7 @@ export default { document.querySelector('.getTextWidth').remove() return Number('-' + (width + 5)) }, - returnMarkArea: function () { + returnMarkArea () { if (this.currentMsg) { if (this.currentMsg.alertRule.operator == '>' || this.currentMsg.alertRule.operator == '>=') { return [{ yAxis: this.currentMsg.alertRule.threshold }, {}] @@ -382,7 +383,7 @@ export default { this.importBox.show = false this.deleteBox.show = false }, - screenDialogClose: function () { + screenDialogClose () { this.screenModal = false this.deleteBox.ids = [] this.$refs.alertListScreenTable.$refs.alertListTable.clearSelection() @@ -413,7 +414,7 @@ export default { }) }) }, - chartUnitChange: function (unit) { + chartUnitChange (unit) { this.chartUnit = unit this.$nextTick(() => { this.queryChartDate() @@ -448,7 +449,7 @@ export default { this.$refs.messageChart.startLoading() } const axiosArr = [] - const paramStr = JSON.stringify(this.promQueryParamConvert(this.currentMsg)) + const paramStr = this.currentMsg ? JSON.stringify(this.promQueryParamConvert(this.currentMsg)) : null if (paramStr && paramStr.trim() != '""') { axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + paramStr.substring(1, paramStr.length - 1).replace(/\+/g, '%2B').replace(/ /g, '%20').replace(/\\/g, '') + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step)) this.legend = [] @@ -474,7 +475,7 @@ export default { symbol: ['circle', 'circle'], label: { distance: this.computeDistance(chartDataFormat.getUnit(this.currentMsg.alertRule.unit ? this.currentMsg.alertRule.unit : 2).compute(this.currentMsg.alertRule.threshold)), - formatter: function (params) { + formatter (params) { return chartDataFormat.getUnit($temp.currentMsg.alertRule.unit ? $temp.currentMsg.alertRule.unit : 2).compute(params.value) } }, @@ -537,7 +538,7 @@ export default { }) } }, - getAlertList: function (filterType, isPreview = false, chartInfo) { + getAlertList (filterType, isPreview = false, chartInfo) { this.resize() this.loadingTable = true this.isPreview = isPreview @@ -551,6 +552,66 @@ export default { } else { chart = Object.assign({}, this.chartInfo) } + if (chart && chart.param) { // 按照粒度,project>module>endpoint 查询只传最细粒度 + const param = chart.param + if (param.endpointId) { + queryParam.endpointIds = param.endpointId + } else { + if (param.moduleId) { + queryParam.moduleIds = param.moduleId + } else { + if (param.projectId) { + queryParam.projectIds = param.projectId + } + } + } + + if (param.ruleId) { + queryParam.ruleIds = param.ruleId + } + if (param.severity) { + queryParam.severityIds = param.severity + } + if (param.state) { + queryParam.state = param.state + } + } + if (this.searchLabel.orderBy) { + queryParam.orderBy = this.searchLabel.orderBy + } + // this.startLoading(filterType); + this.$get('/alert/message', queryParam).then(response => { + if (response.code === 200) { + this.storedTableData = response.data.list + this.storedScreanTableData = response.data.list + this.pageObj.total = response.data.total + this.isError = false + this.errorContent = '' + this.divFirstShow = true + + this.firstShow = true // 展示操作按键 + this.loadingTable = false + this.endLoading(filterType) + } else { + this.isError = true + this.errorContent = response.msg + } + }) + }, + getAlerScreetList (filterType, isPreview = false, chartInfo) { + this.resize() + this.loadingTable = true + this.isPreview = isPreview + const queryParam = { + pageSize: this.screenPageObj.pageSize, + pageNo: this.screenPageObj.pageNo + } + let chart + if (chartInfo) { + chart = Object.assign({}, chartInfo) + } else { + chart = Object.assign({}, this.chartInfo) + } if (chart && chart.param) { // 按照粒度,project>module>endpoint 查询只传最细粒度 const param = chart.param if (param.endpointId && param.endpointId != '') { @@ -566,70 +627,10 @@ export default { } if (param.ruleId && param.ruleId != '') { - queryParam.ruleId = param.ruleId + queryParam.ruleIds = param.ruleId } if (param.severity && param.severity != '') { - queryParam.severity = param.severity - } - if (param.state && param.state != '') { - queryParam.state = param.state - } - } - if (this.searchLabel.orderBy) { - queryParam.orderBy = this.searchLabel.orderBy - } - // this.startLoading(filterType); - this.$get('/alert/message', queryParam).then(response => { - if (response.code == 200) { - this.storedTableData = response.data.list - this.storedScreanTableData = response.data.list - this.pageObj.total = response.data.total - this.isError = false - this.errorContent = '' - this.divFirstShow = true - - this.firstShow = true // 展示操作按键 - this.loadingTable = false - this.endLoading(filterType) - } else { - this.isError = true - this.errorContent = response.msg - } - }) - }, - getAlerScreetList: function (filterType, isPreview = false, chartInfo) { - this.resize() - this.loadingTable = true - this.isPreview = isPreview - const queryParam = { - pageSize: this.screenPageObj.pageSize, - pageNo: this.screenPageObj.pageNo - } - let chart - if (chartInfo) { - chart = Object.assign({}, chartInfo) - } else { - chart = Object.assign({}, this.chartInfo) - } - if (chart && chart.param) { // 按照粒度,project>module>endpoint 查询只传最细粒度 - const param = chart.param - if (param.endpointId && param.endpointId != '') { - queryParam.endpointId = param.endpointId - } else { - if (param.moduleId && param.moduleId != '') { - queryParam.moduleId = param.moduleId - } else { - if (param.projectId && param.projectId != '') { - queryParam.projectId = param.projectId - } - } - } - - if (param.ruleId && param.ruleId != '') { - queryParam.ruleId = param.ruleId - } - if (param.severity && param.severity != '') { - queryParam.severity = param.severity + queryParam.severityIds = param.severity } if (param.state && param.state != '') { queryParam.state = param.state @@ -647,7 +648,7 @@ export default { this.$nextTick(() => { this.storedScreanTableData.forEach((item) => { item.labels = JSON.parse(item.labels) - if (item.alertRule.buildIn != 1) { + if (item.alertRule.buildIn !== 1) { const paramStr = JSON.stringify(this.promQueryParamConvert(item)) axiosAll.push(axios.get('/prom/api/v1/query?query=' + paramStr.substring(1, paramStr.length - 1).replace(/\+/g, '%2B').replace(/ /g, '%20').replace(/\\/g, ''))) } else { diff --git a/nezha-fronted/src/components/charts/chart-list.vue b/nezha-fronted/src/components/charts/chart-list.vue index dd001b54f..db96818fe 100644 --- a/nezha-fronted/src/components/charts/chart-list.vue +++ b/nezha-fronted/src/components/charts/chart-list.vue @@ -145,12 +145,12 @@ :chart-index="index" > - { + const groupId = this.from === fromRoute.panel ? '&groupId=0' : '' + this.$get('visual/panel/chart?panelId=' + params.panelId + groupId + '&pageSize=-1').then(response => { if (response.code === 200) { response.data.list.forEach((item, index) => { item.isLoaded = false }) - // response.data.list = response.data.list.filter((item) => item.groupId === -1 || !item.groupId) // 处理外层存在的groupItem + // chart数据存在dataTotalListBak中 if (response.data.list) { this.dataTotalListBak = response.data.list } else { @@ -645,7 +645,7 @@ export default { let chartListTmp = [] // 查询条件带name - if (this.filter.searchName && this.filter.searchName != '') { + if (this.filter.searchName) { const searchTitleStr = this.filter.searchName this.dataTotalListBak.forEach((item) => { if (item.name.indexOf(searchTitleStr) > -1) { @@ -766,7 +766,7 @@ export default { this.$refs['editChart' + chartItem.id][0].setData(chartItem, singleStatRlt, this.filter.panelId, this.filter, '', errorMsg) } - } else if (chartItem.type == 'text') { + } else if (chartItem.type === 'text') { if (filterType === 'showFullScreen') { // 全屏查询 this.$refs['editChart' + chartItem.id][0].setData(chartItem, null, panelId, filter, null, filterType) @@ -789,7 +789,7 @@ export default { return } if (chartItem.type === 'assetInfo') { - if (chartItem.from != fromRoute.endpoint) { + if (chartItem.from !== fromRoute.endpoint) { this.$set(chartItem, 'draggable', true) this.$set(chartItem, 'resizable', true) } @@ -800,7 +800,7 @@ export default { this.getEndpointInfoChartData(chartItem) return } - if (chartItem.type == 'projectInfo') { + if (chartItem.type === 'projectInfo') { chartItem.name = this.$t('project.chart.projectInfo') this.getProjectInfoChartData(chartItem) return @@ -1350,7 +1350,7 @@ export default { chartInfo.name = this.$t('asset.assetInfo') const detail = [] if (!this.isModel) { - const assetId = this.additionalInfo.assetId ? this.additionalInfo.assetId : this.additionalInfo.id + const assetId = this.obj.assetId ? this.obj.assetId : this.obj.id const arr = [] arr.push(this.$get(`/asset/asset/${assetId}`)) arr.push(this.$get(`/asset/asset/feature/${assetId}`)) @@ -1448,8 +1448,8 @@ export default { const detail = [] if (!this.isModel) { this.$refs['editChart' + chartInfo.id][0].showLoad(chartInfo) - this.$get('/project/info?id=' + this.additionalInfo.id).then(response => { - if (response.code == 200) { + this.$get('/project/info?id=' + this.obj.id).then(response => { + if (response.code === 200) { response.data && (function () { response.data.basic && detail.push({ title: vm.$t('project.chart.basicTitle'), @@ -1516,16 +1516,16 @@ export default { } }, getAlertListChartData (chartInfo, filterType) { - if (this.additionalInfo) { - this.$set(chartInfo, 'param', { endpointId: this.additionalInfo.id }) + if (this.obj) { + this.$set(chartInfo, 'param', { endpointId: this.obj.id }) } - this.$refs['editChart' + chartInfo.id][0].getAlertList(filterType) + this.$refs['editChart' + chartInfo.id][0].getAlertList(null, null, chartInfo) }, getAlertRuleChartData (chartInfo) { const vm = this const detail = [] const req = new Promise((resolve, reject) => { - this.$get('alert/rule/stat?id=' + this.additionalInfo.id).then(response => { + this.$get('alert/rule/stat?id=' + this.obj.id).then(response => { if (response.code == 200) { response.data && (function () { if (response.data.project && response.data.project.length > 0) { diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/panelTabNew.vue b/nezha-fronted/src/components/common/bottomBox/tabs/panelTabNew.vue index 0eb0fb38f..4a144317f 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/panelTabNew.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/panelTabNew.vue @@ -88,7 +88,7 @@
-
@@ -254,7 +254,7 @@ export default { if (refresh) { this.refresh() if (this.from === fromRoute.chartTemp) { - this.$get('/visual/panel/chart', { ids: this.obj.id, groupId: 0 }).then(res => { + this.$get('/visual/panel/chart', { ids: this.obj.id }).then(res => { res.data.list.forEach(item => { if (!item.children) { item.children = [] @@ -375,7 +375,7 @@ export default { } else { if (this.from === this.fromRoute.chartTemp) { if (this.obj.type === 'group') { - this.$get('/visual/panel/chart', { ids: this.obj.id, groupId: 0 }).then(res => { + this.$get('/visual/panel/chart', { ids: this.obj.id }).then(res => { res.data.list.forEach(item => { if (!item.children) { item.children = [] diff --git a/nezha-fronted/src/components/common/rightBox/alertRuleBox.vue b/nezha-fronted/src/components/common/rightBox/alertRuleBox.vue index 6b2690bc4..45aa2d4b0 100644 --- a/nezha-fronted/src/components/common/rightBox/alertRuleBox.vue +++ b/nezha-fronted/src/components/common/rightBox/alertRuleBox.vue @@ -1,109 +1,108 @@