diff --git a/nezha-fronted/src/components/common/language/en.js b/nezha-fronted/src/components/common/language/en.js index 6ece3d69a..f9b63b119 100644 --- a/nezha-fronted/src/components/common/language/en.js +++ b/nezha-fronted/src/components/common/language/en.js @@ -330,7 +330,7 @@ const en = { host: 'Host',//'Host' assetState: 'State',//'状态' assetPing: 'Ping', - modules: 'Module',//'组件' + modules: 'Endpoint',//'组件' alerts: 'Alert message',//'告警信息' dataCenter: 'DC',//DC cabinet: 'Cabinet',//'机柜' diff --git a/nezha-fronted/src/components/common/rightBox/assetBox.vue b/nezha-fronted/src/components/common/rightBox/assetBox.vue index 15a1f929f..b548a76b3 100644 --- a/nezha-fronted/src/components/common/rightBox/assetBox.vue +++ b/nezha-fronted/src/components/common/rightBox/assetBox.vue @@ -301,7 +301,8 @@ {{assetViewData.idcName}} @@ -343,7 +344,8 @@ {{assetViewData.cabinetName}} @@ -439,7 +441,6 @@ user: '', pwd: '', port: '', - uploadFile: null }], exporter: 0 }, @@ -597,7 +598,6 @@ {required: true, message: this.$t('validate.required'), trigger: 'blur'} ] }, - uploadFileList:[], formData:null, module:{}, accountValideResult:true @@ -638,7 +638,6 @@ pwd:"", port:'', privateKey:'', - uploadFile:'' }); } } @@ -740,7 +739,6 @@ user: '', pwd: '', port: '', - uploadFile: null }] }; } @@ -822,15 +820,6 @@ } }) }, - changeLoginType:function(loginType){ - this.assetData.accounts[0].authType = loginType; - if(loginType == 1){//密码登录 - this.clearFile(); - } - if(loginType == 2){//公钥登录 - this.assetData.accounts[0].pwd=''; - } - }, editData(data, item, mark) { let obj = { id: '', @@ -846,35 +835,33 @@ tel: '' } if (data === 'asset') { - //this.assetData.modelId = this.assetData.modelId.join(',').split(',')[1]; - let modelId = this.assetData.modelId.join(',').split(',')[1]; - let form = new FormData(); - form.append("id", this.pageObj.id); - form.append("sn", this.assetData.sn); - form.append("host", this.assetData.host); - form.append("state", this.assetData.state); - form.append("purchaseDate", !this.assetData.purchaseDate?'':this.assetData.purchaseDate); - form.append("idcId", this.assetData.idcId); - form.append("cabinetId", this.assetData.cabinetId); - form.append("modelId", modelId); - if (!this.accountSwitch) { - this.assetData.accounts = []; - } - for(let i in this.assetData.accounts){ - let account=this.assetData.accounts[i]; - if(account.user){ - if (account.id) { - form.append("accounts["+i+"].id", account.id); - } - form.append("accounts["+i+"].authType",account.authType); - form.append("accounts["+i+"].user", account.user); - form.append("accounts["+i+"].port", account.port); - form.append("accounts["+i+"].pwd", account.pwd); - if(account.authType==2){ - form.append('cert',account.uploadFile?account.uploadFile.raw:null); - } - } - } + this.assetData.modelId = this.assetData.modelId.join(',').split(',')[1]; + // let modelId = this.assetData.modelId.join(',').split(',')[1]; + // let form = new FormData(); + // form.append("id", this.pageObj.id); + // form.append("sn", this.assetData.sn); + // form.append("host", this.assetData.host); + // form.append("state", this.assetData.state); + // form.append("purchaseDate", !this.assetData.purchaseDate?'':this.assetData.purchaseDate); + // form.append("idcId", this.assetData.idcId); + // form.append("cabinetId", this.assetData.cabinetId); + // form.append("modelId", modelId); + // if (!this.accountSwitch) { + // this.assetData.accounts = []; + // } + // for(let i in this.assetData.accounts){ + // let account=this.assetData.accounts[i]; + // if(account.user){ + // if (account.id) { + // form.append("accounts["+i+"].id", account.id); + // } + // form.append("accounts["+i+"].authType",account.authType); + // form.append("accounts["+i+"].user", account.user); + // form.append("accounts["+i+"].port", account.port); + // form.append("accounts["+i+"].pwd", account.pwd); + // form.append("accounts["+i+"].privateKey", account.privateKey); + // } + // } if(this.$refs.accountConfigBox&&this.$refs.accountConfigBox.length>0){ this.$refs.accountConfigBox[0].validateAccount(); @@ -882,11 +869,12 @@ this.$refs.assetEditForm.validate((valid) => { if (valid&&this.accountValideResult) { if (this.pageObj.id) { - this.$put('asset', form,{'Content-Type': 'multipart/form-data'}).then(res => { + this.assetData.id=this.pageObj.id; + console.log(JSON.stringify(this.assetData)); + this.$put('asset', this.assetData).then(res => { const h = this.$createElement; if (res.code === 200) { this.$message({duration: 2000, type: 'success', message: this.$t("tip.saveSuccess")}); - this.clearFile(); this.pageObj.id = ''; this.$emit('refreshData', 'true'); this.sendStateData('close'); @@ -901,44 +889,41 @@ } let modelId = '' let authType = '' - if (this.assetData.modelId !== '') { - modelId = this.assetData.modelId.join(',').split(',')[1] - } else { - this.assetData.modelId = '' - } + // if (this.assetData.modelId !== '') { + // modelId = this.assetData.modelId.join(',').split(',')[1] + // } else { + // this.assetData.modelId = '' + // } if (this.assetData.accounts[0].user === '') { authType = '' } else { authType = this.assetData.accounts[0].authType } - let form = new FormData(); - form.append("sn", this.assetData.sn); - form.append("host", this.assetData.host); - form.append("state", this.assetData.state); - form.append("purchaseDate", !this.assetData.purchaseDate?'':this.assetData.purchaseDate); - form.append("idcId", this.assetData.idcId); - form.append("cabinetId", this.assetData.cabinetId); - form.append("modelId", modelId); - if(this.accountSwitch){ - for(let i in this.assetData.accounts){ - let account=this.assetData.accounts[i]; - if(account.user){ - form.append("accounts["+i+"].authType",account.authType); - form.append("accounts["+i+"].user", account.user); - form.append("accounts["+i+"].port", account.port); - form.append("accounts["+i+"].pwd", account.pwd); - if(account.authType==2){ - form.append('cert',account.uploadFile?account.uploadFile.raw:null); - } - } - } - } - form.append("exporter",parseInt(this.assetData.exporter)); - this.$post('asset', form,{'Content-Type': 'multipart/form-data'}).then(res => { + // let form = new FormData(); + // form.append("sn", this.assetData.sn); + // form.append("host", this.assetData.host); + // form.append("state", this.assetData.state); + // form.append("purchaseDate", !this.assetData.purchaseDate?'':this.assetData.purchaseDate); + // form.append("idcId", this.assetData.idcId); + // form.append("cabinetId", this.assetData.cabinetId); + // form.append("modelId", modelId); + // if(this.accountSwitch){ + // for(let i in this.assetData.accounts){ + // let account=this.assetData.accounts[i]; + // if(account.user){ + // form.append("accounts["+i+"].authType",account.authType); + // form.append("accounts["+i+"].user", account.user); + // form.append("accounts["+i+"].port", account.port); + // form.append("accounts["+i+"].pwd", account.pwd); + // form.append("accounts["+i+"].privateKey", account.privateKey) + // } + // } + // } + // form.append("exporter",parseInt(this.assetData.exporter)); + this.$post('asset', this.assetData).then(res => { const h = this.$createElement; if (res.code === 200) { this.$message({duration: 2000, type: 'success', message: this.$t("tip.saveSuccess")}); - this.clearFile(); this.$emit('refreshData', 'true'); this.sendStateData('close'); } else { @@ -1098,13 +1083,6 @@ } }, - clearFile:function(){ - if(this.$refs.upload){ - this.$refs.upload.clearFiles(); - } - this.uploadFileList=[]; - this.assetData.accounts[0].privateKey=''; - }, deleteData(data, item) { this.$confirm(this.$t("tip.confirmDelete"), { confirmButtonText: this.$t("tip.yes"), @@ -1349,12 +1327,6 @@ this.tempData = '' } }, - handleChange(file,fileList) { - if (fileList.length > 0) { - this.uploadFileList = [fileList[fileList.length - 1]] - } - this.assetData.accounts[0].file = this.uploadFileList[0]; - }, editPopoverClose(data) { if (data === 'type') { this.modelCount = '' @@ -1441,21 +1413,4 @@ margin-bottom: 18px; background-color: #DCDFE6; } -/*去除上传文件动画start*/ -/*.upload-demo {*/ -/* display: flex;*/ -/*}*/ -/deep/ .el-list-enter-active, -/deep/ .el-list-leave-active { - transition: none; -} - -/deep/ .el-list-enter, -/deep/ .el-list-leave-active { - opacity: 0; -} -/deep/ .el-upload-list { - height: 40px; -} -/*去除上传文件动画end*/ diff --git a/nezha-fronted/src/components/page/asset/accountConfig.vue b/nezha-fronted/src/components/page/asset/accountConfig.vue index b28e68fd1..338629420 100644 --- a/nezha-fronted/src/components/page/asset/accountConfig.vue +++ b/nezha-fronted/src/components/page/asset/accountConfig.vue @@ -36,13 +36,7 @@
{{account.port}}
- -
{{$t('asset.createAssetTab.sshKeyWasConfig')}}
- -
+
@@ -59,14 +53,7 @@ export default { created() { }, data(){ - let validateFile=(rule,value,callback) => { - if(!this.validateFile()){ - callback(new Error(this.uploadTip)) - } - callback(); - } return { - uploadFileList:[], rules:{ user:[ { required: true, message:this.$t('validate.required'),trigger: 'blur'} @@ -75,9 +62,6 @@ export default { {required:true,message:this.$t('validate.required'),trigger: 'blur'}, { validator: port, trigger: 'blur'} ], - file:[ - { validator: validateFile, trigger: 'change'} - ] }, uploadTip:'' } @@ -97,12 +81,15 @@ export default { changeLoginType:function(loginType){ this.account.authType=loginType; if(loginType == 1){//密码登录 - this.clearFile(); + this.clearPrivateKey(); } if(loginType == 2){//公钥登录 this.account.pwd=''; } }, + clearPrivateKey:function(){ + this.account.privateKey=null; + }, handleChange(file,fileList) { if (fileList.length > 0) { this.uploadFileList = [fileList[fileList.length - 1]] @@ -110,28 +97,12 @@ export default { this.account.uploadFile = this.uploadFileList[0]; this.validateFile(); }, - clearFile:function() { - if (this.$refs.upload) { - this.$refs.upload.clearFiles(); - } - this.uploadFileList = []; - }, validateAccount:function(){ this.validateResult=false; this.$refs.accountForm.validate((valid) => { this.$emit("setValidateResult",valid); - console.log(valid) }); }, - validateFile:function(){ - let file=this.uploadFileList[0]; - if(file&&file.size>500){ - this.uploadTip=this.$t('validate.fileSize') - return false; - }else{ - return true; - } - }, }, watch:{ diff --git a/nezha-fronted/src/components/page/asset/asset.vue b/nezha-fronted/src/components/page/asset/asset.vue index 3519538fa..7ccff0f4e 100644 --- a/nezha-fronted/src/components/page/asset/asset.vue +++ b/nezha-fronted/src/components/page/asset/asset.vue @@ -37,7 +37,6 @@ export-file-name="asset" export-url="/asset/export" :params="searchLabel" - :template-key="templateKey" @afterImport="getAssetData" class="float-right">