feat: endpoint 批量新增微调

This commit is contained in:
zhangyu
2021-08-05 15:07:45 +08:00
parent 161c55d330
commit d829cb432e
5 changed files with 66 additions and 48 deletions

View File

@@ -119,6 +119,22 @@ export default {
this.$get(this.url, params).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++) {
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.tableData = response.data.list
this.nowTime = this.utcTimeToTimezoneStr(response.time) this.nowTime = this.utcTimeToTimezoneStr(response.time)
this.pageObj.total = response.data.total this.pageObj.total = response.data.total

View File

@@ -97,7 +97,7 @@
<pre >{{JSON.stringify(scope.row.configs[0].config,null,2)}}</pre> <pre >{{JSON.stringify(scope.row.configs[0].config,null,2)}}</pre>
</div> </div>
</el-tooltip> </el-tooltip>
<el-tooltip placement="left" effect="light" :popper-class="'endpointConfigsTips'"> <el-tooltip placement="right" effect="light" :popper-class="'endpointConfigsTips'">
<span class="configs-endpoint logs">{ Logs }</span> <span class="configs-endpoint logs">{ Logs }</span>
<div class="endpointConfigsTips" slot="content"> <div class="endpointConfigsTips" slot="content">
<pre >{{JSON.stringify(scope.row.configs[1].config,null,2)}}</pre> <pre >{{JSON.stringify(scope.row.configs[1].config,null,2)}}</pre>
@@ -430,11 +430,11 @@ export default {
} else { } else {
this.object.paramObj.push({ key: '', value: [] }) this.object.paramObj.push({ key: '', value: [] })
} }
if (!this.object.chartIds && this.object.module.chartIds) { // if (!this.object.chartIds && this.object.module.chartIds) {
this.object.chartIds = this.object.module.chartIds // this.object.chartIds = this.object.module.chartIds
} else { // } else {
this.object.chartIds = '' // this.object.chartIds = ''
} // }
this.rightBox.show = true this.rightBox.show = true
this.rightBox.show = true this.rightBox.show = true
} }

View File

@@ -64,24 +64,24 @@
</div> </div>
<div class="right-box-line"></div> <div class="right-box-line"></div>
<!-- ChartTemplate --> <!-- ChartTemplate -->
<el-form-item :label="$t('config.model.ChartTemplate')" prop="ChartTemplate"> <!-- <el-form-item :label="$t('config.model.ChartTemplate')" prop="ChartTemplate">-->
<v-selectpage <!-- <v-selectpage-->
v-model="editEndpoint.chartIds" <!-- v-model="editEndpoint.chartIds"-->
:data="chartTempList" <!-- :data="chartTempList"-->
:language="language" <!-- :language="language"-->
:multiple="true" <!-- :multiple="true"-->
:params="{ <!-- :params="{-->
varType: 2, panelId: 0, <!-- varType: 2, panelId: 0,-->
returnChildren:0,groupId:0, <!-- returnChildren:0,groupId:0,-->
}" <!-- }"-->
:result-format="resultFormat" <!-- :result-format="resultFormat"-->
:tb-columns="ChartSearchShowFields" <!-- :tb-columns="ChartSearchShowFields"-->
class="form-control" <!-- class="form-control"-->
key-field="id" <!-- key-field="id"-->
show-field="name" <!-- show-field="name"-->
title="ChartSearch" <!-- title="ChartSearch"-->
></v-selectpage> <!-- ></v-selectpage>-->
</el-form-item> <!-- </el-form-item>-->
<div class="endpoint-title"> <div class="endpoint-title">
<span class="endpoint-title-content"> <span class="endpoint-title-content">
<i class="nz-icon nz-icon-arrow-down" :class="metricsShow?'':'is-active'" @click="metricsShow = !metricsShow"></i> <i class="nz-icon nz-icon-arrow-down" :class="metricsShow?'':'is-active'" @click="metricsShow = !metricsShow"></i>
@@ -798,7 +798,15 @@ export default {
} }
} else if (key.indexOf('configs.1') !== -1) { } else if (key.indexOf('configs.1') !== -1) {
const keyArr = key.split('.') const keyArr = key.split('.')
this.activeNameLogs[keyArr[3]] = keyArr[4].trim().toLowerCase().replace(keyArr[4][0], keyArr[4][0].toUpperCase()) const str = keyArr[4]
if (str === 'fileName' || str === 'unit' || str === 'listenAddress' || str === 'appName') {
this.activeNameLogs[keyArr[3]] = 'Basic'
} else if (str === 'labels') {
this.activeNameLogs[keyArr[3]] = 'Labels'
} else if (str === 'pipeline') {
this.activeNameLogs[keyArr[3]] = 'Pipeline'
}
this.activeNameLogs = [...this.activeNameLogs] this.activeNameLogs = [...this.activeNameLogs]
} }
} }
@@ -1139,7 +1147,6 @@ export default {
} }
}, },
renderEndpoint () { renderEndpoint () {
console.log(123123, (JSON.stringify(this.editEndpoint.configs) === JSON.stringify(this.blankObject.configs)))
if (this.disabled) { if (this.disabled) {
return return
} }
@@ -1152,9 +1159,9 @@ export default {
if (!this.editEndpoint.name) { if (!this.editEndpoint.name) {
this.editEndpoint.name = res.data.list[0].name this.editEndpoint.name = res.data.list[0].name
} }
if (!this.editEndpoint.chartIds) { // if (!this.editEndpoint.chartIds) {
this.editEndpoint.chartIds = res.data.list[0].module.chartIds // this.editEndpoint.chartIds = res.data.list[0].module.chartIds
} // }
}) })
} }
} }

