Files
lina/src/components/AccountListTable/UpdateSecretInfo.vue
fit2bot c0448afda4 Fix rbac (#1361)
* perf: debug account

* Debug: 添加 debug

* debug: 添加线上debug

* debug: remove vue config

* chore: diglog 添加vif

* debug: authbook

* chore: debug account

* fix: 修改资产账号更新弹窗组件传参方式

* perf: 修改 authbook

* fix: 修复资产账号的更新组件不生效问题

* perf: change build scropt

* feat: 配置概况页的路由权限

* fix: 修复工单流自定义用户获取全局用户bug

* fix: 修复系统角色绑定用户为全局用户

* fix: 修改i18n cn.json=>zh-hans.json 文件名

* fix: 修改i18n cn.json 文件名

Co-authored-by: ibuler <ibuler@qq.com>
Co-authored-by: “怀磊” <2280131253@qq.com>
Co-authored-by: feng626 <1304903146@qq.com>
Co-authored-by: Jiangjie.Bai <bugatti_it@163.com>
2022-03-02 20:49:23 +08:00

104 lines
2.7 KiB
Vue

<template>
<Dialog
width="50"
:title="this.$t('assets.UpdateAssetUserToken')"
:destroy-on-close="true"
:visible.sync="isVisible"
@update:visible="(event) => $emit('update:visible', event)"
@confirm="handleConfirm()"
@cancel="handleCancel()"
v-on="$listeners"
>
<el-form label-position="right" label-width="90px">
<el-form-item :label="this.$t('assets.Hostname')">
<el-input v-model="account.hostname" readonly />
</el-form-item>
<el-form-item :label="this.$t('assets.Username')">
<el-input v-model="account['username']" readonly />
</el-form-item>
<el-form-item :label="this.$t('assets.Password')">
<UpdateToken v-model="authInfo.password" />
</el-form-item>
<el-form-item :label="this.$t('assets.SSHSecretKey')">
<UploadKey @input="getFile" />
</el-form-item>
<el-form-item :label="this.$t('assets.Passphrase')">
<UpdateToken v-model="authInfo.passphrase" />
</el-form-item>
</el-form>
</Dialog>
</template>
<script>
import { Dialog, UploadKey } from '@/components'
import { UpdateToken } from '@/components/FormFields'
export default {
name: 'UpdateSecretInfo',
components: {
Dialog,
UploadKey,
UpdateToken
},
props: {
account: {
type: Object,
default: () => ({})
},
visible: {
type: Boolean,
default: false
}
},
data() {
return {
authInfo: {
password: '',
private_key: '',
passphrase: ''
}
}
},
computed: {
isVisible() {
return this.visible
}
},
methods: {
handleConfirm() {
const data = {}
if (this.authInfo.password !== '') {
data.password = this.authInfo.password
}
if (this.authInfo.private_key !== '') {
data.private_key = this.authInfo.private_key
if (this.authInfo.passphrase) data.passphrase = this.authInfo.passphrase
}
this.$axios.patch(
`/api/v1/assets/accounts/${this.account.id}/`,
data,
{ disableFlashErrorMsg: true }
).then(res => {
this.authInfo = { password: '', private_key: '' }
this.$message.success(this.$tc('common.updateSuccessMsg'))
this.$emit('updateAuthDone', res)
this.$emit('update:visible', false)
}).catch(err => {
const errMsg = Object.values(err.response.data).join(', ')
this.$message.error(this.$tc('common.updateErrorMsg') + ' ' + errMsg)
this.$emit('update:visible', true)
})
},
handleCancel() {
this.$emit('update:visible', false)
},
getFile(file) {
this.authInfo.private_key = file
}
}
}
</script>
<style scoped>
</style>