diff --git a/nezha-fronted/src/assets/css/common/rightBoxCommon.scss b/nezha-fronted/src/assets/css/common/rightBoxCommon.scss index 982c1d4d0..892477f51 100644 --- a/nezha-fronted/src/assets/css/common/rightBoxCommon.scss +++ b/nezha-fronted/src/assets/css/common/rightBoxCommon.scss @@ -56,7 +56,7 @@ padding: 0 30px; overflow-x: hidden; overflow-y: auto; - + box-sizing: border-box; .el-textarea__inner { padding: 5px 70px 4px 15px; } diff --git a/nezha-fronted/src/assets/css/components/common/rightBox/chartRightBox/chartRightBox.scss b/nezha-fronted/src/assets/css/components/common/rightBox/chartRightBox/chartRightBox.scss new file mode 100644 index 000000000..f48ef1dbc --- /dev/null +++ b/nezha-fronted/src/assets/css/components/common/rightBox/chartRightBox/chartRightBox.scss @@ -0,0 +1,16 @@ +.right-box__container{ + .chart-config{ + .el-form { + padding-top: 0px; + } + .chart-title .nz-icon-arrow-down{ + display: inline-block; + transition: transform .3s; + } + .chart-title .nz-icon-arrow-down.is-active{ + transform: rotate( + -90deg + ); + } + } +} diff --git a/nezha-fronted/src/assets/css/components/index.scss b/nezha-fronted/src/assets/css/components/index.scss index a635f8b58..9011bf51d 100644 --- a/nezha-fronted/src/assets/css/components/index.scss +++ b/nezha-fronted/src/assets/css/components/index.scss @@ -43,6 +43,7 @@ @import './common/rightBox/locationCascader.scss'; @import './common/rightBox/menuBox.scss'; @import './common/rightBox/moduleBox.scss'; +@import './common/rightBox/chartRightBox/chartRightBox'; @import './common/table/alert/alertMessageTable.scss'; @import './common/table/alert/alertRuleTable.scss'; @import './common/table/alert/alertSilenceTable.scss'; @@ -87,6 +88,7 @@ @import './page/dashboard/panel.scss'; @import './page/monitor/project/project.scss'; + @import 'common/v-selectpagenew/selectpage.scss'; @import "common/paramBpx/paramBox.scss"; diff --git a/nezha-fronted/src/components/chart/chart.vue b/nezha-fronted/src/components/chart/chart.vue index 10f5a788f..007a19ca1 100644 --- a/nezha-fronted/src/components/chart/chart.vue +++ b/nezha-fronted/src/components/chart/chart.vue @@ -8,6 +8,13 @@ :chart-info="chartInfo" :chart-option="chartOption" > + + + + + + + @@ -30,7 +37,8 @@ import chartTimeSeries from './chart/chartTimeSeries' import chartTreemap from './chart/chartTreemap' import chartUrl from './chart/chartUrl' import chartValue from './chart/chartValue' -import { getOption, isTimeSeries } from './chart/tools' +import chartHexagon from './chart/chartHexagon' +import { getOption, isTimeSeries, isHexagonFigure } from './chart/tools' import lodash from 'lodash' export default { @@ -52,7 +60,8 @@ export default { chartTimeSeries, chartTreemap, chartUrl, - chartValue + chartValue, + chartHexagon }, props: { chartInfo: Object, @@ -76,7 +85,11 @@ export default { } }, methods: { - isTimeSeries + isTimeSeries, + isHexagonFigure, + resize () { + this.$refs['chart' + this.chartInfo.id].resize() + } }, mounted () { } diff --git a/nezha-fronted/src/components/chart/chart/chartHexagon.vue b/nezha-fronted/src/components/chart/chart/chartHexagon.vue new file mode 100644 index 000000000..553cfc036 --- /dev/null +++ b/nezha-fronted/src/components/chart/chart/chartHexagon.vue @@ -0,0 +1,329 @@ + + + + + + + + + + diff --git a/nezha-fronted/src/components/chart/chart/tools.js b/nezha-fronted/src/components/chart/chart/tools.js index c2a929278..e77be5ae3 100644 --- a/nezha-fronted/src/components/chart/chart/tools.js +++ b/nezha-fronted/src/components/chart/chart/tools.js @@ -51,6 +51,10 @@ export function isTimeSeries (type) { return type === chartType.line || type === chartType.area || type === chartType.point } +export function isHexagonFigure (type) { + return type === chartType.hexagonFigure +} + export function initColor (colorNum = 20) { const colorList = [ '#FF5200', '#3685FF', '#FF8D00', '#00DCA2', diff --git a/nezha-fronted/src/components/chart/chartList.vue b/nezha-fronted/src/components/chart/chartList.vue index fba7c4b85..14a110da5 100644 --- a/nezha-fronted/src/components/chart/chartList.vue +++ b/nezha-fronted/src/components/chart/chartList.vue @@ -91,6 +91,7 @@ export default { }, containerResizedEvent (i, newH, newW, newHPx, newWPx) { // TODO 重新渲染图表 + // this.$refs['chart' + i].resize() } }, mounted () { diff --git a/nezha-fronted/src/components/chart/panelChart.vue b/nezha-fronted/src/components/chart/panelChart.vue index ed883b0c7..d0fee0b10 100644 --- a/nezha-fronted/src/components/chart/panelChart.vue +++ b/nezha-fronted/src/components/chart/panelChart.vue @@ -8,6 +8,7 @@ @@ -106,7 +107,43 @@ export default { case 4: { break } + case 'hexagonFigure': { + this.getHexagonFigureData().then(res => { + this.chartData = res + }) + break + } } + }, + getHexagonFigureData () { + return new Promise(resolve => { + this.$get('stat/alertMessage/topN', { size: 48, dimension: 'module' }).then(response => { + if (response.code === 200) { + const moduleData = response.data.list + moduleData.sort((a, b) => b.alertNum - a.alertNum) + const alertTopModules = moduleData.slice(0, 48) + const requests = alertTopModules.map(a => axios.get(`stat/alertMessage/severity?moduleId=${a.id}`)) + const moduleStateData = [] + axios.all(requests).then(result => { + result.forEach((alert, i) => { + const severityData = {} + alert.data.data.list && alert.data.data.list.forEach(a => { + severityData[a.name] = a.num + }) + !severityData.P1 && (severityData.P1 = 0) + !severityData.P2 && (severityData.P2 = 0) + !severityData.P3 && (severityData.P3 = 0) + moduleStateData.push({ ...alertTopModules[i], alert: [severityData] }) + }) + console.log(moduleStateData) + resolve(moduleStateData) + }) + } + }) + }) + }, + resize() { + this.$refs.chart.resize() } }, mounted () { diff --git a/nezha-fronted/src/components/chart/testData.js b/nezha-fronted/src/components/chart/testData.js index 576de5fff..3d7f01533 100644 --- a/nezha-fronted/src/components/chart/testData.js +++ b/nezha-fronted/src/components/chart/testData.js @@ -444,6 +444,219 @@ const chartData = { varType: null, varId: null, varName: null + }, + { + id: 690502, + name: '324', + panelId: 1243, + groupId: 0, + span: 6, + height: 4, + updateBy: 1, + updateAt: '2021-11-10 09:51:06', + type: 'hexagonFigure', + unit: 2, + weight: 2, + dataSource: 'hexagonFigure', + param: '{' + + ' "from":"module",' + + ' "length":"48",' + + ' "showTooltip": true ,' + + ' "col":"8"' + + '}', + pid: null, + buildIn: 0, + remark: '123', + seq: null, + x: 6, + y: 4, + w: 6, + h: 4, + i: 690502, + elements: [ + { + id: 68527, + chartId: 690483, + expression: 'up{asset="44.37"}', + type: 'expert', + legend: '', + buildIn: 0, + seq: null + }, + { + id: 68528, + chartId: 690483, + expression: 'Hadoop_HBase_Healthy', + type: 'expert', + legend: '', + buildIn: 0, + seq: null + } + ], + sync: null, + panel: { + id: 1243, + name: 'test', + createBy: null, + type: null, + link: null, + pid: null, + weight: null, + buildIn: null, + seq: null, + children: null, + parent: null, + chartNum: null + }, + group: { + id: 0, + name: null, + panelId: null, + groupId: null, + span: null, + height: null, + updateBy: null, + updateAt: null, + type: null, + unit: null, + weight: null, + param: null, + pid: null, + buildIn: null, + remark: null, + seq: null, + x: null, + y: null, + elements: null, + sync: null, + panel: null, + group: null, + children: null, + chartNums: null, + asset: null, + varType: null, + varId: null, + varName: null + }, + children: [ + { + id: 690502, + name: '123', + panelId: 1243, + groupId: 690501, + span: 12, + height: 4, + updateBy: 1, + updateAt: '2021-11-10 09:51:15', + type: 'line', + unit: 2, + weight: 3, + param: { + last: 0, + legendValue: { + total: 'off', + min: 'off', + avg: 'off', + last: 'off', + max: 'off' + }, + threshold: '123', + valueMapping: { + mapping: [ + { + color: { + bac: '#fff', + text: '#000' + }, + text: '', + value: '' + } + ], + type: 'text' + }, + url: '', + nullType: 'null' + }, + pid: null, + buildIn: 0, + remark: '', + seq: null, + x: 0, + y: 0, + w: 12, + h: 4, + i: 690489, + elements: [ + { + id: 68543, + chartId: 690502, + expression: '123', + type: 'expert', + legend: '', + buildIn: 0, + seq: null + } + ], + sync: null, + panel: { + id: 1243, + name: 'test', + createBy: null, + type: null, + link: null, + pid: null, + weight: null, + buildIn: null, + seq: null, + children: null, + parent: null, + chartNum: null + }, + group: { + id: 690501, + name: '123', + panelId: null, + groupId: null, + span: null, + height: null, + updateBy: null, + updateAt: null, + type: null, + unit: null, + weight: null, + param: null, + pid: null, + buildIn: null, + remark: null, + seq: null, + x: null, + y: null, + elements: null, + sync: null, + panel: null, + group: null, + children: null, + chartNums: null, + asset: null, + varType: null, + varId: null, + varName: null + }, + children: [ + + ], + chartNums: null, + asset: null, + varType: null, + varId: null, + varName: null + } + ], + chartNums: null, + asset: null, + varType: null, + varId: null, + varName: null } ] }, diff --git a/nezha-fronted/src/components/common/honeycomb/hexagonFigureSvg.vue b/nezha-fronted/src/components/common/honeycomb/hexagonFigureSvg.vue index 0db2e3c7f..46fafacf3 100644 --- a/nezha-fronted/src/components/common/honeycomb/hexagonFigureSvg.vue +++ b/nezha-fronted/src/components/common/honeycomb/hexagonFigureSvg.vue @@ -173,6 +173,7 @@ export default { deep: true, handler (n) { this.init() + console.log(n) } }, col: { // 列数 diff --git a/nezha-fronted/src/components/common/js/constants.js b/nezha-fronted/src/components/common/js/constants.js index aa7fd6bb0..0c03acad0 100644 --- a/nezha-fronted/src/components/common/js/constants.js +++ b/nezha-fronted/src/components/common/js/constants.js @@ -404,7 +404,8 @@ export const chartType = { assetInfo: 'assetInfo', endpointInfo: 'endpointInfo', topology: 'topology', - map: 'map' + map: 'map', + hexagonFigure: 'hexagonFigure' } export const chartLegendPlacement = { diff --git a/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue b/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue new file mode 100644 index 000000000..64336d970 --- /dev/null +++ b/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue @@ -0,0 +1,271 @@ + + + + + + + + {{editChart.id ? $t("dashboard.panel.editChartTitle") : $t("dashboard.panel.createChartTitle")}} + {{editChart.id ? $t("dashboard.panel.editChartTempTitle") : $t("dashboard.panel.createChartTempTitle")}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.name}} + + + + + + + + + + + + {{$t('dashboard.panel.chartForm.dataConfig')}} + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nezha-fronted/src/components/common/rightBox/chart/logsChartConfig.vue b/nezha-fronted/src/components/common/rightBox/chart/logsChartConfig.vue new file mode 100644 index 000000000..b53662a50 --- /dev/null +++ b/nezha-fronted/src/components/common/rightBox/chart/logsChartConfig.vue @@ -0,0 +1,15 @@ + + + logs + + + + + + diff --git a/nezha-fronted/src/components/common/rightBox/chart/metricsChartConfig.vue b/nezha-fronted/src/components/common/rightBox/chart/metricsChartConfig.vue new file mode 100644 index 000000000..ebff6e581 --- /dev/null +++ b/nezha-fronted/src/components/common/rightBox/chart/metricsChartConfig.vue @@ -0,0 +1,183 @@ + + + + + + + + + + + + + + + + {{$t('dashboard.panel.chartForm.legend')}} + + {{$t('dashboard.panel.chartForm.legendTip')}} + + + + + + + + + + + + + + + + + + diff --git a/nezha-fronted/src/components/common/rightBox/chart/otherChartConfig.vue b/nezha-fronted/src/components/common/rightBox/chart/otherChartConfig.vue new file mode 100644 index 000000000..6e31823f1 --- /dev/null +++ b/nezha-fronted/src/components/common/rightBox/chart/otherChartConfig.vue @@ -0,0 +1,15 @@ + + + other + + + + + + diff --git a/nezha-fronted/src/components/common/rightBox/chart/systemChartConfig.vue b/nezha-fronted/src/components/common/rightBox/chart/systemChartConfig.vue new file mode 100644 index 000000000..a95c7954d --- /dev/null +++ b/nezha-fronted/src/components/common/rightBox/chart/systemChartConfig.vue @@ -0,0 +1,15 @@ + + + system + + + + + + diff --git a/nezha-fronted/src/components/page/dashboard/panel.vue b/nezha-fronted/src/components/page/dashboard/panel.vue index 21d9c3d3d..b0511c472 100644 --- a/nezha-fronted/src/components/page/dashboard/panel.vue +++ b/nezha-fronted/src/components/page/dashboard/panel.vue @@ -105,7 +105,34 @@ - + + + + + + + + + + + + + + + @@ -118,6 +145,7 @@