View File

@@ -67,7 +67,7 @@
<pre >{{JSON.stringify(scope.row.configs[0].config,null,2)}}</pre> <pre >{{JSON.stringify(scope.row.configs[0].config,null,2)}}</pre>
</div> </div>
</el-tooltip> </el-tooltip>
<el-tooltip placement="left" effect="light" :popper-class="'endpointConfigsTips'"> <el-tooltip placement="right" effect="light" :popper-class="'endpointConfigsTips'">
<span class="configs-endpoint logs">{ Logs }</span> <span class="configs-endpoint logs">{ Logs }</span>
<div class="endpointConfigsTips" slot="content"> <div class="endpointConfigsTips" slot="content">
<span class="copy-value-content"> <i class="nz-icon nz-icon-override" @click="copyValue(scope.row.configs[1].config)"></i></span> <span class="copy-value-content"> <i class="nz-icon nz-icon-override" @click="copyValue(scope.row.configs[1].config)"></i></span>

View File

@@ -164,7 +164,7 @@ export default {
assetId: '', assetId: '',
name: '', name: '',
port: '', port: '',
chartIds: '', // chartIds: '',
metricsEnable: 1, metricsEnable: 1,
configs: [ configs: [
{ {
@@ -320,18 +320,18 @@ export default {
// this.object.configs.walk = this.object.configs.walk ? JSON.parse(JSON.stringify(this.object.configs.walk)) : [] // this.object.configs.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)) : '' // this.object.port = this.object.configs.port ? JSON.parse(JSON.stringify(this.object.configs.port)) : ''
const configs = [] const configs = []
// this.object.configs.forEach(item => { this.object.configs.forEach(item => {
// item.config = JSON.parse(item.config) item.config = JSON.parse(item.config)
// if (item.type === 'logs') { if (item.type === 'logs') {
// configs.push(item.config) configs.push(item.config)
// } }
// }) })
// this.object.configs[0] = this.object.configs[0].config this.object.configs[0] = this.object.configs[0].config
// this.object.configs[1] = { this.object.configs[1] = {
// type: 'logs', type: 'logs',
// enable: this.object.configs[1].enable, enable: this.object.configs[1].enable,
// config: configs config: configs
// } }
console.log(this.object) console.log(this.object)
this.object.paramObj = [] this.object.paramObj = []
this.object.labelModule = [] this.object.labelModule = []
@@ -373,11 +373,6 @@ export default {
} else { } else {
this.object.paramObj.push({ key: '', value: [] }) this.object.paramObj.push({ key: '', value: [] })
} }
if (!this.object.chartIds) {
this.object.chartIds = ''
} else {
// this.object.chartIds = this.object.chartIds.split(',')
}
this.object.assetName = this.object.asset ? this.object.asset.name : '' this.object.assetName = this.object.asset ? this.object.asset.name : ''
this.object.projectId = this.object.project.id this.object.projectId = this.object.project.id
this.object.moduleId = this.object.module.id this.object.moduleId = this.object.module.id