diff --git a/nezha-fronted/src/components/charts/chart-group.vue b/nezha-fronted/src/components/charts/chart-group.vue
new file mode 100644
index 000000000..a87ac56ff
--- /dev/null
+++ b/nezha-fronted/src/components/charts/chart-group.vue
@@ -0,0 +1,300 @@
+
+
+
+
+
+
+
+
+
+
+
+ {{chartData.title}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nezha-fronted/src/components/charts/chart-list-group.vue b/nezha-fronted/src/components/charts/chart-list-group.vue
new file mode 100644
index 000000000..2e2a4bc1c
--- /dev/null
+++ b/nezha-fronted/src/components/charts/chart-list-group.vue
@@ -0,0 +1,1730 @@
+
+
+
+
+
+
+
+
+
+ {dropmenuChange(item.id, show)}"
+ :chart-data="item"
+ >
+
+ {dropmenuChange(item.id, show)}"
+ :chart-index="item.chartIndex">
+
+ {dropmenuChange(item.id, show)}"
+ :chart-index="item.chartIndex">
+
+ {dropmenuChange(item.id, show)}"
+ :chart-index="item.chartIndex">
+
+ {dropmenuChange(item.id, show)}"
+ :editChartId="'editChartId' + item.id"
+ >
+
+ {dropmenuChange(item.id, show)}"
+ :is-lock="panelLock"
+ :panel-id="filter.panelId"
+ :chart-data="item"
+ :chart-index="item.chartIndex"
+ >
+
+ {dropmenuChange(item.id, show)}"
+ >
+
+ {dropmenuChange(item.id, show)}"
+ :chart-index="item.chartIndex">
+
+
+
+
+
+
+
+
diff --git a/nezha-fronted/src/components/charts/chart-list.vue b/nezha-fronted/src/components/charts/chart-list.vue
index 943602b14..4ce04c9b7 100644
--- a/nezha-fronted/src/components/charts/chart-list.vue
+++ b/nezha-fronted/src/components/charts/chart-list.vue
@@ -170,6 +170,21 @@
:panel-id="filter.panelId"
@dropmenu-change="(show) => {dropmenuChange(item.id, show)}"
:chart-index="index">
+ {dropmenuChange(item.id, show)}"
+ :chart-index="index">
@@ -190,6 +205,7 @@ import chartDataFormat from './chartDataFormat'
import chartAlertList from './chart-alert-list'
import textChart from './text-chart'
import chartPie from './chart-pie'
+import chartGroup from './chart-group'
// import visNetwork from './visNetwork'
export default {
name: 'chartList',
@@ -199,7 +215,8 @@ export default {
draggable: { type: Boolean, default: true },
detail: Object,
from: { type: String },
- panelLock: { type: Boolean, default: false }
+ panelLock: { type: Boolean, default: false },
+ hasGroup: { type: Boolean, default: true }
},
components: {
@@ -211,7 +228,8 @@ export default {
chartSingleStat,
draggable,
textChart,
- chartPie
+ chartPie,
+ chartGroup
// visNetwork,
},
data () {
@@ -573,7 +591,7 @@ export default {
}
if (!param.query) delete param.query
// 根据panelId获得panel下的所有图表
- this.$get('panel/' + params.panelId + '/charts').then(response => {
+ this.$get('visual/panel/chart?id=' + params.panelId).then(response => {
if (response.code === 200) {
response.data.list.forEach((item, index) => {
item.isLoaded = false
@@ -600,6 +618,28 @@ export default {
this.dataTotalList = [...chartListTmp]
this.dataList = [...this.dataTotalList]
+ console.log(this.dataList)
+ // this.dataList.push({
+ // ...this.dataList[0],
+ // group: {
+ // id: 1,
+ // name: 'chart group'
+ // },
+ // type: 'group',
+ // span: 12,
+ // height: 600,
+ // id: 999999,
+ // children: [...this.dataList]
+ // })
+ let addGroupIndex = 0
+ this.dataList.forEach((item) => {
+ if (item.type === 'group') {
+ item.children.forEach(chart => {
+ addGroupIndex++
+ chart.chartIndex = this.dataList.length + addGroupIndex
+ })
+ }
+ })
// this.showShadow=false;
this.$nextTick(() => {
if (this.dataList.length > 0) {
@@ -721,6 +761,9 @@ export default {
// 获取一个图表具体数据,图表信息,图表位置index
getChartData (chartInfo, pos, filterType) {
const chartItem = chartInfo
+ if (chartItem.type === 'group') {
+ return
+ }
if (chartItem.type === 'assetInfo') {
if (chartItem.from != this.$CONSTANTS.fromRoute.endpoint) {
this.$set(chartItem, 'draggable', true)
@@ -938,6 +981,7 @@ export default {
host = chartItem.elements[innerPos].expression
}
// 处理legend别名
+ console.log(chartItem.id)
let alias = this.$refs['editChart' + chartItem.id][0].dealLegendAlias(host, chartItem.elements[innerPos].legend)
if (!alias || alias === '') {
alias = host
@@ -1497,6 +1541,9 @@ export default {
if (chartBox) {
chartBox.style.width = `${(item.span / 12) * 100}%`
chartBox.style.height = `${item.height}px`
+ if (item.type === 'group') {
+ chartBox.style.height = 'auto'
+ }
}
})
},
diff --git a/nezha-fronted/src/components/charts/text-chart.vue b/nezha-fronted/src/components/charts/text-chart.vue
index 6c3561b62..cfec0db0a 100644
--- a/nezha-fronted/src/components/charts/text-chart.vue
+++ b/nezha-fronted/src/components/charts/text-chart.vue
@@ -208,6 +208,7 @@ export default {
},
// 设置数据, filter区分
setData (chartItem, seriesItem, panelId, filter, area) {
+ console.log(chartItem);
this.$nextTick(() => {
this.resize(chartItem)
})
diff --git a/nezha-fronted/src/components/common/js/tools.js b/nezha-fronted/src/components/common/js/tools.js
index c45091578..de4d49411 100644
--- a/nezha-fronted/src/components/common/js/tools.js
+++ b/nezha-fronted/src/components/common/js/tools.js
@@ -349,6 +349,7 @@ export const chartResizeTool = {
return height - this.chartBlankHeight
},
start (vm, originalData, event, chartIndexs) {
+ console.log(vm, originalData, event, chartIndexs)
const $self = this
const data = JSON.parse(JSON.stringify(originalData)) // 将初始对象复制,后续操作使用复制对象
let shadow = vm.$refs.resizeShadow // 缩放时底部阴影dom
diff --git a/nezha-fronted/src/components/common/language/cn.js b/nezha-fronted/src/components/common/language/cn.js
index 5e05e1a42..8497a89ff 100644
--- a/nezha-fronted/src/components/common/language/cn.js
+++ b/nezha-fronted/src/components/common/language/cn.js
@@ -221,6 +221,9 @@ const cn = {
},
text: {
label: '文本'
+ },
+ group: {
+ label: '组'
}
},
statisticsVal: {
diff --git a/nezha-fronted/src/components/common/language/en.js b/nezha-fronted/src/components/common/language/en.js
index 6fadd15ca..e8091ef2f 100644
--- a/nezha-fronted/src/components/common/language/en.js
+++ b/nezha-fronted/src/components/common/language/en.js
@@ -234,6 +234,9 @@ const en = {
},
text: {
label: 'Text'
+ },
+ group: {
+ label: 'group'
}
},
statisticsVal: {
diff --git a/nezha-fronted/src/components/common/multipleTime.vue b/nezha-fronted/src/components/common/multipleTime.vue
index 362816d6b..d755c0975 100644
--- a/nezha-fronted/src/components/common/multipleTime.vue
+++ b/nezha-fronted/src/components/common/multipleTime.vue
@@ -313,7 +313,7 @@ export default {
}
},
mounted () {
- console.log(this.searchTime, 'this.searchTime')
+ // console.log(this.searchTime, 'this.searchTime')
},
methods: {
dateChange (val) {
diff --git a/nezha-fronted/src/components/common/popBox/selectPanel.vue b/nezha-fronted/src/components/common/popBox/selectPanel.vue
index 205bd06a1..d183b1a6c 100644
--- a/nezha-fronted/src/components/common/popBox/selectPanel.vue
+++ b/nezha-fronted/src/components/common/popBox/selectPanel.vue
@@ -115,7 +115,7 @@ export default {
})
}
- this.$put('/panel/tree', toUpdate)
+ this.$put('visual/panel/tree', toUpdate)
},
deletePanel (data) {
this.$emit('deletePanel', data)
diff --git a/nezha-fronted/src/components/common/rightBox/panelBox.vue b/nezha-fronted/src/components/common/rightBox/panelBox.vue
index 570923d69..54c346353 100644
--- a/nezha-fronted/src/components/common/rightBox/panelBox.vue
+++ b/nezha-fronted/src/components/common/rightBox/panelBox.vue
@@ -69,7 +69,7 @@ export default {
cancelButtonText: this.$t('tip.no'),
type: 'warning'
}).then(() => {
- this.$delete('panel?ids=' + u.id).then(response => {
+ this.$delete('visual/panel?ids=' + u.id).then(response => {
if (response.code === 200) {
this.esc()
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.deleteSuccess') })
@@ -85,7 +85,7 @@ export default {
if (valid) {
this.prevent_opt.save = true
if (this.panel.id) {
- this.$put('panel', this.panel).then(response => {
+ this.$put('visual/panel', this.panel).then(response => {
if (response.code === 200) {
this.esc()
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
@@ -96,7 +96,7 @@ export default {
this.prevent_opt.save = false
})
} else {
- this.$post('panel', this.panel).then(response => {
+ this.$post('visual/panel', this.panel).then(response => {
if (response.code === 200) {
this.esc()
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
diff --git a/nezha-fronted/src/components/common/rightBox/roleBox.vue b/nezha-fronted/src/components/common/rightBox/roleBox.vue
index 6f8aa0c1e..596b06d16 100644
--- a/nezha-fronted/src/components/common/rightBox/roleBox.vue
+++ b/nezha-fronted/src/components/common/rightBox/roleBox.vue
@@ -142,7 +142,6 @@ export default {
this.$get('sys/menu').then(response => {
if (response.code == 200) {
this.menus = response.data.list
-
} else {
this.$message.error('load menu faild')
}
diff --git a/nezha-fronted/src/components/page/dashboard/chartBox.vue b/nezha-fronted/src/components/page/dashboard/chartBox.vue
index aaef0d6ee..f57f7e15f 100644
--- a/nezha-fronted/src/components/page/dashboard/chartBox.vue
+++ b/nezha-fronted/src/components/page/dashboard/chartBox.vue
@@ -183,7 +183,7 @@
-
+
{{$t('dashboard.panel.chartForm.option')}}
@@ -198,6 +198,15 @@
+
+
+
+
+ {{item.name}}
+
+
+
+
-->
-
-
-
+
+
+
{{$t('alert.config.expr')}}
@@ -498,7 +507,7 @@ export default {
panelName: [
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
],
- title: [
+ name: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
url: [
@@ -511,6 +520,7 @@ export default {
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
]
},
+ groupArr: [],
chartTypeList: [
{
id: 'line',
@@ -547,6 +557,10 @@ export default {
{
id: 'url',
name: this.$t('dashboard.panel.chartForm.typeVal.url.label')
+ },
+ {
+ id: 'group',
+ name: this.$t('dashboard.panel.chartForm.typeVal.group.label')
}
],
@@ -634,7 +648,7 @@ export default {
cancelButtonText: this.$t('tip.no'),
type: 'warning'
}).then(() => {
- this.$delete('panel?ids=' + panel.id).then(response => {
+ this.$delete('visual/panel?ids=' + panel.id).then(response => {
if (response.code === 200) {
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.deleteSuccess') })
if (this.panelId == panel.id) {
@@ -701,7 +715,7 @@ export default {
this.$refs.chartForm.validate((valid) => {
if (valid) {
if (this.editChart.id) { // 修改
- this.$put('panel/' + this.editChart.id + '/charts').then(response => {
+ this.$put('visual/panel/chart', this.editChart).then(response => {
if (response.code === 200) {
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
this.esc(true)
@@ -710,7 +724,7 @@ export default {
}
})
} else { // 新增
- this.$post('panel/charts', this.editChart).then(response => {
+ this.$post('visual/panel/chart', this.editChart).then(response => {
if (response.code === 200) {
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
this.esc(true)
@@ -850,12 +864,18 @@ export default {
// panelPromise.then(()=>{
if (this.panelId) {
- this.$post('panel/' + this.panelId + '/charts', params || this.editChart).then(response => {
+ const chartParams = params || this.editChart
+ chartParams.panelId = this.panelId
+ if (!chartParams.groupId) {
+ chartParams.groupId = -1
+ }
+ delete chartParams.panel
+ this.$post('visual/panel/chart', chartParams).then(response => {
if (response.code === 200) {
this.esc()
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
this.$refs.chartForm.resetFields()// 清空表单
- this.$emit('on-create-success', 'create', response.data, params, { id: this.panelId, name: this.panelName })
+ this.$emit('on-create-success', 'create', response.data, chartParams, { id: this.panelId, name: this.panelName })
} else {
if (response.msg) {
this.$message.error(response.msg)
@@ -871,12 +891,18 @@ export default {
// 更新图表
updateCharts (params) {
const panelId = this.panelId ? this.panelId : this.chart.panelId
- this.$put('panel/' + panelId + '/charts', params || this.editChart).then(response2 => {
+ const chartParams = params || this.editChart
+ chartParams.panelId = panelId
+ if (!chartParams.groupId) {
+ chartParams.groupId = -1
+ }
+ delete chartParams.panel
+ this.$put('visual/panel/chart', chartParams).then(response2 => {
if (response2.code === 200) {
this.esc()
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
// this.$refs.chartForm.resetFields();//清空表单
- this.$emit('on-create-success', 'update', response2.data, params)
+ this.$emit('on-create-success', 'update', response2.data, chartParams)
} else {
if (response2.msg) {
this.$message.error(response2.msg)
@@ -895,7 +921,7 @@ export default {
const params = {
// productId: this.productId,
// panelId: this.panelId,
- title: this.editChart.title, // this.editChart
+ name: this.editChart.name, // this.editChart
span: this.editChart.span,
height: this.editChart.height,
type: this.editChart.type,
@@ -960,13 +986,14 @@ export default {
getAlertParam: function (param, opType) {
this.$refs.chartForm.validate((valid) => {
const params = {
- title: this.editChart.title, // this.editChart
+ name: this.editChart.name, // this.editChart
span: this.editChart.span,
height: this.editChart.height,
type: this.editChart.type,
unit: this.editChart.unit,
param: param,
- sync: this.editChart.sync
+ sync: this.editChart.sync,
+ remark: this.editChart.remark
}
if (valid) {
if (opType === 'preview') {
@@ -1025,7 +1052,7 @@ export default {
if (this.editChart.type == 'url') {
this.$refs.chartForm.validate((valid) => {
const params = {
- title: this.editChart.title, // this.editChart
+ name: this.editChart.name, // this.editChart
span: this.editChart.span,
height: this.editChart.height,
type: this.editChart.type,
@@ -1033,7 +1060,8 @@ export default {
param: {
url: this.editChart.param.url
},
- sync: this.editChart.sync
+ sync: this.editChart.sync,
+ remark: this.editChart.remark
}
if (valid) {
@@ -1053,14 +1081,15 @@ export default {
valid = false
}
const params = {
- title: this.editChart.title, // this.editChart
+ name: this.editChart.name, // this.editChart
span: this.editChart.span,
height: this.editChart.height,
type: this.editChart.type,
param: {
text: text
},
- sync: this.editChart.sync
+ sync: this.editChart.sync,
+ remark: this.editChart.remark
}
if (valid) {
@@ -1193,11 +1222,12 @@ export default {
this.editInfo = data
// 图表信息获取
this.editChart.id = data.id
- this.editChart.title = data.title
+ this.editChart.name = data.name
this.editChart.span = data.span
this.editChart.height = data.height + ''
this.editChart.type = data.type
this.editChart.unit = data.unit
+ this.editChart.remark = data.remark
this.editChart.elements = data.elements
if (this.editChart.type === 'url') {
this.editChart.param.url = data.param.url
@@ -1252,11 +1282,13 @@ export default {
// 初始化信息
initInfo (unit) {
- this.editChart.title = ''
+ this.editChart.name = ''
this.editChart.type = 'line'
this.editChart.span = 12
this.editChart.height = 400 + ''
this.editChart.unit = unit || 2
+ this.editChart.remark = ''
+ this.editChart.groupId = ''
const param = {}
param.last = 0
param.url = ''
@@ -1394,13 +1426,15 @@ export default {
const params = {
// productId: this.productId,
// panelId: this.panelId,
- title: this.editChart.title, // this.editChart
+ name: this.editChart.name, // this.editChart
span: this.editChart.span,
height: this.editChart.height,
type: this.editChart.type,
unit: this.editChart.unit,
param: this.editChart.param,
- sync: this.editChart.sync
+ sync: this.editChart.sync,
+ remark: this.editChart.remark,
+ groupId: this.editChart.groupId
}
if (this.editChart.type === 'singleStat' || this.editChart.type === 'table') {
// params.param.statistics=this.statistics;
@@ -1439,14 +1473,16 @@ export default {
} else if (this.editChart.type == 'url') {
this.$refs.chartForm.validate((valid) => {
const params = {
- title: this.editChart.title, // this.editChart
+ name: this.editChart.name, // this.editChart
span: this.editChart.span,
height: this.editChart.height,
type: this.editChart.type,
unit: this.editChart.unit,
param: {
url: this.editChart.param.url
- }
+ },
+ remark: this.editChart.remark,
+ groupId: this.editChart.groupId
}
if (valid) {
@@ -1463,14 +1499,16 @@ export default {
valid = false
}
const params = {
- title: this.editChart.title, // this.editChart
+ name: this.editChart.name, // this.editChart
span: this.editChart.span,
height: this.editChart.height,
type: this.editChart.type,
unit: this.editChart.unit,
param: {
text: text
- }
+ },
+ remark: this.editChart.remark,
+ groupId: this.editChart.groupId
}
if (valid) {
@@ -1626,10 +1664,14 @@ export default {
})
}
- if (n.title) {
+ if (n.name) {
this.isEdit = true
}
+
this.editChart = JSON.parse(JSON.stringify(n))
+ if (!n.groupId || n.groupId == -1) {
+ this.editChart.groupId = ''
+ }
if (!n.param.nullType) {
this.editChart.param.nullType = 'connected'
}
diff --git a/nezha-fronted/src/components/page/dashboard/panel.vue b/nezha-fronted/src/components/page/dashboard/panel.vue
index c9af034fb..0c9b201fd 100644
--- a/nezha-fronted/src/components/page/dashboard/panel.vue
+++ b/nezha-fronted/src/components/page/dashboard/panel.vue
@@ -238,7 +238,7 @@ export default {
cancelButtonText: this.$t('tip.no'),
type: 'warning'
}).then(() => {
- this.$delete('panel?ids=' + u.id).then(response => {
+ this.$delete('visual/panel?ids=' + u.id).then(response => {
if (response.code === 200) {
this.$message({
duration: 1000,
@@ -317,7 +317,7 @@ export default {
cancelButtonText: this.$t('tip.no'),
type: 'warning'
}).then(() => {
- this.$delete('panel/' + data.panelId + '/charts?ids=' + data.id).then(response => {
+ this.$delete('visual/panel/chart?ids=' + data.id).then(response => {
if (response.code === 200) {
this.$message({
duration: 2000,
@@ -434,7 +434,7 @@ export default {
if (!this.hasButton('panel_view')) {
return
}
- this.$get('panel').then(response => {
+ this.$get('visual/panel?pageSize=-1').then(response => {
if (response.code === 200) {
this.panelData = response.data.list
for (let i = 0; i < this.panelData.length; i++) {
@@ -450,7 +450,7 @@ export default {
getTableData (clearShowPanel) {
const vm = this
- this.$get('panel?type=dashboard').then(response => {
+ this.$get('visual/panel?type=dashboard&pageSize=-1').then(response => {
if (response.code === 200) {
this.panelData = response.data.list
let isInitData = false
diff --git a/nezha-fronted/static/config.json b/nezha-fronted/static/config.json
index ca9183fea..66c3c57ef 100644
--- a/nezha-fronted/static/config.json
+++ b/nezha-fronted/static/config.json
@@ -1 +1 @@
-{"baseUrl":"", "version": "1.2.2020.11.10.14.10"}
+{"baseUrl":"http://192.168.40.42:8080/nz-admin/", "version": "1.2.2020.11.10.14.10"}