diff --git a/nezha-fronted/src/components/charts/chart-list-group.vue b/nezha-fronted/src/components/charts/chart-list-group.vue index 90a01c17e..984cfd3d3 100644 --- a/nezha-fronted/src/components/charts/chart-list-group.vue +++ b/nezha-fronted/src/components/charts/chart-list-group.vue @@ -146,6 +146,20 @@ :chart-index="item.chartIndex" > + {chartBySync(item)}" + @dropmenu-change="(show) => {dropmenuChange(item.id, show)}" + :is-lock="panelLock" + :panel-id="filter.panelId" + :chart-data="item" + :chart-index="index" + > + + {chartBySync(item)}" + @dropmenu-change="(show) => {dropmenuChange(item.id, show)}" + :is-lock="panelLock" + :panel-id="filter.panelId" + :chart-data="item" + :chart-index="index" + > + 0) { + if (filterType === 'showFullScreen') { // 全屏查询 + this.$refs['editChart' + chartItem.id][0].setData(chartItem, null, + this.filter.panelId, null, filterType) + } else { + this.$refs['editChart' + chartItem.id][0].setData(chartItem, null, + this.filter.panelId, null, '') + } + } + return + } if (chartItem.type == 'text') { if (this.$refs['editChart' + chartItem.id] && this.$refs['editChart' + chartItem.id].length > 0) { if (filterType === 'showFullScreen') { // 全屏查询 diff --git a/nezha-fronted/src/components/charts/diagram-chart.vue b/nezha-fronted/src/components/charts/diagram-chart.vue new file mode 100644 index 000000000..be8006939 --- /dev/null +++ b/nezha-fronted/src/components/charts/diagram-chart.vue @@ -0,0 +1,218 @@ + + + + + + + + + + + + {{chartData.name}} + + + + + + + + + + + + + + + + + + {{$t('dashboard.edit')}} + + {{$t('dashboard.delete')}} + + {{$t('dashboard.duplicate')}} + + {{$t('overall.syncChart')}} + + + + + + + + + + + + {{data.name}} + + + + + + + + + + + + + + + diff --git a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue new file mode 100644 index 000000000..6fd497755 --- /dev/null +++ b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue @@ -0,0 +1,2610 @@ + + + + + + + + + + + + + + + + + + + {{item.group}} + + + + + + + + + + + + + + + + {{ $t('overall.uploadCustomPicture') }} + + + + + + + + + + + + + + + + + + + + {{$t('project.topology.defaultLineType')}} + + + + + + + + {{item.name}} + + + + + + + + + + + + + {{$t('project.topology.preview')}} + + + {{$t('project.topology.previewExit')}} + + + {{$t('project.topology.save')}} + + + {{$t('project.topology.exit')}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + endpoint + + + + + + + + + + + + + + + + + + + + + alert + + + + + alert + + + + + + {{ $t('overall.name') }} + + + + + + {{ $t('overall.folder') }} + + + + + + + + + + + + + {{$t('overall.dragFileTip')}},{{$t('overall.or')}} {{$t('overall.clickUpload')}} + + + + + + + + {{$t('project.topology.exit')}} + + + + {{$t('project.topology.save')}} + + + + + + + + + + + diff --git a/nezha-fronted/src/components/common/js/constants.js b/nezha-fronted/src/components/common/js/constants.js index f5bf2c517..279d6d5a8 100644 --- a/nezha-fronted/src/components/common/js/constants.js +++ b/nezha-fronted/src/components/common/js/constants.js @@ -172,6 +172,17 @@ export const statisticsList = [ { value: 'different', label: i18n.t('dashboard.panel.chartForm.statisticsVal.different') } ] +export const alignList = [ + { value: 'left', label: i18n.t('dashboard.panel.chartForm.alignList.left') }, + { value: 'center', label: i18n.t('dashboard.panel.chartForm.alignList.center') }, + { value: 'right', label: i18n.t('dashboard.panel.chartForm.alignList.right') } +] + +export const lockList = [ + { value: 1, label: i18n.t('dashboard.panel.chartForm.lockList.on') }, + { value: 0, label: i18n.t('dashboard.panel.chartForm.lockList.off') } +] + export const chart = { varType: [ { value: '1', label: i18n.t('asset.asset') }, diff --git a/nezha-fronted/src/components/common/js/tools.js b/nezha-fronted/src/components/common/js/tools.js index 9a82bec27..591cc2991 100644 --- a/nezha-fronted/src/components/common/js/tools.js +++ b/nezha-fronted/src/components/common/js/tools.js @@ -4,7 +4,7 @@ import i18n from '../i18n' import bus from '@/libs/bus' import moment from 'moment-timezone' /* 弹窗点击外部后关闭 */ -const exceptClassName = ['prevent-clickoutside', 'config-dropdown', 'nz-pop', 'el-picker', 'chart-box-dropdown', 'metric-dropdown', 'el-cascader__dropdown', 'no-style-class', 'el-message-box', 'nz-dashboard-dropdown', 'el-autocomplete-suggestion', 'nz-temp-box', 'el-time-panel'] // clickoutside排除的class(白名单) no-style-class:没有任何样式的class +const exceptClassName = ['prevent-clickoutside', 'config-dropdown', 'nz-pop', 'el-picker', 'chart-box-dropdown', 'metric-dropdown', 'el-cascader__dropdown', 'no-style-class', 'el-message-box', 'nz-dashboard-dropdown', 'el-autocomplete-suggestion', 'nz-temp-box', 'el-time-panel', 'topology-dialog', 'el-dropdown-menu', 'el-select-dropdown'] // clickoutside排除的class(白名单) no-style-class:没有任何样式的class export const clickoutside = { // 初始化指令 bind (el, binding, vnode) { diff --git a/nezha-fronted/src/components/common/language/cn.js b/nezha-fronted/src/components/common/language/cn.js index 5bc0cb2b5..5b4e7d103 100644 --- a/nezha-fronted/src/components/common/language/cn.js +++ b/nezha-fronted/src/components/common/language/cn.js @@ -253,6 +253,8 @@ const cn = { thresholds: '阈值', group: '组', remark: '描述', + lock: '锁', + align: '对齐方式', typeVal: { line: { label: '曲线图' @@ -282,6 +284,9 @@ const cn = { text: { label: '文本' }, + diagram: { + label: '示意图' + }, group: { label: '组' } @@ -297,6 +302,15 @@ const cn = { different: 'Different', null: 'None' }, + alignList: { + left: '左对齐', + right: '右对齐', + center: '居中' + }, + lockList: { + on: '开', + off: '关' + }, width: '宽', high: '高', metric: '指标', @@ -727,7 +741,7 @@ const cn = { download: '下载', osType: 'OS 类型', autoScript: '自动安装脚本', - type: 'Agent类型', + type: 'Agent类型' } }, agent: { @@ -1230,7 +1244,7 @@ const cn = { list: '列表', delete: '删除', save: '保存', - info: '信息', + info: '信息' } }, project: { @@ -1419,7 +1433,8 @@ const cn = { imgError: '请上传图片', folder: '目录', selMod: '请个所有节点绑定module', - none: '无' + none: '无', + previewExit: '继续编辑' }, update: '更新' }, @@ -1604,23 +1619,23 @@ const cn = { add: '新增', edit: '修改', delete: '删除', - mibBrowser: 'MIB浏览器', + mibBrowser: 'MIB浏览器' }, credential: { view: '查看', add: '新增', edit: '修改', - delete: '删除', + delete: '删除' }, system: { basic: '基础设置', email: 'Email', terminal: '终端', ldap: 'LDAP', - apiKey : { + apiKey: { add: '新增', edit: '修改', - delete: '删除', + delete: '删除' } }, terminalLog: { @@ -1636,7 +1651,7 @@ const cn = { reset: '重置' }, apikey: { - apiKey: 'Api Key', + apiKey: 'Api Key' } }, ...zhLocale diff --git a/nezha-fronted/src/components/common/language/en.js b/nezha-fronted/src/components/common/language/en.js index 93edef8c4..1432d3c7c 100644 --- a/nezha-fronted/src/components/common/language/en.js +++ b/nezha-fronted/src/components/common/language/en.js @@ -269,6 +269,8 @@ const en = { thresholds: 'Thresholds', group: 'Group', remark: 'Description', + lock: 'Lock', + align: 'Align', typeVal: { line: { label: 'Line Chart' // "曲线图" @@ -298,6 +300,9 @@ const en = { text: { label: 'Text' }, + diagram: { + label: 'Diagram' + }, group: { label: 'Group' } @@ -313,6 +318,15 @@ const en = { different: 'Different', null: 'None' }, + alignList: { + left: 'Left', + right: 'Right', + center: 'Center' + }, + lockList: { + on: 'ON', + off: 'OFF' + }, width: 'Width', // "宽" high: 'Height', // "高" metric: 'Metric', // "指标" @@ -1424,7 +1438,8 @@ const en = { imgError: 'Please upload pictures', folder: 'Folder', selMod: 'Please bind module for all nodes', - none: 'None' + none: 'None', + previewExit: 'Continue' }, update: '更新' }, diff --git a/nezha-fronted/src/components/common/project/L5/CanvasProps.vue b/nezha-fronted/src/components/common/project/L5/CanvasProps.vue index 1003e2f8c..a2f7be05c 100644 --- a/nezha-fronted/src/components/common/project/L5/CanvasProps.vue +++ b/nezha-fronted/src/components/common/project/L5/CanvasProps.vue @@ -11,7 +11,7 @@ - + - - - + + + @@ -62,7 +62,7 @@ export default { data () { return { tempDom: { height: 400, width: '' }, - chartDataTemp: { id: 8832, prev: null, next: null, panelId: 0, title: '123', span: 12, height: 13, createAt: '2021-01-27 07:36:19', unit: 2, weight: 0, pid: null, buildIn: null, seq: null, param: { last: 0, legendValue: { total: 'off', min: 'off', avg: 'off', last: 'off', max: 'off' }, threshold: '', url: '', nullType: 'connected' }, sync: null, asset: null, isLoaded: true, from: '__vue_devtool_undefined__', draggable: true, resizable: true, editable: true }, + chartDataTemp: { id: 8832, prev: null, next: null, panelId: 0, title: '123', span: 12, height: 12, createAt: '2021-01-27 07:36:19', unit: 2, weight: 0, pid: null, buildIn: null, seq: null, param: { last: 0, legendValue: { total: 'off', min: 'off', avg: 'off', last: 'off', max: 'off' }, threshold: '', url: '', nullType: 'connected' }, sync: null, asset: null, isLoaded: true, from: '__vue_devtool_undefined__', draggable: true, resizable: true, editable: true }, chartData: {}, filter: { end_time: bus.timeFormate(bus.getOffsetTimezoneData(), 'yyyy-MM-dd hh:mm:ss'), diff --git a/nezha-fronted/src/components/common/project/L5/topologyTopTool.vue b/nezha-fronted/src/components/common/project/L5/topologyTopTool.vue index 04038998f..34ab51a63 100644 --- a/nezha-fronted/src/components/common/project/L5/topologyTopTool.vue +++ b/nezha-fronted/src/components/common/project/L5/topologyTopTool.vue @@ -106,7 +106,7 @@ export default { } }, mounted () { - const dataOption = getTopology(this.index).data + const dataOption = this.index == -2 ? getTopology(-1).data : getTopology(this.index).data Object.keys(this.option).forEach(key => { if (key === 'scale') { this.scaleNum = (JSON.stringify(dataOption[key]) ? parseInt(dataOption[key] * 100) : this.scaleNum) diff --git a/nezha-fronted/src/components/page/dashboard/chartBox.vue b/nezha-fronted/src/components/page/dashboard/chartBox.vue index 4ca8c8fb0..ea722e317 100644 --- a/nezha-fronted/src/components/page/dashboard/chartBox.vue +++ b/nezha-fronted/src/components/page/dashboard/chartBox.vue @@ -141,6 +141,29 @@ position: relative; top: 1px; } + .topology-box{ + width: 100%; + height: 242px; + border: 1px solid #E7EAED; + border-radius: 2px; + position: relative; + } + .topology-dialog{ + position: fixed !important; + height: 100vh; + width: 100vw; + top: 0; + left: 0; + z-index: 1; + } + .topology-mc{ + width: 100%; + height: 100%; + position: absolute; + top: 0; + left: 0; + z-index: 10; + } @@ -245,7 +268,7 @@ - + + + + + + {{item.label}} + + + + + + + + {{item.label}} + + + @@ -275,11 +314,20 @@ + {{$t('dashboard.panel.chartForm.content')}} + + + + + + + + - + {{$t('alert.config.expr')}} @@ -294,7 +342,7 @@ - + + + @@ -448,6 +498,7 @@ import selectPanel from '../../common/popBox/selectPanel' import nezhaColor from '../../common/nezhaColor' import i18n from '../../common/i18n' import { fromRoute } from '@/components/common/js/constants' +import diagram from '@/components/common/ChartDiagram/diagram' const rz = { methods: { rz (e) { @@ -481,7 +532,8 @@ export default { }, filterPanel: '', statisticsList: this.$CONSTANTS.statisticsList, - + alignList: this.$CONSTANTS.alignList, + lockList: this.$CONSTANTS.lockList, promqlCount: 1, promqlKeys: [], elementIds: [], @@ -548,6 +600,10 @@ export default { id: 'url', name: this.$t('dashboard.panel.chartForm.typeVal.url.label') }, + { + id: 'diagram', + name: this.$t('dashboard.panel.chartForm.typeVal.diagram.label') + }, { id: 'group', name: this.$t('dashboard.panel.chartForm.typeVal.group.label') @@ -590,7 +646,8 @@ export default { varTypeArr: [ { name: 'Asset', id: 1 }, { name: 'Endpoint', id: 2 } - ] + ], + topologyDialog: false // metricStore: [] } }, @@ -600,7 +657,8 @@ export default { 'promql-input': promqlInput, 'rich-text-editor': richTextEditor, selectPanel, - nezhaColor + nezhaColor, + diagram }, mounted () { this.$nextTick(() => { @@ -1398,6 +1456,12 @@ export default { this.editChart.span = 12 this.editChart.height = 6 this.setIsGroup() + } else if (chartType === 'diagram') { + this.editChart.param = { + lock: 0, + align: 'center', + topo: {} + } } else { this.setIsOtherChart() if (chartType === 'bar' || chartType === 'line' || chartType === 'stackArea') { @@ -1678,6 +1742,12 @@ export default { }, getMetricOptions () { return this.metricOptions + }, + topologyDialogChange (flag, data) { + this.topologyDialog = flag + if (data) { + this.editChart.param.topo = data + } } }, created () { @@ -1759,7 +1829,7 @@ export default { } else { this.createData(this.showPanel.id, '', n.unit) } - if ( this.editChart.param && !this.editChart.param.statistics) { + if (this.editChart.param && !this.editChart.param.statistics) { this.editChart.param.statistics = 'null' } } diff --git a/nezha-fronted/static/config.json b/nezha-fronted/static/config.json index 5f74f5d01..864f961ff 100644 --- a/nezha-fronted/static/config.json +++ b/nezha-fronted/static/config.json @@ -1 +1 @@ -{"baseUrl":"/", "version": "21.04"} +{"baseUrl":"http://192.168.40.42:8080/nz-admin/", "version": "21.04"}