diff --git a/nezha-fronted/src/components/common/rightBox/editEndpointBoxNew.vue b/nezha-fronted/src/components/common/rightBox/editEndpointBoxNew.vue index d52593430..530623f15 100644 --- a/nezha-fronted/src/components/common/rightBox/editEndpointBoxNew.vue +++ b/nezha-fronted/src/components/common/rightBox/editEndpointBoxNew.vue @@ -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 () { diff --git a/nezha-fronted/src/components/common/rightBox/moduleBox.vue b/nezha-fronted/src/components/common/rightBox/moduleBox.vue index 94165bfcc..bb1d6fc46 100644 --- a/nezha-fronted/src/components/common/rightBox/moduleBox.vue +++ b/nezha-fronted/src/components/common/rightBox/moduleBox.vue @@ -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 () { diff --git a/nezha-fronted/src/components/page/config/agent.vue b/nezha-fronted/src/components/page/config/agent.vue index 8e45df1b9..923a26038 100644 --- a/nezha-fronted/src/components/page/config/agent.vue +++ b/nezha-fronted/src/components/page/config/agent.vue @@ -55,7 +55,7 @@ - +
{{$t('config.agent.agent.autoScript')}}
@@ -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 }) } },