From 76756146e3f0ce41bc1af8d3cab0eec1c9fbef28 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Mon, 11 Sep 2023 14:00:30 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat=EF=BC=9A=20=E6=B7=BB=E5=8A=A0nz-defaul?= =?UTF-8?q?t-config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nezha-fronted/src/entrance/app/App.vue | 1 + nezha-fronted/src/entrance/app/main.js | 3 +++ .../src/entrance/exportHtml/exportHtml.js | 3 +++ nezha-fronted/src/store/index.js | 15 ++++++++++++++- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/nezha-fronted/src/entrance/app/App.vue b/nezha-fronted/src/entrance/app/App.vue index 0be2ff9fe..483bfa8b7 100644 --- a/nezha-fronted/src/entrance/app/App.vue +++ b/nezha-fronted/src/entrance/app/App.vue @@ -26,6 +26,7 @@ export default { this.$axios.defaults.baseURL = result.body.baseUrl const version = result.body.version const baseUrl = result.body.baseUrl + this.$store.commit('setNzDefaultConfig', result.body) localStorage.setItem('nz-baseURL', baseUrl) const defaultWindowWidth = result.body.width || 1024 if (version !== localStorage.getItem('nz-version')) { diff --git a/nezha-fronted/src/entrance/app/main.js b/nezha-fronted/src/entrance/app/main.js index 4712523f6..6348a69e3 100644 --- a/nezha-fronted/src/entrance/app/main.js +++ b/nezha-fronted/src/entrance/app/main.js @@ -169,6 +169,9 @@ Vue.mixin({ }, $routePath () { return this.$route.path + }, + nzDefaultConfig () { + return this.$store.getters.getNzDefaultConfig } }, methods: { diff --git a/nezha-fronted/src/entrance/exportHtml/exportHtml.js b/nezha-fronted/src/entrance/exportHtml/exportHtml.js index 55ccc0d13..ec24ec8bf 100644 --- a/nezha-fronted/src/entrance/exportHtml/exportHtml.js +++ b/nezha-fronted/src/entrance/exportHtml/exportHtml.js @@ -105,6 +105,9 @@ Vue.mixin({ }, $routePath () { return this.$route.path + }, + nzDefaultConfig () { + return this.$store.getters.getNzDefaultConfig } }, ...mainMixin diff --git a/nezha-fronted/src/store/index.js b/nezha-fronted/src/store/index.js index 4bdb35ce8..040b00670 100644 --- a/nezha-fronted/src/store/index.js +++ b/nezha-fronted/src/store/index.js @@ -58,9 +58,15 @@ const store = new Vuex.Store({ diagnosisTab: {}, // 故障诊断 showDiagnosisTab: false, configSync: {}, // 配置同步 - showConfigSync: false + showConfigSync: false, + nzDefaultConfig: { + minStep: 60 + }, }, getters: { + getNzDefaultConfig (state) { + return state.nzDefaultConfig + }, getGlobalSearchId (state) { return state.globalSearchId }, @@ -135,6 +141,13 @@ const store = new Vuex.Store({ } }, mutations: { + // 设置默认 config + setNzDefaultConfig (state, defaultConfig) { + state.nzDefaultConfig = { + ...state.nzDefaultConfig, + ...defaultConfig + } + }, /* 监听对象变化,用于顶部菜单与底部内容的同步 */ projectListChange (state) { state.projectListChange++ From 1f0625b988e38be682ad449bf944498f36da0f31 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Mon, 11 Sep 2023 14:21:41 +0800 Subject: [PATCH 2/2] =?UTF-8?q?NEZ-3185=20=20=20feat=EF=BC=9Adashboard=20p?= =?UTF-8?q?romql&logql=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A=E4=B9=89=20step?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nezha-fronted/src/assets/css/common.scss | 3 +++ .../src/components/chart/panelChart.vue | 16 +++++++++++++--- .../common/project/meta2d/js/meta2dMainCalc.js | 10 +++++++--- .../common/rightBox/chart/chartConfig.vue | 13 ++++++++++++- .../common/rightBox/chart/chartRightBox.vue | 4 ++-- .../common/rightBox/chart/publicConfig.js | 9 ++++++--- .../src/components/page/dashboard/dashboard.vue | 2 +- 7 files changed, 44 insertions(+), 13 deletions(-) diff --git a/nezha-fronted/src/assets/css/common.scss b/nezha-fronted/src/assets/css/common.scss index dd5fea04c..65fb76be4 100644 --- a/nezha-fronted/src/assets/css/common.scss +++ b/nezha-fronted/src/assets/css/common.scss @@ -743,3 +743,6 @@ i.nz-icon-override{ .el-form-item__error { padding-top: 0; } +input::placeholder{ + text-transform:capitalize; +} diff --git a/nezha-fronted/src/components/chart/panelChart.vue b/nezha-fronted/src/components/chart/panelChart.vue index c8bccc99a..61220592e 100644 --- a/nezha-fronted/src/components/chart/panelChart.vue +++ b/nezha-fronted/src/components/chart/panelChart.vue @@ -244,6 +244,13 @@ export default { } this.chartInfo.loaded && this.query(elements, startTime, endTime, step, params, isRefresh) }, + getIemStep (element, step) { + let myStep = step + if (element.step) { + myStep = element.step + 's' + } + return myStep + }, query (elements, startTime, endTime, step, params, isRefresh) { // 获取chart的数据 this.isError = false this.allDataLength = 0 @@ -271,10 +278,11 @@ export default { urlPre += '/logs/loki' } let requests = elements.map((element) => { + const myStep = this.getIemStep(element, step) if (this.from === fromRoute.chartTemp || this.from === fromRoute.dashboardTemp) { return chartTempData } - let query = `${urlPre}/api/v1/query_range?start=${startTime}&end=${endTime}&step=${step}` + let query = `${urlPre}/api/v1/query_range?start=${startTime}&end=${endTime}&step=${myStep}` if (isTimeSeries(this.chartInfo.type)) { let nullType = this.chartInfo.param.nullType || 'null' nullType = (nullType === 'connected' ? 'null' : nullType) @@ -298,10 +306,11 @@ export default { }) if (this.multipleTime) { const multipleRequests = elements.map((element) => { + const myStep = this.getIemStep(element, step) if (this.from === fromRoute.chartTemp || this.from === fromRoute.dashboardTemp) { return chartTempData } - let query = `${urlPre}/api/v1/query_range?start=${startTime - this.minusTime / 1000}&end=${endTime - this.minusTime / 1000}&step=${step}` + let query = `${urlPre}/api/v1/query_range?start=${startTime - this.minusTime / 1000}&end=${endTime - this.minusTime / 1000}&step=${myStep}` if (isTimeSeries(this.chartInfo.type)) { let nullType = this.chartInfo.param.nullType || 'null' nullType = (nullType === 'connected' ? 'null' : nullType) @@ -351,7 +360,8 @@ export default { } if (comparisonSt && comparisonEt) { const comparisonRequests = elements.map((element) => { - let query = `${urlPre}/api/v1/query_range?start=${comparisonSt}&end=${comparisonEt}&step=${step}` + const myStep = this.getIemStep(element, step) + let query = `${urlPre}/api/v1/query_range?start=${comparisonSt}&end=${comparisonEt}&step=${myStep}` if (element.filter) { query += `&filter=${element.filter}` } diff --git a/nezha-fronted/src/components/common/project/meta2d/js/meta2dMainCalc.js b/nezha-fronted/src/components/common/project/meta2d/js/meta2dMainCalc.js index b2b2c5ec8..10945884a 100644 --- a/nezha-fronted/src/components/common/project/meta2d/js/meta2dMainCalc.js +++ b/nezha-fronted/src/components/common/project/meta2d/js/meta2dMainCalc.js @@ -82,7 +82,7 @@ export default { const meta2dOptions = { minScale: this.minScale, // maxScale: 2, - autoAnchor: false, + autoAnchor: false // disableAnchor: true } const meta2d = new window.Meta2d(this.meta2dId, meta2dOptions) @@ -131,8 +131,12 @@ export default { startTime = this.timeRange[0] endTime = this.timeRange[1] } else if (this.filterTime) { - startTime = this.filterTime[0] - endTime = this.filterTime[1] + startTime = this.momentStrToTimestamp(this.filterTime[0]) + endTime = this.momentStrToTimestamp(this.filterTime[1]) + } + if (typeof (startTime) == 'string') { + startTime = this.momentStrToTimestamp(this.filterTime[0]) + endTime = this.momentStrToTimestamp(this.filterTime[1]) } this.getQueryValues(this.querysArray, startTime, endTime).then((arr) => { this.clacTopoData(this.$lodash.cloneDeep(this.topoData), arr).then((data) => { diff --git a/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue b/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue index f8831f022..d3241b4b3 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue +++ b/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue @@ -106,6 +106,13 @@ + + {{$t('overall.step')}}  + + + + + @@ -1341,7 +1348,11 @@ export default { } }, mixins: [promqlInputMixin, publicConfig, chartTypeShow], - computed: {}, + computed: { + minStep () { + return this.nzDefaultConfig.minStep + } + }, data () { return { rules: { diff --git a/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue b/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue index fe46069ce..7aa4f1b3e 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue +++ b/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue @@ -381,7 +381,7 @@ export default { height: 4, unit: 2, type: 'line', - elements: [{ expression: '', legend: '', type: 'expert', id: '', name: 'A', state: 1 }], + elements: [{ expression: '', legend: '', type: 'expert', id: '', name: 'A', state: 1 , step: undefined}], param: { stack: 0, nullType: 'null', @@ -423,7 +423,7 @@ export default { height: 4, unit: 2, type: 'log', - elements: [{ expression: '', legend: '', type: 'expert', id: '', name: 'A', state: 1 }], + elements: [{ expression: '', legend: '', type: 'expert', id: '', name: 'A', state: 1 , step: undefined}], param: { enable: { thresholds: false, diff --git a/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js b/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js index 4cd0bb2b4..d9615393b 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js +++ b/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js @@ -327,7 +327,8 @@ export default { legend: this.expressionsShow[i].legend, name: this.expressionName[i], state: this.expressionsShow[i].state, - orderNum: i + orderNum: i, + step: this.expressionsShow[i].step }) } }) @@ -407,7 +408,8 @@ export default { error: '', legend: '', elementId: '', - state: 1 + state: 1, + step: undefined }) this.expressionChange() } else { @@ -420,7 +422,8 @@ export default { error: '', elementId: item.id, legend: item.legend, - state: item.state + state: item.state, + step: item.step }) } }, diff --git a/nezha-fronted/src/components/page/dashboard/dashboard.vue b/nezha-fronted/src/components/page/dashboard/dashboard.vue index 8ea5d6347..22b508e6e 100644 --- a/nezha-fronted/src/components/page/dashboard/dashboard.vue +++ b/nezha-fronted/src/components/page/dashboard/dashboard.vue @@ -272,7 +272,7 @@ export default { pointSize: 6 } }, - elements: [{ expression: '', legend: '', type: 'expert', id: '', name: 'A', state: 1, orderNum: 0 }], + elements: [{ expression: '', legend: '', type: 'expert', id: '', name: 'A', state: 1, orderNum: 0 , step: undefined}], panel: '', sync: 0, remark: '',