diff --git a/nezha-fronted/src/components/chart/chart/chartTable.vue b/nezha-fronted/src/components/chart/chart/chartTable.vue index 326f0c63a..52db31ecb 100644 --- a/nezha-fronted/src/components/chart/chart/chartTable.vue +++ b/nezha-fronted/src/components/chart/chart/chartTable.vue @@ -19,7 +19,15 @@ {{col.title}} @@ -38,13 +46,22 @@ export default { data () { return { tableData: [], - columns: [] + columns: [], + valueMapping: {} } }, methods: { initChart () { console.log(this.chartInfo, this.chartData) this.columns = this.chartInfo.param.columns + this.chartInfo.param.valueMapping.mapping.forEach((item) => { + if (this.valueMapping[item.column]) { + this.valueMapping[item.column].push(item) + } else { + this.valueMapping[item.column] = [item] + } + }) + console.log(this.valueMapping) const data = this.initTableData(this.chartInfo, this.chartData) const arr = [] console.log(data) @@ -54,6 +71,9 @@ export default { arr.push(data[key][keys]) }) }) + arr.forEach(item => { + item.valueMapping = this.selectTableMapping(item, this.valueMapping) + }) this.tableData = arr this.$refs.dataTable.doLayout() console.log(data) @@ -69,10 +89,11 @@ export default { data.$labels = data.metric const value = getMetricTypeValue(data.values, chartInfo.param.statistics) const showValue = chartDataFormat.getUnit(chartInfo.unit ? chartInfo.unit : 2).compute(value, null, -1, 2) - const mapping = this.selectTableMapping(value, chartInfo.param.valueMapping) + // const mapping = this.selectTableMapping(value, chartInfo.param.valueMapping) data.values = value data.showValue = showValue - data.mapping = mapping + data.legend = this.handleLegend(chartInfo, data, expressionIndex, dataIndex, colorIndex) + // data.mapping = mapping data.keys = '' // eslint-disable-next-line vue/no-mutating-props arr.forEach((item) => { @@ -97,12 +118,38 @@ export default { }) return returnData }, - selectTableMapping () { - + selectTableMapping (row, valueMapping) { + const obj = {} + this.columns.forEach((column) => { + if (valueMapping[column.title]) { + obj[column.title + 'mapping'] = '' + if (this.chartInfo.param.valueMapping.show) { + valueMapping[column.title].forEach(item => { + if (item.type === 'value') { + if (row.values == item.value) { + obj[column.title + 'mapping'] = item + } + } + if (item.type === 'range') { + if (row.values >= item.from && row.values <= item.to) { + obj[column.title + 'mapping'] = item + } + } + if (item.type === 'regx') { + const reg = new RegExp(item.regx) + if (reg.test(row.values)) { + obj[column.title + 'mapping'] = item + } + } + }) + } + } + }) + return obj }, tableDataSort (orderBy) { - }, + } }, mounted () { this.initChart() diff --git a/nezha-fronted/src/components/chart/panelChart.vue b/nezha-fronted/src/components/chart/panelChart.vue index 771dce0e7..5666615f2 100644 --- a/nezha-fronted/src/components/chart/panelChart.vue +++ b/nezha-fronted/src/components/chart/panelChart.vue @@ -141,6 +141,16 @@ export default { break } case 'system': { + console.log(this.chartInfo) + const params = { + q: '', + stat: startTime, + end: endTime, + resultType: 'matrix' + } + this.$get('/stat', params).then(res => { + console.log(res) + }) this.loading = false break } @@ -154,7 +164,7 @@ export default { } if (this.chartInfo.type === 'diagram') { this.chartData = [this.chartInfo.param.topo] - if (!this.chartInfo.param.topo || !this.chartInfo.param.topo.pens.length){ + if (!this.chartInfo.param.topo || !this.chartInfo.param.topo.pens.length) { this.chartData = [] } else { this.chartData = [this.chartInfo.param.topo] diff --git a/nezha-fronted/src/components/common/login.vue b/nezha-fronted/src/components/common/login.vue index 930b56f4e..2cf2c5af5 100644 --- a/nezha-fronted/src/components/common/login.vue +++ b/nezha-fronted/src/components/common/login.vue @@ -153,9 +153,9 @@ export default { methods: { ...mapActions(['loginSuccess']), login () { - // if (this.loading || !this.license.valid || !this.license.token) { - // return - // } + if (this.loading || !this.license.valid || !this.license.token) { + return + } if (this.validateLogin() && (this.$route.path == '/' || this.$route.path == '/login')) { this.loading = true this.$post('/sys/login', this.loginData).then(res => { diff --git a/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue b/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue index db139d1dd..6eaea19e8 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue +++ b/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue @@ -434,8 +434,71 @@ + + +
+
+ {{$t('dashboard.panel.chartForm.columns')}} +
+
+
+ + + + + {{item.value}} + + + + + + + + + + + + + + +
+ + +
+
Title
+
+ + + +
+
Unit
+
+ + +
+ +
+
Display
+
+ + + +
+
+
+
+ Add Colums +
+
+ -
+
{{$t('dashboard.panel.chartForm.valueMapping')}} +
+
Columns
+
+ + +
Display
@@ -575,68 +644,6 @@
- - -
-
- {{$t('dashboard.panel.chartForm.columns')}} -
-
-
- - - - - {{item.value}} - - - - - - - - - - - - - - -
- - -
-
Title
-
- - - -
-
Unit
-
- - -
- -
-
Display
-
- - - -
-
-
-
- Add Colums -
-
@@ -793,7 +800,11 @@ export default { statistics: 'last', columns: [], tags: [], - indexs: '' + indexs: '', + valueMapping: { + show: true, + mapping: [] + } } break case 'log': diff --git a/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js b/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js index 9c5f7c384..0abf0500b 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js +++ b/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js @@ -301,7 +301,7 @@ export default { }, addMapping () { const bacColor = randomcolor() - this.chartConfig.param.valueMapping.mapping.push({ + const obj = { type: 'value', show: true, value: undefined, @@ -310,7 +310,11 @@ export default { bac: bacColor + 'FF', text: ColorReverse(bacColor) + 'FF' } - }) + } + if (this.chartConfig.type === 'table') { + obj.column = '' + } + this.chartConfig.param.valueMapping.mapping.push(obj) this.change() }, copyMapping (index) { diff --git a/nezha-fronted/src/components/common/rightBox/chart/systemChartConfig.vue b/nezha-fronted/src/components/common/rightBox/chart/systemChartConfig.vue index b3161a517..a439bd063 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/systemChartConfig.vue +++ b/nezha-fronted/src/components/common/rightBox/chart/systemChartConfig.vue @@ -26,7 +26,7 @@ class="form-item--half-width" prop="param.systemGroup" > - + @@ -36,7 +36,7 @@ class="form-item--half-width" prop="param.systemSelect" > - + @@ -194,148 +194,6 @@
- -
-
- {{$t('dashboard.panel.chartForm.valueMapping')}} - -
- - -
-
- - - - - {{item.value}} - - - {{item.from}} -> {{item.to}} - - - {{item.regx}} - -
- - {{item.display || "T"}} - -
-
-
- - - - - - - - - - - -
- - -
- - - -
- - - - - - - - - - - - -
- -
-
Display
-
- - - - -
-
-
-
- Add valueMapping -
-
-
-
-
@@ -397,6 +255,154 @@ Add Colums
+ + +
+
+ {{$t('dashboard.panel.chartForm.valueMapping')}} + +
+ + +
+
+ + + + + {{item.value}} + + + {{item.from}} -> {{item.to}} + + + {{item.regx}} + +
+ + {{item.display || "T"}} + +
+
+
+ + + + + + + + + + + +
+ + +
+ + + +
+ + + + + + + + + + + + +
+ +
+
Columns
+
+ + + +
+
Display
+
+ + + + +
+
+
+
+ Add valueMapping +
+
+
+
@@ -405,11 +411,13 @@ import publicConfig from '@/components/common/rightBox/chart/publicConfig' import chartTypeShow from '@/components/common/rightBox/chart/chartTypeShow' import nezhaColor from '@/components/common/nezhaColor' +import VueTagsInput from '@johmun/vue-tags-input' export default { name: 'systemChartConfig', mixins: [publicConfig, chartTypeShow], components: { - nezhaColor + nezhaColor, + VueTagsInput }, data () { return { @@ -516,11 +524,16 @@ export default { systemGroup: '', systemSelect: '', indexs: '', + tags: [], sort: 'desc', limit: 100, nullType: 'null', statistics: 'last', - columns: [] + columns: [], + valueMapping: { + show: true, + mapping: [] + } } break } @@ -533,6 +546,17 @@ export default { this.chartConfig.param.systemSelect = '' this.groupList = item.group this.selectList = JSON.parse(JSON.stringify(item.select)) + }, + systemGroupChange () { + this.chartConfig.param.group = this.chartConfig.param.systemGroup.map(item => { + const obj = this.groupList.find(group => group.name === item) + return obj + }) + this.change() + }, + systemSelectChange () { + this.chartConfig.param.select = this.selectList.find(item => item.name === this.chartConfig.param.systemSelect) + this.change() } }, created () {