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