feat:panel chart 可以通过模板添加
This commit is contained in:
@@ -278,7 +278,11 @@ const cn = {
|
|||||||
content: '内容',
|
content: '内容',
|
||||||
tooltip: 'Tooltip',
|
tooltip: 'Tooltip',
|
||||||
displayChart: '图表',
|
displayChart: '图表',
|
||||||
aggregation: 'Aggregation'
|
aggregation: 'Aggregation',
|
||||||
|
varType: 'Vartype',
|
||||||
|
pid: 'Chart 模板',
|
||||||
|
selectAsset: '请选择Asset',
|
||||||
|
selectEndpoint: '请选择Endpoint'
|
||||||
},
|
},
|
||||||
chartTableColumn: {
|
chartTableColumn: {
|
||||||
metric: '指标',
|
metric: '指标',
|
||||||
|
|||||||
@@ -288,7 +288,11 @@ const en = {
|
|||||||
content: 'Content',
|
content: 'Content',
|
||||||
tooltip: 'Tooltip',
|
tooltip: 'Tooltip',
|
||||||
displayChart: 'Display chart',
|
displayChart: 'Display chart',
|
||||||
aggregation: 'Aggregation'
|
aggregation: 'Aggregation',
|
||||||
|
varType: 'Vartype',
|
||||||
|
pid: 'Chart template',
|
||||||
|
selectAsset: 'Please select the Asset',
|
||||||
|
selectEndpoint: 'Please select the Endpoint'
|
||||||
},
|
},
|
||||||
chartTableColumn: {
|
chartTableColumn: {
|
||||||
metric: 'Metric', // '指标'
|
metric: 'Metric', // '指标'
|
||||||
|
|||||||
@@ -313,7 +313,7 @@
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button @click="imgUpload" class="nz-btn nz-btn-size-normal-new nz-btn-style-normal-new"
|
<button @click="imgUpload" class="nz-btn nz-btn-size-normal-new nz-btn-style-normal-new"
|
||||||
v-has="'project_topo_save'" :disabled="prevent_opt.save"
|
v-has="'topo_icon_save'" :disabled="prevent_opt.save"
|
||||||
:class="{'nz-btn-disabled':prevent_opt.save}"
|
:class="{'nz-btn-disabled':prevent_opt.save}"
|
||||||
style="margin-right: 20px">
|
style="margin-right: 20px">
|
||||||
{{$t('project.topology.save')}}
|
{{$t('project.topology.save')}}
|
||||||
@@ -477,6 +477,8 @@ export default {
|
|||||||
penToolTipScale: 1,
|
penToolTipScale: 1,
|
||||||
oldScale: 1,
|
oldScale: 1,
|
||||||
uploadPicShow: false,
|
uploadPicShow: false,
|
||||||
|
imgWidth: 0,
|
||||||
|
imgHeight: 0,
|
||||||
uploadPic: {
|
uploadPic: {
|
||||||
name: '',
|
name: '',
|
||||||
unit: ''
|
unit: ''
|
||||||
@@ -1484,22 +1486,24 @@ export default {
|
|||||||
beforeAvatarUpload (file, fileList) {
|
beforeAvatarUpload (file, fileList) {
|
||||||
const this_ = this
|
const this_ = this
|
||||||
const isJPG = (file.raw.type === 'image/jpeg' || file.raw.type === 'image/png')
|
const isJPG = (file.raw.type === 'image/jpeg' || file.raw.type === 'image/png')
|
||||||
|
const isLt2M = file.size / 1024 / 1024 < 2
|
||||||
if (!isJPG) {
|
if (!isJPG) {
|
||||||
this.$message.error(this_.$t('project.topology.imgFormat'))
|
this.$message.error(this_.$t('project.topology.imgFormat'))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// if (!isLt2M) {
|
if (!isLt2M) {
|
||||||
// this.$message.error( this_.$t('project.topology.imgSize'));
|
this.$message.error(this_.$t('project.topology.imgSize'))
|
||||||
// return false;
|
return false
|
||||||
// }
|
}
|
||||||
const isSize = new Promise(function (resolve, reject) {
|
const isSize = new Promise(function (resolve, reject) {
|
||||||
const width = 100
|
const width = 0
|
||||||
const height = 100
|
const height = 0
|
||||||
const _URL = window.URL || window.webkitURL
|
const _URL = window.URL || window.webkitURL
|
||||||
const img = new Image()
|
const img = new Image()
|
||||||
img.onload = function () {
|
img.onload = function () {
|
||||||
const valid = img.width > width && img.height > height
|
const valid = img.width > width && img.height > height
|
||||||
|
this_.imgWidth = img.width
|
||||||
|
this_.imgHeight = img.height
|
||||||
valid ? resolve() : reject()
|
valid ? resolve() : reject()
|
||||||
}
|
}
|
||||||
img.src = _URL.createObjectURL(file.raw)
|
img.src = _URL.createObjectURL(file.raw)
|
||||||
@@ -1545,12 +1549,15 @@ export default {
|
|||||||
upload () {
|
upload () {
|
||||||
const form = new FormData()
|
const form = new FormData()
|
||||||
form.append('file', this.file)
|
form.append('file', this.file)
|
||||||
|
console.log(this.file)
|
||||||
if (this.uploadPic.name) {
|
if (this.uploadPic.name) {
|
||||||
form.append('name', this.uploadPic.name)
|
form.append('name', this.uploadPic.name)
|
||||||
} else {
|
} else {
|
||||||
form.append('name', this.file.name.substring(0, this.file.name.lastIndexOf('.')))
|
form.append('name', this.file.name.substring(0, this.file.name.lastIndexOf('.')))
|
||||||
}
|
}
|
||||||
form.append('unit', this.uploadPic.unit)
|
form.append('unit', this.uploadPic.unit)
|
||||||
|
form.append('width', this.imgWidth)
|
||||||
|
form.append('height', this.imgHeight)
|
||||||
this.$post('monitor/project/topo/icon', form, { 'Content-Type': 'multipart/form-data' }).then(res => {
|
this.$post('monitor/project/topo/icon', form, { 'Content-Type': 'multipart/form-data' }).then(res => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.saveSuccess') })
|
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.saveSuccess') })
|
||||||
@@ -1685,6 +1692,7 @@ export default {
|
|||||||
responseType: 'arraybuffer'
|
responseType: 'arraybuffer'
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
console.log(res.data)
|
||||||
return ('data:image/jpeg;base64,' + btoa(new Uint8Array(res.data).reduce((data, byte) => data + String.fromCharCode(byte), '')))
|
return ('data:image/jpeg;base64,' + btoa(new Uint8Array(res.data).reduce((data, byte) => data + String.fromCharCode(byte), '')))
|
||||||
})
|
})
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
|||||||
@@ -8,17 +8,17 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="right-box__container">
|
<div class="right-box__container">
|
||||||
<div class="container__form">
|
<div class="container__form">
|
||||||
<el-form ref="userForm" :model="editChartTemp" :rules="editChartTemp.id ? rules2 : rules" class="right-box-form right-box-form-left" label-position="top" label-width="120px">
|
<el-form ref="userForm" :model="editChartTemp" :rules="rules" class="right-box-form right-box-form-left" label-position="top" label-width="120px">
|
||||||
<!--type-->
|
<!--type-->
|
||||||
<el-form-item :label="$t('dashboard.panel.chartForm.varType')">
|
<el-form-item :label="$t('dashboard.panel.chartForm.varType')" prop="varType">
|
||||||
<el-select class="right-box-row-with-btn" placeholder="" clearable popper-class="chart-box-dropdown-small" size="mini" v-model="editChartTemp.varType" value-key="chartType" id="chart-box-group">
|
<el-select class="right-box-row-with-btn" placeholder="" clearable popper-class="chart-box-dropdown-small" size="mini" v-model="editChartTemp.varType" value-key="chartType" id="chart-box-group" @change="varTypeChange">
|
||||||
<el-option :key="item.id" :label="item.name" :value="item.id" v-for="item in varTypeArr">
|
<el-option :key="item.id" :label="item.name" :value="item.id" v-for="item in varTypeArr">
|
||||||
<span class="panel-dropdown-label-txt" >{{item.name}}</span>
|
<span class="panel-dropdown-label-txt" >{{item.name}}</span>
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<!--chartTemp list-->
|
<!--chartTemp list-->
|
||||||
<el-form-item :label="$t('dashboard.panel.chartForm.varType')">
|
<el-form-item :label="$t('dashboard.panel.chartForm.pid')" prop="pid">
|
||||||
<el-select class="right-box-row-with-btn" placeholder="" clearable popper-class="chart-box-dropdown-small" size="mini" v-model="editChartTemp.pid" value-key="chartType" id="chart-box-group" >
|
<el-select class="right-box-row-with-btn" placeholder="" clearable popper-class="chart-box-dropdown-small" size="mini" v-model="editChartTemp.pid" value-key="chartType" id="chart-box-group" >
|
||||||
<el-option :key="item.id" :label="item.name" :value="item.id" v-for="item in chartTempArr">
|
<el-option :key="item.id" :label="item.name" :value="item.id" v-for="item in chartTempArr">
|
||||||
<span class="panel-dropdown-label-txt" >{{item.name}}</span>
|
<span class="panel-dropdown-label-txt" >{{item.name}}</span>
|
||||||
@@ -27,12 +27,13 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<!-- 选择资产,穿梭框 -->
|
<!-- 选择资产,穿梭框 -->
|
||||||
<div class="form__sub-title">{{$t('overall.select')}}</div>
|
<div class="form__sub-title">{{editChartTemp.varType === 1 ? 'Asset' : 'Endpoint'}}</div>
|
||||||
<nz-transfer ref="transfer"
|
<nz-transfer ref="transfer"
|
||||||
:page-obj="transfer.pageObj"
|
:page-obj="transfer.pageObj"
|
||||||
:search-msg="transfer.searchMsg"
|
:search-msg="transfer.searchMsg"
|
||||||
:table-data="transfer.tableData"
|
:table-data="transfer.tableData"
|
||||||
style="margin-bottom: 20px;"
|
style="margin-bottom: 20px;"
|
||||||
|
:tableTitle="transferTableTitle"
|
||||||
@leftToRight="addAsset"
|
@leftToRight="addAsset"
|
||||||
@search="search"
|
@search="search"
|
||||||
@rightToLeft="removeAsset">
|
@rightToLeft="removeAsset">
|
||||||
@@ -77,7 +78,10 @@ export default {
|
|||||||
url: 'visual/panel/chart/fromTmpl',
|
url: 'visual/panel/chart/fromTmpl',
|
||||||
rightBox: { model: { show: false } },
|
rightBox: { model: { show: false } },
|
||||||
rules: { // 表单校验规则
|
rules: { // 表单校验规则
|
||||||
name: [
|
varType: [
|
||||||
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
||||||
|
],
|
||||||
|
pid: [
|
||||||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -139,7 +143,19 @@ export default {
|
|||||||
pages: 1,
|
pages: 1,
|
||||||
total: 0
|
total: 0
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
transferTableTitle: [
|
||||||
|
{
|
||||||
|
label: this.$t('overall.name'),
|
||||||
|
prop: 'name',
|
||||||
|
show: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: this.$t('asset.host'),
|
||||||
|
prop: 'manageIp',
|
||||||
|
show: true
|
||||||
}
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -153,7 +169,7 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
this.getChartTempData()
|
this.getChartTempData()
|
||||||
this.getAssetData()
|
this.getTableData()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
clickOutside () {
|
clickOutside () {
|
||||||
@@ -170,9 +186,9 @@ export default {
|
|||||||
if (!this.transfer.selectedData.length) {
|
if (!this.transfer.selectedData.length) {
|
||||||
this.prevent_opt.save = false
|
this.prevent_opt.save = false
|
||||||
if (this.editChartTemp.varType === 1) {
|
if (this.editChartTemp.varType === 1) {
|
||||||
this.$message.error('请选择Asset')
|
this.$message.error(this.$t('dashboard.panel.chartForm.selectAsset'))
|
||||||
} else {
|
} else {
|
||||||
this.$message.error('请选择Endpoint')
|
this.$message.error(this.$t('dashboard.panel.chartForm.selectEndpoint'))
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -184,6 +200,7 @@ export default {
|
|||||||
this.prevent_opt.save = false
|
this.prevent_opt.save = false
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.saveSuccess') })
|
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.saveSuccess') })
|
||||||
|
this.$emit('on-create-success')
|
||||||
this.esc(true)
|
this.esc(true)
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(res.msg)
|
this.$message.error(res.msg)
|
||||||
@@ -209,7 +226,7 @@ export default {
|
|||||||
search (searchLabel, page) {
|
search (searchLabel, page) {
|
||||||
this.transfer.searchLabel = JSON.parse(JSON.stringify(searchLabel))
|
this.transfer.searchLabel = JSON.parse(JSON.stringify(searchLabel))
|
||||||
this.transfer.pageObj = JSON.parse(JSON.stringify(page))
|
this.transfer.pageObj = JSON.parse(JSON.stringify(page))
|
||||||
this.getAssetData()
|
this.getTableData()
|
||||||
},
|
},
|
||||||
addAsset (toAdd) {
|
addAsset (toAdd) {
|
||||||
this.transfer.selectedData = toAdd
|
this.transfer.selectedData = toAdd
|
||||||
@@ -231,6 +248,13 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
getTableData () {
|
||||||
|
if (this.editChartTemp.varType === 1) {
|
||||||
|
this.getAssetData()
|
||||||
|
} else {
|
||||||
|
this.getEndpointData()
|
||||||
|
}
|
||||||
|
},
|
||||||
getAssetData () {
|
getAssetData () {
|
||||||
this.$refs.transfer.startLoading()
|
this.$refs.transfer.startLoading()
|
||||||
this.$get('asset/asset', { ...this.transfer.searchLabel, ...this.transfer.pageObj }).then(response => {
|
this.$get('asset/asset', { ...this.transfer.searchLabel, ...this.transfer.pageObj }).then(response => {
|
||||||
@@ -252,7 +276,38 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
varTypeChange () {
|
varTypeChange () {
|
||||||
|
this.getChartTempData()
|
||||||
|
this.editChartTemp.pid = ''
|
||||||
|
this.transfer.selectedData = []
|
||||||
|
this.$refs.transfer.selectedData = []
|
||||||
|
if (this.editChartTemp.varType === 1) {
|
||||||
|
this.transferTableTitle = [
|
||||||
|
{
|
||||||
|
label: this.$t('overall.name'),
|
||||||
|
prop: 'name',
|
||||||
|
show: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: this.$t('asset.host'),
|
||||||
|
prop: 'manageIp',
|
||||||
|
show: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
} else {
|
||||||
|
this.transferTableTitle = [
|
||||||
|
{
|
||||||
|
label: 'ID',
|
||||||
|
prop: 'id',
|
||||||
|
show: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: this.$t('project.endpoint.name'),
|
||||||
|
prop: 'name',
|
||||||
|
show: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
this.getTableData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,7 +194,6 @@ export default {
|
|||||||
str += `<div>PROMETHEUS <div class="active-icon inline-block ${item == '0' ? 'red' : 'green'}"></div></div>`
|
str += `<div>PROMETHEUS <div class="active-icon inline-block ${item == '0' ? 'red' : 'green'}"></div></div>`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
console.log(arr, str)
|
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
:from="fromRoute.endpoint"
|
:from="fromRoute.endpoint"
|
||||||
:layout="['searchInput', 'elementSet']"
|
:layout="['searchInput', 'elementSet']"
|
||||||
:hasSearch="true"
|
:hasSearch="true"
|
||||||
|
@search="search"
|
||||||
:search-msg="searchMsg">
|
:search-msg="searchMsg">
|
||||||
<template v-slot:top-tool-right>
|
<template v-slot:top-tool-right>
|
||||||
<export-excel
|
<export-excel
|
||||||
@@ -126,6 +127,26 @@ export default {
|
|||||||
type: 'input',
|
type: 'input',
|
||||||
label: 'id',
|
label: 'id',
|
||||||
disabled: false
|
disabled: false
|
||||||
|
}, {
|
||||||
|
id: 14,
|
||||||
|
name: this.$t('asset.asset'),
|
||||||
|
type: 'query',
|
||||||
|
label: 'query',
|
||||||
|
disabled: false
|
||||||
|
},{
|
||||||
|
id: 34,
|
||||||
|
name: this.$t('project.project.project'),
|
||||||
|
// name: this.$t('asset.asset'),
|
||||||
|
type: 'input',
|
||||||
|
label: 'projectName',
|
||||||
|
disabled: false
|
||||||
|
}, {
|
||||||
|
id: 35,
|
||||||
|
name: this.$t('project.module.module'),
|
||||||
|
// name: this.$t('asset.asset'),
|
||||||
|
type: 'input',
|
||||||
|
label: 'moduleName',
|
||||||
|
disabled: false
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
roles: [],
|
roles: [],
|
||||||
@@ -222,17 +243,23 @@ export default {
|
|||||||
getTableData () {
|
getTableData () {
|
||||||
this.$set(this.searchLabel, 'pageNo', this.pageObj.pageNo)
|
this.$set(this.searchLabel, 'pageNo', this.pageObj.pageNo)
|
||||||
this.$set(this.searchLabel, 'pageSize', this.pageObj.pageSize)
|
this.$set(this.searchLabel, 'pageSize', this.pageObj.pageSize)
|
||||||
|
const params = {
|
||||||
|
...this.searchLabel,
|
||||||
|
...this.searchCheckBox
|
||||||
|
}
|
||||||
if (this.searchLabel.projectIds) {
|
if (this.searchLabel.projectIds) {
|
||||||
localStorage.setItem('endpointProjectId', this.searchLabel.projectIds)
|
localStorage.setItem('endpointProjectId', this.searchLabel.projectIds)
|
||||||
|
if (params.projectIds) {
|
||||||
|
params.projectIds += ',' + this.searchLabel.projectIds
|
||||||
|
} else {
|
||||||
|
params.projectIds = this.searchLabel.projectIds
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
localStorage.removeItem('endpointProjectId')
|
localStorage.removeItem('endpointProjectId')
|
||||||
}
|
}
|
||||||
const params = {
|
console.log()
|
||||||
...this.searchLabel,
|
|
||||||
...this.titleSearch
|
|
||||||
}
|
|
||||||
this.tools.loading = true
|
this.tools.loading = true
|
||||||
this.$get(this.url, { ...params, ...this.searchCheckBox }).then(response => {
|
this.$get(this.url, params).then(response => {
|
||||||
this.tools.loading = false
|
this.tools.loading = false
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
for (let i = 0; i < response.data.list.length; i++) {
|
for (let i = 0; i < response.data.list.length; i++) {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export function get (url, params) {
|
|||||||
axios.get(url, {
|
axios.get(url, {
|
||||||
params: params
|
params: params
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
resolve(response.data)
|
resolve(response.data, response)
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
if (err.response) {
|
if (err.response) {
|
||||||
resolve(err.response.data)
|
resolve(err.response.data)
|
||||||
@@ -42,7 +42,7 @@ export function get (url, params) {
|
|||||||
export function post (url, params, headers) {
|
export function post (url, params, headers) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
axios.post(url, params, { headers: headers }).then(response => {
|
axios.post(url, params, { headers: headers }).then(response => {
|
||||||
resolve(response.data)
|
resolve(response.data, response)
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
if (err.response) {
|
if (err.response) {
|
||||||
resolve(err.response.data)
|
resolve(err.response.data)
|
||||||
@@ -56,7 +56,7 @@ export function post (url, params, headers) {
|
|||||||
export function put (url, params, headers) {
|
export function put (url, params, headers) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
axios.put(url, params, { headers: headers }).then(response => {
|
axios.put(url, params, { headers: headers }).then(response => {
|
||||||
resolve(response.data)
|
resolve(response.data, response)
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
if (err.response) {
|
if (err.response) {
|
||||||
resolve(err.response.data)
|
resolve(err.response.data)
|
||||||
@@ -70,7 +70,7 @@ export function put (url, params, headers) {
|
|||||||
export function del (url, params) {
|
export function del (url, params) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
axios.delete(url, params).then(response => {
|
axios.delete(url, params).then(response => {
|
||||||
resolve(response.data)
|
resolve(response.data, response)
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
if (err.response) {
|
if (err.response) {
|
||||||
resolve(err.response.data)
|
resolve(err.response.data)
|
||||||
|
|||||||
Reference in New Issue
Block a user