diff --git a/nezha-fronted/src/App.vue b/nezha-fronted/src/App.vue index 810717713..dc5e136f0 100644 --- a/nezha-fronted/src/App.vue +++ b/nezha-fronted/src/App.vue @@ -15,15 +15,22 @@ export default { browserWindowZoom }, async created () { + const herfSpiltArr = window.location.href.split('/') + if (herfSpiltArr[3] !== '#') { + herfSpiltArr[3] = '#' + window.location.href = herfSpiltArr.join('/') + } const Timestamp = new Date().getTime() const url = 'static/config.json?Timestamp=' + Timestamp const result = await this.$http.get(url) this.$axios.defaults.baseURL = result.body.baseUrl const version = result.body.version if (version !== localStorage.getItem('nz-version')) { - sessionStorage.clear() + localStorage.clear() localStorage.clear() localStorage.setItem('nz-version', version) + herfSpiltArr[2] = herfSpiltArr[2] + '?t=' + new Date().getTime() + window.location.href = herfSpiltArr[0] + '//' + herfSpiltArr[2] } } } diff --git a/nezha-fronted/src/assets/css/components/common/project/topology.scss b/nezha-fronted/src/assets/css/components/common/project/topology.scss index eefab6d23..ce2883d2f 100644 --- a/nezha-fronted/src/assets/css/components/common/project/topology.scss +++ b/nezha-fronted/src/assets/css/components/common/project/topology.scss @@ -63,6 +63,14 @@ background: rgba(196,196,196,0.4) !important; box-shadow: inset 0 -1px 0 0 rgba(0,0,0,0.27); } + .topology-scroll{ + &.v{ + display: none; + } + &.h{ + display: none; + } + } .model-error.nz-icon-shuidi { color: #FADED7; animation: model-error-animation .6s infinite ease-in-out; @@ -530,5 +538,8 @@ .topo-noData /deep/ .icon{ width: 5rem; height: 5rem; - +} +.topo-page{ + overflow: hidden; + box-sizing: border-box; } diff --git a/nezha-fronted/src/components/charts/chart-alert-list.vue b/nezha-fronted/src/components/charts/chart-alert-list.vue index a4a740890..e71ff78df 100644 --- a/nezha-fronted/src/components/charts/chart-alert-list.vue +++ b/nezha-fronted/src/components/charts/chart-alert-list.vue @@ -65,11 +65,13 @@ @tableDataSort="tableDataSort" @del="deleteMessage" @showText="showText" + @addSilence="addSilence" @messageDetail="messageDetail" ref="alertListTable" :form="'chartList'" :fromPath="'/alertList'" style="height: calc(100% - 50px)" + :showOption="showOption" :showTopBtn="false" > @@ -101,7 +103,7 @@ :showOption="false" :chart-alert-list="true" > - +
@@ -155,6 +157,7 @@
+ @@ -167,13 +170,15 @@ import pickTime from '../common/pickTime' import chart from '../page/dashboard/overview/chart' import alertMessageTable from '@/components/common/table/alert/alertMessageTable.vue' import chartDataList from '@/components/common/mixin/chartDataList' +import alertSilenceBox from '@/components/common/rightBox/alertSilenceBox' export default { name: 'chartTable', components: { loading: loading, chart: chart, 'pick-time': pickTime, - alertMessageTable: alertMessageTable + alertMessageTable: alertMessageTable, + alertSilenceBox }, props: { // 看板id @@ -197,12 +202,14 @@ export default { chartData: {}, id: { type: String }, from: { type: String }, + showOption: { type: Boolean, default: true }, isLock: { type: Boolean, default: false } }, mixins: [chartDataList], data () { return { currentMsg: null, + silenceBoxShow: false, tableHeight: 0, data: {}, // 该图表信息,chartItem unit: {}, @@ -319,7 +326,22 @@ export default { logData: [], chartLoading: false, dialogShowText: false, - dialogText: '' + dialogText: '', + blankSilenceObject: { + id: '', + startAt: '', + endAt: '', + ruleId: '', + type: 'asset', + linkId: '', + remark: '', + time: [], + matchers: [ + { name: '', value: '', regex: 0 } + ], + name: '' + }, + objectSilence: {} } }, computed: { @@ -493,7 +515,7 @@ export default { const axiosArr = [] 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) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step)) + axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + encodeURIComponent(this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\r|\n+/g, '')) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step + '&filter=' + encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels))))) this.legend = [] this.chartDatas = [] axios.all(axiosArr).then(res => { @@ -626,7 +648,7 @@ export default { this.$get('/alert/message', queryParam).then(response => { if (response.code === 200) { this.storedTableData = response.data.list - this.storedScreanTableData = response.data.list + this.storedScreanTableData = JSON.parse(JSON.stringify(response.data.list)) this.pageObj.total = response.data.total this.isError = false this.errorContent = '' @@ -686,7 +708,7 @@ export default { this.$get('/alert/message', queryParam).then(response => { if (response.code == 200) { this.storedTableData = response.data.list - this.storedScreanTableData = response.data.list + this.storedScreanTableData = JSON.parse(JSON.stringify(response.data.list)) const axiosAll = [] this.$nextTick(() => { this.storedScreanTableData.forEach((item) => { @@ -736,7 +758,7 @@ export default { this.getAlerScreetList() }, promQueryParamConvert (obj) { - let r = '(' + obj.alertRule.expr.replace(/\"/g, '\'') + ')' + let r = '(' + obj.alertRule.expr.replace(/\"/g, '\'').replace(/\r|\n+/g, '') + ')' let intoLabels = false obj.labels = JSON.parse(obj.labels) if (Object.keys(obj.labels).length > 0) { @@ -767,6 +789,14 @@ export default { } return r }, + promQueryParamLabels (labels) { + const obj = labels.constructor === Object ? labels : JSON.stringify(labels) + const filterArr = ['alertname', 'severity_id', 'severity', 'rule_type'] + filterArr.forEach(key => { + delete obj[key] + }) + return JSON.stringify(obj) + }, elementsetShow (s, e) { const eventfixed = { shezhi: 0, @@ -899,6 +929,9 @@ export default { // this.$refs.alertListTable.$refs.alertListTable.clearSelection() // this.$refs.alertListScreenTable.$refs.dataTable.clearSelection() this.screenPageObj = { ...this.pageObj } + if (this.$refs.screenPagination && this.$refs.screenPagination.pageSize) { + this.$refs.screenPagination.pageSize = this.screenPageObj.pageSize + } }, // 设置数据, filter区分 setData (chartItem, seriesItem, panelId, filter, area, errorMsg) { @@ -974,7 +1007,7 @@ export default { const start = this.searchTimeDialog[0] ? this.searchTimeDialog[0] : bus.computeTimezoneTime(new Date().getTime() - 1 * 60 * 60 * 1000) const end = this.searchTimeDialog[1] ? this.searchTimeDialog[1] : bus.computeTimezoneTime(new Date().getTime()) this.expressions = [this.currentMsg.alertRule.expr] - this.$get('/logs/loki/api/v1/query_range?format=1&query=' + this.currentMsg.alertRule.expr + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&limit=' + limit).then(res => { + this.$get('/logs/loki/api/v1/query_range?format=1&query=' + encodeURIComponent(this.currentMsg.alertRule.expr) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&limit=' + limit + '&filter=' + encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels)))).then(res => { this.chartLoading = false const logData = [res.data] this.resultType = res.data.resultType @@ -1077,6 +1110,43 @@ export default { showText (row) { this.dialogShowText = true this.dialogText = row.alertRule.trbShot + }, + addSilence (row, type) { + this.blankSilenceObject.startAt = bus.timeFormate(bus.getOffsetTimezoneData(), 'yyyy-MM-dd hh:mm:ss') + this.blankSilenceObject.endAt = bus.timeFormate(bus.getOffsetTimezoneData(1), 'yyyy-MM-dd hh:mm:ss') + this.objectSilence = JSON.parse(JSON.stringify(this.blankSilenceObject)) + this.objectSilence.name = 'Quick silence' + if (type !== 'alertMessage' && type !== 'alertRule') { + this.objectSilence.matchers = [ + { name: type, value: row.name, regex: 0 }, + { name: type + '_id', value: row.id, regex: 0 } + ] + } else if (type === 'alertMessage') { + if (typeof row.labels === 'string') row.labels = JSON.parse(row.labels) + const labels = JSON.parse(JSON.stringify(row.labels)) + this.objectSilence.matchers = [] + const filterArr = ['alertname', 'severity_id', 'severity', 'rule_type'] + Object.keys(labels).forEach((key, i) => { + if (filterArr.indexOf(key) != -1) { + return + } + this.objectSilence.matchers.push( + { name: key, value: labels[key], regex: 0 } + ) + }) + } else if (type === 'alertRule') { + this.objectSilence.matchers = [ + { name: 'alertName', value: row.name, regex: 0 } + ] + } + this.silenceBoxShow = true + }, + closeSilenceBox (refresh) { + this.silenceBoxShow = false + if (refresh) { + this.delFlag = true + this.getAlertList() + } } }, created () { diff --git a/nezha-fronted/src/components/charts/chart-bar-statistics.vue b/nezha-fronted/src/components/charts/chart-bar-statistics.vue index c192a41fc..f698f3363 100644 --- a/nezha-fronted/src/components/charts/chart-bar-statistics.vue +++ b/nezha-fronted/src/components/charts/chart-bar-statistics.vue @@ -635,23 +635,6 @@ export default { }, 100) }) }, - dealLegendAlias (legend, expression) { - if (/\{\{.+\}\}/.test(expression)) { - const labelValue = expression.replace(/(\{\{.+?\}\})/g, function (i) { - const label = i.substr(i.indexOf('{{') + 2, i.indexOf('}}') - i.indexOf('{{') - 2) - const reg = new RegExp(label + '=".+?"') - let value = null - if (reg.test(legend)) { - const find = legend.match(reg)[0] - value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1) - } - return value || label - }) - return labelValue - } else { - return expression - } - }, clickLegend (legendName, index) { /* 点击legend * 1.当前如果是全高亮状态,则全部置灰,只留被点击的legend高亮 diff --git a/nezha-fronted/src/components/charts/chart-list-group.vue b/nezha-fronted/src/components/charts/chart-list-group.vue index e620b1130..da9f7ecd8 100644 --- a/nezha-fronted/src/components/charts/chart-list-group.vue +++ b/nezha-fronted/src/components/charts/chart-list-group.vue @@ -213,6 +213,7 @@ import chartBarStatis from './chart-bar-statistics' import logs from './logs' import { fromRoute } from '@/components/common/js/constants' import chartTempData from '@/components/charts/chartTempData' +import { dealLegendAlias } from '@/components/common/js/tools' // import visNetwork from './visNetwork' export default { name: 'chartList', @@ -289,7 +290,7 @@ export default { dragging: null, // chartDataCacheGroup:new Map,//图表数据缓存,用于查询:id:{} stepHeight: 50, - + childrenScrollTop: 0, tempDom: { height: '', width: '' } // showShadow:false, } @@ -408,6 +409,7 @@ export default { this.cleanData() // 内含 panelId,开始时间,结束时间 this.filter = filter + this.childrenScrollTop = 0 this.pagePanelId = this.filter.panelId this.getData(this.filter) }, @@ -510,10 +512,11 @@ export default { // this.getChartData(item, index, this.filter) this.setChartSize(item, index) const chartBox = document.getElementById('chart-' + item.id)// this.$refs['editChart'+item.id][0]; - this.handleElementInViewport(chartBox, 0, item, index, true) + this.handleElementInViewport(chartBox, this.childrenScrollTop, item, index, true) }) }, loadChartData (scrollTop) { + this.childrenScrollTop = scrollTop if (this.dataList.length > 0) { this.dataList.forEach((item, index) => { this.setChartSize(item, index) @@ -703,7 +706,7 @@ export default { this.$nextTick(() => { const axiosArr = chartItem.elements.map((ele) => { const filterItem = ele - let query = filterItem.expression + let query = encodeURIComponent(filterItem.expression) if ((chartInfo.type === 'line' || chartInfo.type === 'bar' || chartInfo.type === 'stackArea' || chartInfo.type === 'table') && chartInfo.param) { // 如果是这三个 默认给null chartInfo.param.nullType = chartInfo.param.nullType || 'null' query += '&nullType=' + chartInfo.param.nullType @@ -870,7 +873,7 @@ export default { host = chartItem.elements[innerPos].expression } // 处理legend别名 - let alias = this.$refs['editChart' + chartItem.id][0].dealLegendAlias(host, chartItem.elements[innerPos].legend) + let alias = dealLegendAlias(host, chartItem.elements[innerPos].legend) if (!alias || alias === '') { alias = host } @@ -1106,7 +1109,7 @@ export default { host += '}' } // 处理legend别名 - let alias = this.$refs['editChart' + chartInfo.id][0].dealLegendAlias(host, chartInfo.elements[0].legend) + let alias = dealLegendAlias(host, chartInfo.elements[0].legend) if (!alias || alias === '') { alias = host } @@ -1196,7 +1199,7 @@ export default { const endTime = bus.timeFormate(now, 'yyyy-MM-dd hh:mm:ss') // const step = bus.getStep(startTime, endTime) this.$nextTick(() => { - let query = chartInfo.elements[0].expression + let query = encodeURIComponent(chartInfo.elements[0].expression) if ((chartInfo.type === 'line' || chartInfo.type === 'bar' || chartInfo.type === 'stackArea') && chartInfo.param) { chartInfo.param.nullType = chartInfo.param.nullType || 'null' query += '&nullType=' + chartInfo.param.nullType @@ -1397,7 +1400,7 @@ export default { if (this.additionalInfo) { this.$set(chartInfo, 'param', { endpointId: this.additionalInfo.id }) } - this.$refs['editChart' + chartInfo.id][0].getAlertList(filterType) + this.$refs['editChart' + chartInfo.id][0] && this.$refs['editChart' + chartInfo.id][0].getAlertList(filterType) }, getAlertRuleChartData (chartInfo) { const vm = this diff --git a/nezha-fronted/src/components/charts/chart-list.vue b/nezha-fronted/src/components/charts/chart-list.vue index 6a3aa2aee..8c6504e69 100644 --- a/nezha-fronted/src/components/charts/chart-list.vue +++ b/nezha-fronted/src/components/charts/chart-list.vue @@ -225,7 +225,7 @@ 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' +import { chartResizeTool, dealLegendAlias } from '@/components/common/js/tools' export default { name: 'chartList', props: { @@ -236,7 +236,8 @@ export default { obj: Object, panelLock: { type: Boolean, default: false }, hasGroup: { type: Boolean, default: true }, - panelDataList: Array + panelDataList: Array, + nowTimeType: {} }, components: { @@ -280,7 +281,8 @@ export default { // chartDataCacheGroup:new Map,//图表数据缓存,用于查询:id:{} stepWidth: null, - tempDom: { height: '', width: '' } + tempDom: { height: '', width: '' }, + childrenScrollTop: 0 // showShadow:false, } }, @@ -439,6 +441,7 @@ export default { this.cleanData() // 内含 panelId,开始时间,结束时间 this.filter = filter + this.childrenScrollTop = 0 this.pagePanelId = this.filter.panelId this.getData(this.filter) }, @@ -565,10 +568,6 @@ export default { // 获取panel详情数据,获取panel下所有chart列表 getData (params) { - if (this.finshGetData) { - return - } - this.finshGetData = true const param = { panelId: params.panelId, query: params.query, @@ -641,21 +640,16 @@ export default { } }) }) - this.finshGetData = false return } if (!param.query) delete param.query // 根据panelId获得panel下的所有图表 // const groupId = true ? '&groupId=0' : '' if (!params.panelId) { - this.finshGetData = false return } // 没有panelId不调用接口 this.$get('visual/panel/chart?panelId=' + params.panelId + '&groupId=0' + '&pageSize=-1').then(response => { if (response.code === 200) { - setTimeout(() => { - this.finshGetData = false - }, 100) response.data.list.forEach((item, index) => { item.isLoaded = false }) @@ -706,7 +700,7 @@ export default { if (!item.isLoaded) { // 获得当前显示在浏览器的图表,从后台获取数据 const chartBox = document.getElementById('chart-' + item.id) - this.handleElementInViewport(chartBox, 0, item, index) + this.handleElementInViewport(chartBox, this.childrenScrollTop, item, index) } if (item.type === 'group') { this.$refs['editChart' + item.id][0].$refs.listGroup.getData(params) @@ -718,6 +712,7 @@ export default { }) }, loadChartData (scrollTop) { + this.childrenScrollTop = scrollTop if (this.dataList.length > 0) { this.dataList.forEach((item, index) => { if (!item.isLoaded) { @@ -821,7 +816,7 @@ export default { getChartData (chartInfo, pos, filterType) { const chartItem = chartInfo if (chartItem.type === 'group') { - this.$refs['editChart' + chartItem.id][0].setData(chartItem) + this.$refs['editChart' + chartItem.id][0] && this.$refs['editChart' + chartItem.id][0].setData(chartItem) return } if (chartItem.type === 'assetInfo') { @@ -905,7 +900,12 @@ export default { let startTime = '' let endTime = '' if (filterType === 'refresh') { // 刷新 - const now = new Date(bus.computeTimezone(new Date().getTime())) + let now = null + if (this.nowTimeType.id === 0 && this.nowTimeType.value === -1) { + now = new Date(this.filter.start_time) + } else { + now = new Date(bus.computeTimezone(new Date().getTime())) + } const origin = new Date(this.filter.end_time) const numInterval = now.getTime() - origin.getTime() if (numInterval >= 60000) { // 大于1分钟,则start、end均往后移numInterval,否则时间不变 @@ -918,8 +918,8 @@ export default { endTime = this.filter.end_time } } else if (filterType === 'showFullScreen') { // 全屏时间查询 - startTime = this.filter.start_time - endTime = this.filter.end_time + startTime = this.filter.showFullScreenStart_time + endTime = this.filter.showFullScreenEnd_time // this.$parent.refreshTime(startTime,endTime);全屏查询,不更新panel列表的时间条件 } else { startTime = this.filter.start_time @@ -930,7 +930,7 @@ export default { this.$nextTick(() => { const axiosArr = chartItem.elements.map((ele) => { const filterItem = ele - let query = filterItem.expression + let query = encodeURIComponent(filterItem.expression) if ((chartInfo.type === 'line' || chartInfo.type === 'bar' || chartInfo.type === 'stackArea' || chartInfo.type === 'table') && chartInfo.param) { // 如果是这三个 默认给null chartInfo.param.nullType = chartInfo.param.nullType || 'null' query += '&nullType=' + chartInfo.param.nullType @@ -1096,7 +1096,7 @@ export default { host = chartItem.elements[innerPos].expression } // 处理legend别名 - let alias = this.$refs['editChart' + chartItem.id][0].dealLegendAlias(host, chartItem.elements[innerPos].legend) + let alias = dealLegendAlias(host, chartItem.elements[innerPos].legend) if (!alias || alias === '') { alias = host } @@ -1336,7 +1336,7 @@ export default { host += '}' } // 处理legend别名 - let alias = this.$refs['editChart' + chartInfo.id][0].dealLegendAlias(host, chartInfo.elements[0].legend) + let alias = dealLegendAlias(host, chartInfo.elements[0].legend) if (!alias || alias === '') { alias = host } @@ -1416,7 +1416,7 @@ export default { }, getEndpointInfoChartData (chartInfo) { const detail = [] - this.$refs['editChart' + chartInfo.id][0].showLoad() + this.$refs['editChart' + chartInfo.id][0] && this.$refs['editChart' + chartInfo.id][0].showLoad() chartInfo.name = this.$t('project.chart.endpointInfo') chartInfo.from = fromRoute.endpoint const basicInfo = JSON.parse(JSON.stringify(this.obj)) @@ -1447,7 +1447,6 @@ export default { const arr = [] arr.push(this.$get(`/asset/asset/${assetId}`)) arr.push(this.$get(`/asset/asset/feature/${assetId}`)) - console.log(this.$refs['editChart' + chartInfo.id][0]) if (this.$refs['editChart' + chartInfo.id][0]) { this.$refs['editChart' + chartInfo.id][0].showLoad() } @@ -1619,7 +1618,7 @@ export default { if (this.obj) { this.$set(chartInfo, 'param', { endpointId: this.obj.id }) } - this.$refs['editChart' + chartInfo.id][0].getAlertList(null, null, chartInfo) + this.$refs['editChart' + chartInfo.id][0] && this.$refs['editChart' + chartInfo.id][0].getAlertList(null, null, chartInfo) }, getAlertRuleChartData (chartInfo) { const vm = this @@ -1760,8 +1759,8 @@ export default { }, searchData (chartId, searchTime) { if (searchTime) { // 全屏时间查询 - this.filter.start_time = bus.timeFormate(searchTime[0], 'yyyy-MM-dd hh:mm:ss') - this.filter.end_time = bus.timeFormate(searchTime[1], 'yyyy-MM-dd hh:mm:ss') + this.filter.showFullScreenStart_time = bus.timeFormate(searchTime[0], 'yyyy-MM-dd hh:mm:ss') + this.filter.showFullScreenEnd_time = bus.timeFormate(searchTime[1], 'yyyy-MM-dd hh:mm:ss') } this.dataList.forEach((item, index) => { if (item.id === chartId) { @@ -1834,6 +1833,9 @@ export default { this.$post('visual/panel/chart/syncTmpl', { ids: [item.id] }).then(res => { if (res.code === 200) { this.getData(this.filter) + // setTimeout(() => { + // this.refreshChart(item.id) + // }, 100) this.$message.success(this.$t('tip.syncSuccess')) } else { this.$message.error(res.msg) diff --git a/nezha-fronted/src/components/charts/chart-pie.vue b/nezha-fronted/src/components/charts/chart-pie.vue index 40d8e42eb..f12443865 100644 --- a/nezha-fronted/src/components/charts/chart-pie.vue +++ b/nezha-fronted/src/components/charts/chart-pie.vue @@ -533,23 +533,6 @@ export default { }, 100) }) }, - dealLegendAlias: function (legend, expression) { - if (/\{\{.+\}\}/.test(expression)) { - const labelValue = expression.replace(/(\{\{.+?\}\})/g, function (i) { - const label = i.substr(i.indexOf('{{') + 2, i.indexOf('}}') - i.indexOf('{{') - 2) - const reg = new RegExp(label + '=".+?"') - let value = null - if (reg.test(legend)) { - const find = legend.match(reg)[0] - value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1) - } - return value || label - }) - return labelValue - } else { - return expression - } - }, clickLegend (legendName, index) { /* 点击legend * 1.当前如果是全高亮状态,则全部置灰,只留被点击的legend高亮 diff --git a/nezha-fronted/src/components/charts/chart-table.vue b/nezha-fronted/src/components/charts/chart-table.vue index 0f9fd005c..675fd40a2 100644 --- a/nezha-fronted/src/components/charts/chart-table.vue +++ b/nezha-fronted/src/components/charts/chart-table.vue @@ -88,6 +88,7 @@ @@ -101,7 +102,7 @@ @@ -352,6 +353,8 @@ export default { this.seriesItemScreen = this.seriesItem this.screenModal = true + this.screenPageObj.pageNo = 1 + this.screenPageObj.pageSize = this.pageObj.pageSize }, // 设置数据, filter区分 setData (chartItem, seriesItem, panelId, filter, area, errorMsg) { @@ -390,6 +393,7 @@ export default { } this.mapping = mapping item.mapping = mapping + item.oldValue = item.value item.value = mapping ? mapping.text.replace('{{value}}', item.value).replace('{{name}}', item.element.alias) : chartDataFormat.getUnit(chartItem.unit ? chartItem.unit : 2).compute(value, null, 2) } return item @@ -608,23 +612,6 @@ export default { this.orderByScreen = { order: item.order, prop: item.prop } this.seriesItemScreen = this.filterShowData(this.storedScreanTableData, this.screenPageObj, 'seriesScreen') }, - dealLegendAlias: function (legend, expression) { - if (/\{\{.+\}\}/.test(expression)) { - const labelValue = expression.replace(/(\{\{.+?\}\})/g, function (i) { - const label = i.substr(i.indexOf('{{') + 2, i.indexOf('}}') - i.indexOf('{{') - 2) - const reg = new RegExp(label + '=".+?"') - let value = null - if (reg.test(legend)) { - const find = legend.match(reg)[0] - value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1) - } - return value || label - }) - return labelValue - } else { - return expression - } - }, // 获取格式 getNumStr (num) { if (num) { diff --git a/nezha-fronted/src/components/charts/chartPreview.vue b/nezha-fronted/src/components/charts/chartPreview.vue index e7afb3083..a84fe3126 100644 --- a/nezha-fronted/src/components/charts/chartPreview.vue +++ b/nezha-fronted/src/components/charts/chartPreview.vue @@ -138,7 +138,7 @@ - + @@ -93,7 +100,7 @@
-
@@ -137,6 +144,7 @@ export default { data () { return { fromRoute, + panelTabLoading: false, panelLock: true, showTopBtn: false, // top按钮 visible: false, @@ -213,7 +221,8 @@ export default { // ---图表相关参数--end scrollbarWrap: null, panelDataList: [], - batchDeleteObjs: [] + batchDeleteObjs: [], + nowTimeType: {} } }, components: { @@ -347,6 +356,7 @@ export default { // this.searchTime = [...val]; if (this.$refs.pickTime) { const nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType + this.nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType this.setSearchTime(nowTimeType.type, nowTimeType.value) this.filter.start_time = bus.timeFormate(this.searchTime[0], 'yyyy-MM-dd hh:mm:ss') this.filter.end_time = bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss') @@ -551,9 +561,11 @@ export default { this.panelLock = boolean }, chartBySync () { - this.$post('visual/panel/chart/syncTmpl', { pid: this.obj.id }).then(res => { + this.panelTabLoading = true + this.$post('visual/panel/chart/syncTmpl', { panelId: this.showPanel.id }).then(res => { + this.panelTabLoading = false if (res.code === 200) { - this.getTableData() + this.getTableData(this.obj.id) this.$message.success(this.$t('tip.syncSuccess')) } else { this.$message.error(res.msg) diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/terminalLogCMDTab.vue b/nezha-fronted/src/components/common/bottomBox/tabs/terminalLogCMDTab.vue index 5b9ae62db..679f8e55a 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/terminalLogCMDTab.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/terminalLogCMDTab.vue @@ -1,8 +1,10 @@