fix: 修改 endpoint module 编辑新增时 立即点击save params不被保存的问题
This commit is contained in:
@@ -456,52 +456,56 @@ export default {
|
||||
},
|
||||
/* 保存 */
|
||||
save () {
|
||||
this.editEndpoint.configs.params = this.paramToJson(this.editEndpoint.paramObj)
|
||||
this.editEndpoint.configs.labels = this.labelsToJson(this.editEndpoint.labelModule)
|
||||
this.editEndpoint.paramObj = this.editEndpoint.paramObj.filter(item => item.value && item.value.length)
|
||||
this.editEndpoint.labelModule = this.editEndpoint.labelModule.filter(item => item.value)
|
||||
const params = { ...this.editEndpoint }
|
||||
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) => {
|
||||
if (valid) {
|
||||
if (this.optionType === 'add' || this.optionType === 'batch') {
|
||||
this.prevent_opt.save = true
|
||||
if (this.editEndpoint.assetId) {
|
||||
this.$emit('close', true, this.editEndpoint, false)
|
||||
this.prevent_opt.save = false
|
||||
} else {
|
||||
this.$emit('close', true, this.editEndpoint, true)
|
||||
this.prevent_opt.save = false
|
||||
}
|
||||
} else if (this.optionType === 'edit') {
|
||||
if (this.editEndpoint.id) {
|
||||
this.$put('monitor/endpoint', [params]).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
||||
this.$store.commit('setReloadFacade')
|
||||
this.esc(true)
|
||||
} else {
|
||||
this.$message.error(response.msg)
|
||||
}
|
||||
this.prevent_opt.save = true
|
||||
setTimeout(() => {
|
||||
this.editEndpoint.configs.params = this.paramToJson(this.editEndpoint.paramObj)
|
||||
this.editEndpoint.configs.labels = this.labelsToJson(this.editEndpoint.labelModule)
|
||||
this.editEndpoint.paramObj = this.editEndpoint.paramObj.filter(item => item.value && item.value.length)
|
||||
this.editEndpoint.labelModule = this.editEndpoint.labelModule.filter(item => item.value)
|
||||
const params = { ...this.editEndpoint }
|
||||
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) => {
|
||||
if (valid) {
|
||||
if (this.optionType === 'add' || this.optionType === 'batch') {
|
||||
this.prevent_opt.save = true
|
||||
if (this.editEndpoint.assetId) {
|
||||
this.$emit('close', true, this.editEndpoint, false)
|
||||
this.prevent_opt.save = false
|
||||
})
|
||||
} else {
|
||||
this.$emit('close', true, this.editEndpoint, true)
|
||||
this.prevent_opt.save = false
|
||||
}
|
||||
} else if (this.optionType === 'edit') {
|
||||
if (this.editEndpoint.id) {
|
||||
this.$put('monitor/endpoint', [params]).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
||||
this.$store.commit('setReloadFacade')
|
||||
this.esc(true)
|
||||
} else {
|
||||
this.$message.error(response.msg)
|
||||
}
|
||||
this.prevent_opt.save = false
|
||||
})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.prevent_opt.save = false
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}, 10)
|
||||
},
|
||||
/* 删除 */
|
||||
del () {
|
||||
|
||||
@@ -454,49 +454,52 @@ export default {
|
||||
},
|
||||
/* 保存 */
|
||||
save () {
|
||||
this.editModule.configs.params = this.paramToJson(this.editModule.paramObj)
|
||||
this.editModule.configs.labels = this.labelsToJson(this.editModule.labelModule)
|
||||
const params = { ...this.editModule }
|
||||
params.configs.walk = params.walk
|
||||
params.configs.port = params.port
|
||||
params.configs = JSON.stringify(params.configs)
|
||||
if (this.authType === 2 && !this.editModule.configs.bearer_token) {
|
||||
this.$message.error("'token' is required")
|
||||
} else if (this.authType === 1 && !(this.editModule.configs.basic_auth.username && this.editModule.configs.basic_auth.pin)) {
|
||||
this.$message.error("'username' and 'password' is required")
|
||||
} else {
|
||||
this.authType = 0
|
||||
}
|
||||
this.$refs.moduleForm.validate((valid) => {
|
||||
if (valid) {
|
||||
this.prevent_opt.save = true
|
||||
if (this.editModule.id) {
|
||||
this.$put('monitor/module', params).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
||||
this.$store.commit('setReloadFacade')
|
||||
this.esc(true)
|
||||
} else {
|
||||
this.$message.error(response.msg)
|
||||
}
|
||||
this.prevent_opt.save = false
|
||||
})
|
||||
} else {
|
||||
this.$post('monitor/module', params).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
||||
this.$store.commit('setReloadFacade')
|
||||
this.esc(true)
|
||||
} else {
|
||||
this.$message.error(response.msg)
|
||||
}
|
||||
this.prevent_opt.save = false
|
||||
})
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.editModule.configs.params = this.paramToJson(this.editModule.paramObj)
|
||||
this.editModule.configs.labels = this.labelsToJson(this.editModule.labelModule)
|
||||
const params = { ...this.editModule }
|
||||
params.configs.walk = params.walk
|
||||
params.configs.port = params.port
|
||||
params.configs = JSON.stringify(params.configs)
|
||||
if (this.authType === 2 && !this.editModule.configs.bearer_token) {
|
||||
this.$message.error("'token' is required")
|
||||
} else if (this.authType === 1 && !(this.editModule.configs.basic_auth.username && this.editModule.configs.basic_auth.pin)) {
|
||||
this.$message.error("'username' and 'password' is required")
|
||||
} else {
|
||||
return false
|
||||
this.authType = 0
|
||||
}
|
||||
})
|
||||
this.$refs.moduleForm.validate((valid) => {
|
||||
if (valid) {
|
||||
this.prevent_opt.save = true
|
||||
if (this.editModule.id) {
|
||||
this.$put('monitor/module', params).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
||||
this.$store.commit('setReloadFacade')
|
||||
this.esc(true)
|
||||
} else {
|
||||
this.$message.error(response.msg)
|
||||
}
|
||||
this.prevent_opt.save = false
|
||||
})
|
||||
} else {
|
||||
this.$post('monitor/module', params).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
||||
this.$store.commit('setReloadFacade')
|
||||
this.esc(true)
|
||||
} else {
|
||||
this.$message.error(response.msg)
|
||||
}
|
||||
this.prevent_opt.save = false
|
||||
})
|
||||
}
|
||||
} else {
|
||||
this.prevent_opt.save = false
|
||||
return false
|
||||
}
|
||||
})
|
||||
}, 10)
|
||||
},
|
||||
/* 删除 */
|
||||
del () {
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item class="half-form-item">
|
||||
<button class="nz-btn nz-btn-size-normal-new nz-btn-style-normal-new" type="button" @click="downloadAgent">{{$t('config.agent.agent.download')}}</button>
|
||||
<button :class="{'nz-btn-disabled':downloadAgentFlag}" :disabled="downloadAgentFlag" class="nz-btn nz-btn-size-normal-new nz-btn-style-normal-new" type="button" @click="downloadAgent">{{$t('config.agent.agent.download')}}</button>
|
||||
</el-form-item>
|
||||
<div class="right-box-sub-title">{{$t('config.agent.agent.autoScript')}}</div>
|
||||
<div style="margin-bottom: 20px;width: 100%"></div>
|
||||
@@ -177,7 +177,8 @@ export default {
|
||||
},
|
||||
wgetVisible: false,
|
||||
curlVisible: false,
|
||||
federationEnabled: !Number(localStorage.getItem('nz-prometheus-federation-enabled'))
|
||||
federationEnabled: !Number(localStorage.getItem('nz-prometheus-federation-enabled')),
|
||||
downloadAgentFlag: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -245,7 +246,9 @@ export default {
|
||||
}
|
||||
},
|
||||
downloadAgent: function () {
|
||||
this.downloadAgentFlag = true
|
||||
axios.get('agent/download?os=' + this.agentParam.osType, { responseType: 'blob' }).then(data => {
|
||||
this.downloadAgentFlag = false
|
||||
let fileName = 'confagent'
|
||||
const disposition = data.headers['content-disposition']
|
||||
if (disposition) {
|
||||
@@ -266,6 +269,8 @@ export default {
|
||||
link.click()
|
||||
window.URL.revokeObjectURL(link.href)
|
||||
}
|
||||
}).catch(()=>{
|
||||
this.downloadAgentFlag = false
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user