diff --git a/src/components/AccountListTable/ViewSecret.vue b/src/components/AccountListTable/ViewSecret.vue index 284d8b564..b38234d63 100644 --- a/src/components/AccountListTable/ViewSecret.vue +++ b/src/components/AccountListTable/ViewSecret.vue @@ -29,7 +29,9 @@ :cell-value="secretInfo.secret" :col="{ formatterArgs: { name: account['name'], + secretType: secretType || '' }}" + @input="onShowKeyCopyFormatterChange" /> @@ -102,6 +104,7 @@ export default { }, data() { return { + modifiedSecret: '', secretInfo: {}, versions: '-', showSecret: false, @@ -129,9 +132,19 @@ export default { }, methods: { accountConfirmHandle() { + this.modifiedSecret && this.onChangeSecretSubmit() this.showSecret = false this.mfaDialogVisible = false }, + onChangeSecretSubmit() { + const params = { + name: this.secretInfo.name, + secret: this.secretInfo.secret + } + this.$axios.patch(`/api/v1/accounts/accounts/${this.account.id}/`, params).then(() => { + this.$message.success(this.$tc('common.updateSuccessMsg')) + }) + }, getAuthInfo() { this.$axios.get(this.url, { disableFlashErrorMsg: true }).then(resp => { this.secretInfo = resp @@ -144,6 +157,10 @@ export default { }, showHistoryDialog() { this.showPasswordHistoryDialog = true + }, + onShowKeyCopyFormatterChange(value) { + if (value === this.secretInfo.secret) return + this.modifiedSecret = value } } } diff --git a/src/components/TableFormatters/ShowKeyCopyFormatter.vue b/src/components/TableFormatters/ShowKeyCopyFormatter.vue index 3893074ac..90549301a 100644 --- a/src/components/TableFormatters/ShowKeyCopyFormatter.vue +++ b/src/components/TableFormatters/ShowKeyCopyFormatter.vue @@ -1,31 +1,26 @@ @@ -47,6 +42,7 @@ export default { hasShow: true, hasDownload: true, hasCopy: true, + hasEdit: true, defaultShow: false } } @@ -54,6 +50,8 @@ export default { }, data() { return { + isEdit: false, + realValue: this.cellValue, formatterArgs: Object.assign(this.formatterArgsDefault, this.col.formatterArgs || {}), isShow: false } @@ -68,14 +66,46 @@ export default { hasCopy: function() { return this.formatterArgs.hasCopy }, + hasEdit: function() { + return this.formatterArgs.hasEdit + }, name: function() { return this.formatterArgs.name }, + iActions() { + const actions = [ + { + has: this.hasEdit && this.formatterArgs?.secretType === 'password', + class: this.isEdit ? 'fa-check' : 'fa-pencil', + action: this.onEdit, + tooltip: this.$t('common.Edit') + }, + { + has: this.hasShow, + class: this.isShow ? 'fa-eye-slash' : 'fa-eye', + action: this.onShow, + tooltip: this.$t('common.View') + }, + { + has: this.hasDownload, + icon: 'fa-download', + action: this.onDownload, + tooltip: this.$t('common.Download') + }, + { + has: this.hasCopy, + icon: 'fa-clone', + action: this.onCopy, + tooltip: this.$t('common.Copy') + } + ] + return actions + }, currentValue() { if (this.isShow) { - return this.cellValue || '-' + return this.realValue || '-' } else { - return this.cellValue ? '******' : '-' + return this.realValue ? '******' : '-' } } }, @@ -87,10 +117,21 @@ export default { this.isShow = !this.isShow }, onCopy() { - copy(this.cellValue) + copy(this.realValue) }, onDownload() { - downloadText(this.cellValue, this.name + '.txt') + downloadText(this.realValue, this.name + '.txt') + }, + onEdit() { + this.isEdit = !this.isEdit + if (this.isEdit) { + this.$nextTick(() => { + this.$refs.editInput.focus() + }) + } + }, + onEditBlur() { + this.$emit('input', this.realValue) } } } @@ -128,4 +169,10 @@ export default { } } } + .edit-input >>> input { + border-left: none; + border-right: none; + border-top: none; + height: 30px; + } diff --git a/src/i18n/langs/en.json b/src/i18n/langs/en.json index 5291405d9..31e79baff 100644 --- a/src/i18n/langs/en.json +++ b/src/i18n/langs/en.json @@ -622,6 +622,7 @@ "Username": "Username", "Validity": "Validity", "Invalidity": "Invalidity", + "Edit": "Edit", "View": "View", "Yes": "Yes", "action": "Action", diff --git a/src/i18n/langs/ja.json b/src/i18n/langs/ja.json index 0d6259267..b49eb56d4 100644 --- a/src/i18n/langs/ja.json +++ b/src/i18n/langs/ja.json @@ -620,6 +620,7 @@ "Username": "ユーザー名", "Validity": "有効", "Invalidity": "無効", + "Edit": "編集", "View": "表示", "Yes": "はい", "action": "アクション", diff --git a/src/i18n/langs/zh.json b/src/i18n/langs/zh.json index f499e4b31..c8843bde7 100644 --- a/src/i18n/langs/zh.json +++ b/src/i18n/langs/zh.json @@ -643,6 +643,7 @@ "Username": "用户名", "Validity": "有效", "Invalidity": "无效", + "Edit": "编辑", "View": "查看", "Yes": "是", "action": "动作",