From 63a18d757694b6ecbb48ead9d2e9ac7437832c46 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Thu, 26 Aug 2021 15:38:45 +0800 Subject: [PATCH] =?UTF-8?q?NEZ-938=20fix:=E4=BA=8C=E7=BA=A7=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=20endpoint=E7=BC=96=E8=BE=91=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E7=82=B9=E5=87=BBconsole=20=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/bottomBox/tabs/endpointTabNew.vue | 111 ++++++++++++++---- .../src/components/page/asset/asset.vue | 2 +- .../page/monitor/endpoint/endpointList.vue | 2 +- 3 files changed, 89 insertions(+), 26 deletions(-) diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/endpointTabNew.vue b/nezha-fronted/src/components/common/bottomBox/tabs/endpointTabNew.vue index 4ea41bdc2..fd0c6c0ac 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/endpointTabNew.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/endpointTabNew.vue @@ -24,6 +24,7 @@ :endpointTab="true" @del="del" @edit="edit" + @copy="copy" @orderBy="tableDataSort" @addSilence="addSilence" @reload="getTableData" @@ -37,6 +38,9 @@ + + + @@ -120,20 +124,9 @@ export default { this.tools.loading = false if (response.code === 200) { for (let i = 0; i < response.data.list.length; i++) { - response.data.list[i].status = response.data.list[i].status + '' - const configs = [] response.data.list[i].configs.forEach(item => { item.config = JSON.parse(item.config) - if (item.type === 'logs') { - configs.push(item.config) - } }) - response.data.list[i].configs[0] = response.data.list[i].configs[0].config - response.data.list[i].configs[1] = { - type: 'logs', - enable: response.data.list[i].configs[1].enable, - config: configs - } } this.tableData = response.data.list this.nowTime = this.utcTimeToTimezoneStr(response.time) @@ -147,38 +140,108 @@ export default { } }) }, - edit (row) { + edit (row, copyFlag) { this.$get('monitor/endpoint/' + row.id).then(res => { - const u = res.data - this.object = JSON.parse(JSON.stringify(u)) - this.object.configs = JSON.parse(this.object.configs) - this.object.walk = this.object.configs.walk ? JSON.parse(JSON.stringify(this.object.configs.walk)) : [] - this.object.port = this.object.configs.port ? JSON.parse(JSON.stringify(this.object.configs.port)) : 9100 + this.object = JSON.parse(JSON.stringify(res.data)) + if (copyFlag) { + this.object.id = '' + this.object.name = this.object.name + '-copy' + if (this.object.name.length > 64) { + const length = this.object.name.length - 64 + console.log(length, this.object.name.length, row.name.length) + this.object.name = row.name.substring(0, row.name.length - length) + '-copy' + } + } + this.object.configs.forEach(item => { + item.config = JSON.parse(item.config) + }) this.object.paramObj = [] this.object.labelModule = [] - if (JSON.stringify(this.object.configs.labels) !== '{}' && this.object.configs.labels) { - Object.keys(this.object.configs.labels).forEach(key => { - this.object.labelModule.push({ key, value: this.object.configs.labels[key] }) + if (!this.object.configs[0].config.relabel_config) { + this.object.configs[0].config.relabel_config = [] + } + this.object.configs[0].config.relabel_config && this.object.configs[0].config.relabel_config.forEach(item => { + item.showAllRelabelOption = false + item.tags = '' + }) + this.object.configs[1].config.forEach(item => { + item.labelModule = [] + if (JSON.stringify(item.labels) !== '{}' && item.labels) { + Object.keys(item.labels).forEach(key => { + item.labelModule.push({ key, value: item.labels[key] }) + }) + } else { + item.labelModule.push({ key: '', value: '' }) + } + item.pipeline && item.pipeline.forEach((pipeline) => { + if (pipeline.type === 'labels') { + const labelsArr = [] + if (JSON.stringify(pipeline.labels) !== '{}' && pipeline.labels) { + Object.keys(pipeline.labels).forEach(key => { + labelsArr.push({ key, value: pipeline.labels[key] }) + }) + } else { + labelsArr.push({ key: '', value: '' }) + } + pipeline.labels = labelsArr + } + if (pipeline.type === 'json') { + const expressionsArr = [] + if (JSON.stringify(pipeline.expressions) !== '{}' && pipeline.expressions) { + Object.keys(pipeline.expressions).forEach(key => { + expressionsArr.push({ key, value: pipeline.expressions[key] }) + }) + } else { + expressionsArr.push({ key: '', value: '' }) + } + pipeline.expressions = expressionsArr + } + }) + if (item.type === 'file') { + item.unit = '' + item.appName = '' + item.listenAddress = '' + } else if (item.type === 'journal') { + item.fileName = '' + item.appName = '' + item.listenAddress = '' + } else if (item.type === 'syslog') { + item.fileName = '' + item.unit = '' + } + }) + if (JSON.stringify(this.object.configs[0].config.labels) !== '{}' && this.object.configs[0].config.labels) { + Object.keys(this.object.configs[0].config.labels).forEach(key => { + this.object.labelModule.push({ key, value: this.object.configs[0].config.labels[key] }) }) } else { this.object.labelModule.push({ key: '', value: '' }) } - if (JSON.stringify(this.object.configs.params) !== '{}' && this.object.configs.params) { - Object.keys(this.object.configs.params).forEach(key => { - this.object.paramObj.push({ key, value: this.object.configs.params[key] }) + if (JSON.stringify(this.object.configs[0].config.params) !== '{}' && this.object.configs[0].config.params) { + Object.keys(this.object.configs[0].config.params).forEach(key => { + this.object.paramObj.push({ key, value: this.object.configs[0].config.params[key] }) }) } else { this.object.paramObj.push({ key: '', value: [] }) } this.object.assetName = this.object.asset ? this.object.asset.name : '' + this.object.assetId = this.object.asset ? this.object.asset.id + '' : '' this.object.projectId = this.object.project.id this.object.moduleId = this.object.module.id this.object.type = this.object.module.type - this.rightBox.editShow = true + if (copyFlag) { + this.rightBox.show = true + } else { + this.rightBox.editShow = true + } }) }, + copy (row) { + this.edit(row, true) + }, closeRightEditBox (refresh) { this.rightBox.editShow = false + this.rightBox.show = false if (refresh) { this.delFlag = true this.getTableData() diff --git a/nezha-fronted/src/components/page/asset/asset.vue b/nezha-fronted/src/components/page/asset/asset.vue index a08b1cbf2..e79a36af9 100644 --- a/nezha-fronted/src/components/page/asset/asset.vue +++ b/nezha-fronted/src/components/page/asset/asset.vue @@ -54,7 +54,7 @@ v-loading="tools.loading" :api="url" :custom-table-title="tools.customTableTitle" - :height="mainTableHeight" + :height="dataListLayout.indexOf('clickSearch') > -1? 'calc(100% - 40px)' : mainTableHeight" :table-data="tableData" @cli="cli" @del="del" diff --git a/nezha-fronted/src/components/page/monitor/endpoint/endpointList.vue b/nezha-fronted/src/components/page/monitor/endpoint/endpointList.vue index a39c9cda3..17aba9f9a 100644 --- a/nezha-fronted/src/components/page/monitor/endpoint/endpointList.vue +++ b/nezha-fronted/src/components/page/monitor/endpoint/endpointList.vue @@ -56,7 +56,7 @@ v-loading="tools.loading" :api="url" :custom-table-title="tools.customTableTitle" - :height="mainTableHeight" + :height="dataListLayout.indexOf('clickSearch') > -1? 'calc(100% - 8px)' : mainTableHeight" :table-data="tableData" :tableId="tableId" @del="del"