From 78efa5b642740fe9605145a38d0cd7bb7fbdbb6d Mon Sep 17 00:00:00 2001 From: zhangyu Date: Tue, 3 Aug 2021 15:32:22 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E8=B0=83=E6=95=B4module=E7=9A=84?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/popBox/topToolMoreOptions.vue | 5 +++ .../common/rightBox/editEndpointBoxNew.vue | 43 ++++++++++++++----- .../page/monitor/endpoint/endpointList.vue | 7 +-- .../page/monitor/module/moduleList.vue | 37 +++++++++------- 4 files changed, 64 insertions(+), 28 deletions(-) diff --git a/nezha-fronted/src/components/common/popBox/topToolMoreOptions.vue b/nezha-fronted/src/components/common/popBox/topToolMoreOptions.vue index 4a0843698..e90cefc24 100644 --- a/nezha-fronted/src/components/common/popBox/topToolMoreOptions.vue +++ b/nezha-fronted/src/components/common/popBox/topToolMoreOptions.vue @@ -157,6 +157,8 @@ export default { url = '/asset/asset/cancelImport' } else if (this.importUrl.indexOf('endpoint') > -1) { url = '/monitor/endpoint/cancelImport' + } else if (this.importUrl.indexOf('module') > -1) { + url = '/monitor/module/cancelImport' } else if (this.importUrl.indexOf('rule') > -1) { url = '/alert/rule/cancelImport' } else if (this.importUrl.indexOf('panel') > -1) { @@ -243,6 +245,9 @@ export default { } else if (this.importUrl.indexOf('endpoint') > -1) { url = '/monitor/endpoint/template' param.type = 'endpoint' + } else if (this.importUrl.indexOf('module') > -1) { + url = '/monitor/module/template' + param.type = 'module' } else if (this.importUrl.indexOf('tmpl') > -1) { url = '/expression/tmpl/template' } else if (this.importUrl.indexOf('alert') > -1) { diff --git a/nezha-fronted/src/components/common/rightBox/editEndpointBoxNew.vue b/nezha-fronted/src/components/common/rightBox/editEndpointBoxNew.vue index b1dc8105e..aa2897ee4 100644 --- a/nezha-fronted/src/components/common/rightBox/editEndpointBoxNew.vue +++ b/nezha-fronted/src/components/common/rightBox/editEndpointBoxNew.vue @@ -31,16 +31,19 @@ - + - - - + + + + + + @@ -538,7 +541,8 @@ export default { optionType: { type: String, default: 'batch' - } + }, + blankObject: {} }, components: { 'select-walk': selectWalk, @@ -570,7 +574,10 @@ export default { name: [ { validator: this.optionType === 'batch' ? '' : noSpecialChar, trigger: 'change' } ], - asset: [ + assetId: [ + { required: !(this.optionType === 'batch'), message: this.$t('validate.required'), trigger: 'change' } + ], + assetName: [ { required: !(this.optionType === 'batch'), message: this.$t('validate.required'), trigger: 'change' } ], projectId: [ @@ -585,6 +592,7 @@ export default { }, projectList: [], moduleList: [], + assetList: [], credentialList: [], typeList: [ { @@ -729,7 +737,9 @@ export default { }) }, getAsset () { - + this.$get('asset/asset', { pageSize: -1 }).then(res => { + this.assetList = res.data.list + }) }, getWalkData () { this.$get('mib/tree', { pageSize: -1, pageNo: 1 }).then(response => { @@ -1127,15 +1137,28 @@ export default { return assetData } }, + renderEndpoint () { + console.log(123123, (JSON.stringify(this.editEndpoint.configs) === JSON.stringify(this.blankObject.configs))) + if (this.disabled) { + return + } + if (this.editEndpoint.moduleId && this.editEndpoint.assetId && (JSON.stringify(this.editEndpoint.configs) === JSON.stringify(this.blankObject.configs))) { + this.$post('/monitor/endpoint/render', { moduleIds: this.editEndpoint.moduleId, assetIds: this.editEndpoint.assetId }).then(res => { + console.log(res) + this.editEndpoint.configs = res.data.list[0].configs + }) + } + } }, mounted () { - this.getWalkData() - this.getAsset() - this.ChartTemplateList() + }, created () { this.getProjectList() this.getCredential() + this.getWalkData() + this.getAsset() + this.ChartTemplateList() }, computed: { mibName () { diff --git a/nezha-fronted/src/components/page/monitor/endpoint/endpointList.vue b/nezha-fronted/src/components/page/monitor/endpoint/endpointList.vue index 453a41cd2..f5831cce4 100644 --- a/nezha-fronted/src/components/page/monitor/endpoint/endpointList.vue +++ b/nezha-fronted/src/components/page/monitor/endpoint/endpointList.vue @@ -71,10 +71,10 @@ - + - + @@ -115,6 +115,7 @@ export default { blankObject: { id: '', projectId: '', + assetId: '', name: '', port: '', chartIds: '', @@ -128,7 +129,7 @@ export default { snmpCredentialsId: '', metrics_path: '', port: '', - host: '{{asset.manageIp}}', + host: '', scrape_interval: '', scrape_timeout: '', params: '', diff --git a/nezha-fronted/src/components/page/monitor/module/moduleList.vue b/nezha-fronted/src/components/page/monitor/module/moduleList.vue index 0b876fa9f..da59ed340 100644 --- a/nezha-fronted/src/components/page/monitor/module/moduleList.vue +++ b/nezha-fronted/src/components/page/monitor/module/moduleList.vue @@ -11,25 +11,30 @@ @search="search" >