-
+
+
@@ -569,6 +570,9 @@ export default {
name: [
{ validator: this.optionType === 'batch' ? '' : noSpecialChar, trigger: 'change' }
],
+ asset: [
+ { required: !(this.optionType === 'batch'), message: this.$t('validate.required'), trigger: 'change' }
+ ],
projectId: [
{ required: !(this.optionType === 'batch'), message: this.$t('validate.required'), trigger: 'change' }
],
@@ -784,13 +788,6 @@ export default {
params.configs.walk = params.walk
params.configs.port = params.port
params.configs = JSON.stringify(params.configs)
- if (this.authType === 2 && !this.editEndpoint.configs.bearer_token) {
- this.$message.error("'token' is required")
- } else if (this.authType === 1 && !(this.editEndpoint.configs.basic_auth.username && this.editEndpoint.configs.basic_auth.pin)) {
- this.$message.error("'username' and 'password' is required")
- } else {
- this.authType = 0
- }
this.$nextTick(() => {
this.$refs.moduleForm.validate((valid, errorKey) => {
let key = Object.keys(errorKey)
@@ -863,7 +860,7 @@ export default {
logsLogsArrAdd () {
this.activeNameLogs.push('Basic')
this.logsCopyValue.push('')
- this.editModule.configs[1].config.push({
+ this.editEndpoint.configs[1].config.push({
basic: {
type: 'file',
fileName: ''
@@ -874,24 +871,24 @@ export default {
})
},
removeLogsArr (index) {
- if (this.editModule.configs[1].config.length !== 1) {
- this.editModule.configs[1].config.splice(index, 1)
+ if (this.editEndpoint.configs[1].config.length !== 1) {
+ this.editEndpoint.configs[1].config.splice(index, 1)
}
},
logsBasicTypeChange (i) {
- const type = this.editModule.configs[1].config[i].basic.type
+ const type = this.editEndpoint.configs[1].config[i].basic.type
if (type === 'file') {
- this.editModule.configs[1].config[i].basic = {
+ this.editEndpoint.configs[1].config[i].basic = {
type,
fileName: ''
}
} else if (type === 'journal') {
- this.editModule.configs[1].config[i].basic = {
+ this.editEndpoint.configs[1].config[i].basic = {
type,
unit: ''
}
} else if (type === 'syslog') {
- this.editModule.configs[1].config[i].basic = {
+ this.editEndpoint.configs[1].config[i].basic = {
type,
appName: '',
listenAddress: ''
@@ -1044,7 +1041,7 @@ export default {
},
tabClick (index) {
if (this.activeNameLogs[index] === 'Preview') {
- const params = JSON.parse(JSON.stringify(this.editModule.configs[1].config[index]))
+ const params = JSON.parse(JSON.stringify(this.editEndpoint.configs[1].config[index]))
params.labels = this.labelsToJson(params.labelModule)
delete params.labelModule
Object.keys(params).forEach(key => {
@@ -1074,42 +1071,52 @@ export default {
// 添加pipeline
addPipeline (obj, logsIndex, pipeLineIndex, type) {
if (type == 'splice') {
- this.editModule.configs[1].config[logsIndex].pipeline.splice(pipeLineIndex, 0, obj)
+ this.editEndpoint.configs[1].config[logsIndex].pipeline.splice(pipeLineIndex, 0, obj)
}
if (type == 'push') {
- this.editModule.configs[1].config[logsIndex].pipeline.push(obj)
+ this.editEndpoint.configs[1].config[logsIndex].pipeline.push(obj)
}
},
+ addLogsLabel (index) {
+ this.editEndpoint.configs[1].config[index].labelModule.push({ key: '', value: '' })
+ },
+ removeLogsLabel (logsIndex, i) {
+ if (this.editEndpoint.configs[1].config[logsIndex].labelModule.length === 1) {
+ this.editEndpoint.configs[1].config[logsIndex].labelModule = [{ key: '', value: '' }]
+ return
+ }
+ this.editEndpoint.configs[1].config[logsIndex].labelModule.splice(i, 1)
+ },
// 删除pipeline
delPipeline (logsIndex, pipeLineIndex) {
- this.editModule.configs[1].config[logsIndex].pipeline.splice(pipeLineIndex, 1)
+ this.editEndpoint.configs[1].config[logsIndex].pipeline.splice(pipeLineIndex, 1)
},
// 添加pipelineItem
addPipelineItem (logsIndex, pipelineIndex) {
- const val = this.editModule.configs[1].config[logsIndex].pipeline[pipelineIndex].type
+ const val = this.editEndpoint.configs[1].config[logsIndex].pipeline[pipelineIndex].type
if (val === 'regex') {
- this.editModule.configs[1].config[logsIndex].pipeline[pipelineIndex].expression.push('')
+ this.editEndpoint.configs[1].config[logsIndex].pipeline[pipelineIndex].expression.push('')
} else if (val === 'json') {
- this.editModule.configs[1].config[logsIndex].pipeline[pipelineIndex].expressions.push('')
+ this.editEndpoint.configs[1].config[logsIndex].pipeline[pipelineIndex].expressions.push('')
} else if (val === 'template') {
- this.editModule.configs[1].config[logsIndex].pipeline[pipelineIndex].expressions.push('')
+ this.editEndpoint.configs[1].config[logsIndex].pipeline[pipelineIndex].expressions.push('')
} else if (val === 'timestamp') {
- this.editModule.configs[1].config[logsIndex].pipeline[pipelineIndex].expressions.push('')
+ this.editEndpoint.configs[1].config[logsIndex].pipeline[pipelineIndex].expressions.push('')
} else if (val === 'labels') {
- this.editModule.configs[1].config[logsIndex].pipeline[pipelineIndex].labels.push({
+ this.editEndpoint.configs[1].config[logsIndex].pipeline[pipelineIndex].labels.push({
key: '',
value: ''
})
} else if (val === 'output') {
- this.editModule.configs[1].config[logsIndex].pipeline[pipelineIndex].expressions.push('')
+ this.editEndpoint.configs[1].config[logsIndex].pipeline[pipelineIndex].expressions.push('')
}
},
delPipelineItem (logsIndex, pipelineIndex, itemIndex) {
- const val = this.editModule.configs[1].config[logsIndex].pipeline[pipelineIndex].type
+ const val = this.editEndpoint.configs[1].config[logsIndex].pipeline[pipelineIndex].type
if (val === 'json') {
- this.editModule.configs[1].config[logsIndex].pipeline[pipelineIndex].expressions.splice(itemIndex, 1)
+ this.editEndpoint.configs[1].config[logsIndex].pipeline[pipelineIndex].expressions.splice(itemIndex, 1)
} else if (val === 'labels') {
- this.editModule.configs[1].config[logsIndex].pipeline[pipelineIndex].labels.splice(itemIndex, 1)
+ this.editEndpoint.configs[1].config[logsIndex].pipeline[pipelineIndex].labels.splice(itemIndex, 1)
}
},
resultFormat (resp) {
diff --git a/nezha-fronted/src/components/common/rightBox/moduleBox.vue b/nezha-fronted/src/components/common/rightBox/moduleBox.vue
index ec8b600f6..80816ffa0 100644
--- a/nezha-fronted/src/components/common/rightBox/moduleBox.vue
+++ b/nezha-fronted/src/components/common/rightBox/moduleBox.vue
@@ -63,21 +63,20 @@
{editModule.chartIds = data.map(d => d.id).join(',')}"
+ v-model="editModule.chartIds"
+ class="form-control"
+ :result-format="resultFormat"
>
@@ -731,28 +730,27 @@ export default {
this.editModule.configs[0].config.params = this.paramToJson(this.editModule.paramObj)
this.editModule.configs[0].config.labels = this.labelsToJson(this.editModule.labelModule)
this.editModule.configs[1].config.forEach(item => {
- if (item.labels) {
- item.labels = this.labelsToJson(item.labels)
+ if (item.labelModule) {
+ item.labels = this.labelsToJson(item.labelModule)
+ } else {
+ item.labels = ''
}
})
- const params = { ...this.editModule }
- // params.configs = JSON.stringify(params.configs)
- if (this.authType === 2 && !this.editModule.configs[0].config.bearer_token) {
- // this.$message.error("'token' is required")
- // return
- } else if (this.authType === 1 && !(this.editModule.configs[0].config.basic_auth.username && this.editModule.configs[0].config.basic_auth.pin)) {
- // this.$message.error("'username' and 'password' is required")
- // return
- } else {
- this.authType = 0
- }
+ const params = JSON.parse(JSON.stringify(this.editModule))
+ params.configs[1].config.forEach(item => {
+ item.pipeline && item.pipeline.forEach((pipeline) => {
+ if (pipeline.type === 'labels') {
+ pipeline.labels = this.labelsToJson(pipeline.labels)
+ }
+ })
+ })
+ params.configs = JSON.stringify(params.configs)
this.$refs.moduleForm.validate((valid, errorKey) => {
let key = Object.keys(errorKey)
if (key.length) {
key = key[0]
if (key.indexOf('configs.0') !== -1) {
const keyArr = key.split('.')
- console.log(keyArr)
if (keyArr[3] === 'basic_auth' || keyArr[3] === 'bearer_token') {
this.activeName = 'Auth'
} else if (keyArr[3] === 'basic' || keyArr[3] === 'port') {
@@ -1085,12 +1083,13 @@ export default {
}
},
mounted () {
- this.getWalkData()
- this.ChartTemplateList()
+
},
created () {
this.getProjectList()
this.getCredential()
+ this.getWalkData()
+ this.ChartTemplateList()
},
computed: {
mibName () {
diff --git a/nezha-fronted/src/components/page/monitor/module/moduleList.vue b/nezha-fronted/src/components/page/monitor/module/moduleList.vue
index ac9a26bdc..0b876fa9f 100644
--- a/nezha-fronted/src/components/page/monitor/module/moduleList.vue
+++ b/nezha-fronted/src/components/page/monitor/module/moduleList.vue
@@ -187,36 +187,51 @@ export default {
if (res.code === 200) {
this.object = JSON.parse(JSON.stringify(res.data))
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.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.paramObj = []
this.object.labelModule = []
- this.object.logsConfig.forEach(item => {
+ this.object.configs[1].config.forEach(item => {
item.labelModule = []
if (JSON.stringify(item.labels) !== '{}' && item.labels) {
- Object.keys(this.object.configs.labels).forEach(key => {
+ 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 (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 (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].params[key] })
})
} else {
this.object.paramObj.push({ key: '', value: [] })
}
if (!this.object.chartIds) {
this.object.chartIds = ''
+ } else {
+ // this.object.chartIds = this.object.chartIds.split(',')
}
this.rightBox.show = true
}