From ba83bb14f3f6176326f2ddae1bc42bbd7e3f8301 Mon Sep 17 00:00:00 2001 From: ibuler Date: Mon, 18 Sep 2023 19:33:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Form/AutoDataForm/index.vue | 3 + src/components/Form/DataForm/index.vue | 5 +- .../Form/FormFields/PasswordRule.vue | 101 ++++++++++++++++++ src/components/Form/FormFields/index.js | 3 + src/i18n/langs/en.json | 28 +++-- src/i18n/langs/ja.json | 25 +++-- src/i18n/langs/zh.json | 7 ++ .../accounts/AccountChangeSecret/fields.js | 44 +------- .../AccountTemplateDetail/Detail.vue | 3 +- src/views/accounts/AccountTemplate/const.js | 12 ++- 10 files changed, 171 insertions(+), 60 deletions(-) create mode 100644 src/components/Form/FormFields/PasswordRule.vue diff --git a/src/components/Form/AutoDataForm/index.vue b/src/components/Form/AutoDataForm/index.vue index 5031e4903..b18b2ba48 100644 --- a/src/components/Form/AutoDataForm/index.vue +++ b/src/components/Form/AutoDataForm/index.vue @@ -67,6 +67,9 @@ export default { } }, computed: { + dataForm() { + return this.$refs.dataForm + }, iForm() { const iForm = {} Object.entries(this.form).forEach(([key, value]) => { diff --git a/src/components/Form/DataForm/index.vue b/src/components/Form/DataForm/index.vue index e0ca366b1..57a1fef62 100644 --- a/src/components/Form/DataForm/index.vue +++ b/src/components/Form/DataForm/index.vue @@ -136,8 +136,8 @@ export default { }) }, // 重置表单 - resetForm(formName) { - this.$refs[formName].resetFields() + resetForm() { + this.$refs['form'].resetFields() }, handleClick(button) { const callback = button.callback || function(values, form) { @@ -148,6 +148,7 @@ export default { callback(values, form, button) }, getFormValue() { + return this.$refs.form.getFormValue() } } } diff --git a/src/components/Form/FormFields/PasswordRule.vue b/src/components/Form/FormFields/PasswordRule.vue new file mode 100644 index 000000000..1b91624d9 --- /dev/null +++ b/src/components/Form/FormFields/PasswordRule.vue @@ -0,0 +1,101 @@ + + + + + diff --git a/src/components/Form/FormFields/index.js b/src/components/Form/FormFields/index.js index 2ae4be679..a652c19e9 100644 --- a/src/components/Form/FormFields/index.js +++ b/src/components/Form/FormFields/index.js @@ -18,6 +18,7 @@ import BoolTextReadonly from './BoolTextReadonly.vue' import NestedObjectSelect2 from './NestedObjectSelect2.vue' import DatetimeRangePicker from './DatetimeRangePicker.vue' import JSONManyToManySelect from './JSONManyToManySelect/index.vue' +import PasswordRule from './PasswordRule.vue' export default { Link, @@ -34,6 +35,7 @@ export default { DynamicInput, PasswordInput, UploadSecret, + PasswordRule, TextReadonly, WeekCronSelect, BoolTextReadonly, @@ -57,6 +59,7 @@ export { DynamicInput, PasswordInput, UploadSecret, + PasswordRule, TextReadonly, WeekCronSelect, BoolTextReadonly, diff --git a/src/i18n/langs/en.json b/src/i18n/langs/en.json index 23ae587ee..f101b8993 100644 --- a/src/i18n/langs/en.json +++ b/src/i18n/langs/en.json @@ -87,7 +87,8 @@ "SystemUserAmount": "SystemUser amount", "AssetChangeSecretUpdate": "Update account change secret", "Success": "Success", - "AddSystemUser": "Add system user" + "AddSystemUser": "Add system user", + "PasswordRule": "PasswordRule" }, "AccountPush": { "WindowsPushHelpText": "Windows assets do not support pushing keys", @@ -490,7 +491,8 @@ "ReLogin": "Re-Login", "ReLoginTitle": "The current three-party login user (cas/saml) is not bound to MFA and does not support password verification. Please login again", "NeedReLogin": "Need Re-Login", - "ReLoginErr": "Login time has exceeded 5 minutes, please login again" + "ReLoginErr": "Login time has exceeded 5 minutes, please login again", + "AddPassKey": "AddPassKey" }, "common": { "Enterprise": "Enterprise", @@ -761,7 +763,8 @@ "Download": "Download", "UserPage": "User page", "View": "View", - "EnterpriseEdition": "Enterprise edition" + "EnterpriseEdition": "Enterprise edition", + "PassKey": "Passkey" }, "passwordOrPassphrase": "Password or Passphrase", "removeErrorMsg": "Remove failed: ", @@ -896,7 +899,13 @@ "LessEqualThan": "Less than or equal to", "OtherRules": "Other rules", "BelongTo": "Belong to", - "GreatEqualThan": "Greater than or equal to" + "GreatEqualThan": "Greater than or equal to", + "PasswordRule": "PasswordRule", + "Uppercase": "Uppercase", + "Length": "Length", + "Digit": "Digit", + "Lowercase": "Lowercase", + "SpecialSymbol": "SpecialSymbol" }, "dashboard": { "ActiveAsset": "Asset active", @@ -1446,7 +1455,8 @@ "DeviceUpdate": "Update Asset - Network Device", "CloudCreate": "Create Asset - Cloud Platform", "DatabaseUpdate": "Update Asset - Database", - "CloudUpdate": "Update Asset - Cloud Platform" + "CloudUpdate": "Update Asset - Cloud Platform", + "OnlineUserDevices": "OnlineUserDevices" }, "rbac": { "Permissions": "Permissions", @@ -1798,7 +1808,8 @@ "SystemTools": "Tools", "BasicTools": "Basic tool", "sync": "Sync", - "AccountStorage": "Account Storage" + "AccountStorage": "Account Storage", + "Passkey": "Passkey" }, "tickets": { "BatchApproval": "Batch approval", @@ -2199,7 +2210,8 @@ "QcloudLighthouse": "Tencent Cloud (lightweight application server)", "KingSoftCloud": "KingSoft Cloud", "CTYunPrivate": "CTYun Private", - "LAN": "LAN" + "LAN": "LAN", + "AccountHelpText": "A cloud account is used to connect to a cloud service provider and access the provider's resource information." }, "Corporation": "Corporation", "Edition": "Edition", @@ -2295,4 +2307,4 @@ "PublishStatus": "Publish status", "NoPublished": "Unpublished" } -} +} \ No newline at end of file diff --git a/src/i18n/langs/ja.json b/src/i18n/langs/ja.json index f5750d834..c2576b9ad 100644 --- a/src/i18n/langs/ja.json +++ b/src/i18n/langs/ja.json @@ -87,7 +87,8 @@ "SystemUserAmount": "システムユーザー数", "AssetChangeSecretUpdate": "アカウントの更新とパスワードの変更", "Success": "成功", - "AddSystemUser": "システムユーザーを追加" + "AddSystemUser": "システムユーザーを追加", + "PasswordRule": "パスワードのルール" }, "AccountPush": { "WindowsPushHelpText": "windows アセットはプッシュキーをサポートしていません", @@ -490,7 +491,8 @@ "ReLogin": "再ログイン", "ReLoginTitle": "現在、サードパーティのログインユーザー(CAS/SAML)は、MFAをバインドしておらず、パスワードチェックをサポートしていません。再ログインしてください。", "NeedReLogin": "再ログインが必要です", - "ReLoginErr": "ログイン時間が 5 分を超えました。もう一度ログインしてください" + "ReLoginErr": "ログイン時間が 5 分を超えました。もう一度ログインしてください", + "AddPassKey": "パスキー(通行鍵)を追加" }, "common": { "Enterprise": "企業版", @@ -764,7 +766,8 @@ "Download": "ダウンロード", "UserPage": "ユーザービュー", "View": "ビュー", - "EnterpriseEdition": "企業版" + "EnterpriseEdition": "企業版", + "PassKey": "パスキー" }, "passwordOrPassphrase": "パスワードまたはキーパスワード", "removeErrorMsg": "削除に失敗しました:", @@ -895,7 +898,13 @@ "LessEqualThan": "以下または等しい", "OtherRules": "他のルール", "BelongTo": "所属する", - "GreatEqualThan": "以上または等しい" + "GreatEqualThan": "以上または等しい", + "PasswordRule": "パスワードのルール", + "Uppercase": "大文字", + "Length": "長さ", + "Digit": "数字", + "Lowercase": "小文字", + "SpecialSymbol": "特殊記号" }, "dashboard": { "TotalJobLog": "ジョブ実行総数", @@ -1791,7 +1800,8 @@ "SMSProvider": "メールサービス業者 / プロトコル", "Applets": "リモート アプリケーション", "sync": "同期", - "AccountStorage": "アカウントストレージ" + "AccountStorage": "アカウントストレージ", + "Passkey": "パスキー" }, "tickets": { "BatchApproval": "大量承認です", @@ -2192,7 +2202,8 @@ "DateSync": "同期日", "Status": "ステータス", "Log": "ログ", - "DeleteReleasedAssets": "リリース済アセットの削除" + "DeleteReleasedAssets": "リリース済アセットの削除", + "AccountHelpText": "クラウドアカウントはクラウドサービスプロバイダーに接続し、プロバイダーのリソース情報にアクセスするためのアカウントです" }, "Template": { "Template": "テンプレート管理" @@ -2287,4 +2298,4 @@ "PublishStatus": "投稿ステータス", "NoPublished": "未発表" } -} +} \ No newline at end of file diff --git a/src/i18n/langs/zh.json b/src/i18n/langs/zh.json index d8b85a794..f8bece0fc 100644 --- a/src/i18n/langs/zh.json +++ b/src/i18n/langs/zh.json @@ -49,6 +49,7 @@ "RecipientHelpText": "当前只支持邮件发送, 若收件人 A B 都设置,账号的密钥将被拆分成前后两部分" }, "AccountChangeSecret": { + "PasswordRule": "密码规则", "ParamsHelpText": "改密参数设置,目前仅对平台种类为主机的资产生效。", "ContainAttachment": "含附件", "AddAsset": "添加资产", @@ -473,6 +474,12 @@ "ReLoginErr": "登录时长已超过 5 分钟,请重新登录" }, "common": { + "PasswordRule": "密码规则", + "Length": "长度", + "Uppercase": "大写字母", + "Lowercase": "小写字母", + "Digit": "数字", + "SpecialSymbol": "特殊字符", "Enterprise": "企业版", "SyncTask": "同步任务", "New": "新建", diff --git a/src/views/accounts/AccountChangeSecret/fields.js b/src/views/accounts/AccountChangeSecret/fields.js index 7915b2132..48199455e 100644 --- a/src/views/accounts/AccountChangeSecret/fields.js +++ b/src/views/accounts/AccountChangeSecret/fields.js @@ -1,49 +1,14 @@ import i18n from '@/i18n/i18n' import { CronTab } from '@/components' -import { TagInput, UpdateToken } from '@/components/Form/FormFields' -import { Required } from '@/components/Form/DataForm/rules' +import { PasswordRule, TagInput, UpdateToken } from '@/components/Form/FormFields' -var validatorInterval = (rule, value, callback) => { +const validatorInterval = (rule, value, callback) => { if (parseInt(value) < 1) { return callback(new Error(i18n.t('accounts.AccountChangeSecret.validatorMessage.EnsureThisValueIsGreaterThanOrEqualTo1'))) } callback() } -function getAssetPasswordRulesItems() { - return [ - { - id: 'length', - prop: 'length', - label: i18n.t('accounts.AccountChangeSecret.PasswordLength'), - rules: [Required], - hidden: ({ secret_strategy, secret_type }) => (secret_strategy === 'specific' || secret_type !== 'password') - } - ] -} - -function generatePasswordRulesItemsFields(obType) { - const itemsFields = [] - let items - if (obType === 'asset') { - items = getAssetPasswordRulesItems() - } - items.forEach((item, index, array) => { - itemsFields.push({ - id: item.id, - prop: item.prop, - el: {}, - attrs: {}, - type: 'input', - label: item.label, - rules: item.rules, - helpText: item.helpText, - hidden: item.hidden - }) - }) - return itemsFields -} - export const getChangeSecretFields = () => { return { secret_type: { @@ -84,8 +49,9 @@ export const getChangeSecretFields = () => { } }, password_rules: { - type: 'group', - items: generatePasswordRulesItemsFields('asset') + component: PasswordRule, + label: i18n.t('accounts.AccountChangeSecret.PasswordRule'), + hidden: ({ secret_strategy, secret_type }) => (secret_strategy === 'specific' || secret_type !== 'password') }, recipients: { label: i18n.t('accounts.AccountChangeSecret.Addressee'), diff --git a/src/views/accounts/AccountTemplate/AccountTemplateDetail/Detail.vue b/src/views/accounts/AccountTemplate/AccountTemplateDetail/Detail.vue index 6086285d1..30d4815b8 100644 --- a/src/views/accounts/AccountTemplate/AccountTemplateDetail/Detail.vue +++ b/src/views/accounts/AccountTemplate/AccountTemplateDetail/Detail.vue @@ -53,7 +53,8 @@ export default { url: `/api/v1/accounts/account-templates/${this.object.id}/`, excludes: ['privileged', 'secret', 'passphrase', 'spec_info'], detailFields: [ - 'id', 'name', 'username', 'secret_type', 'created_by', 'comment', + 'id', 'name', 'username', 'secret_type', 'auto_push', + 'secret_strategy', 'created_by', 'comment', { key: this.$t('accounts.SuFrom'), formatter: () => { diff --git a/src/views/accounts/AccountTemplate/const.js b/src/views/accounts/AccountTemplate/const.js index db8df4bb7..8551b6d30 100644 --- a/src/views/accounts/AccountTemplate/const.js +++ b/src/views/accounts/AccountTemplate/const.js @@ -1,14 +1,15 @@ import { getUuidUpdateFromUrl } from '@/utils/common' -import { UpdateToken } from '@/components/Form/FormFields' +import { PasswordRule, UpdateToken } from '@/components/Form/FormFields' import Select2 from '@/components/Form/FormFields/Select2' import AutomationParams from '@/components/Apps/AutomationParams' +import i18n from '@/i18n/i18n' export const templateFields = (vm) => { return [ [vm.$t('common.Basic'), ['name', 'username', 'privileged', 'su_from']], [vm.$t('assets.Secret'), [ - 'secret_type', 'secret_strategy', 'secret', 'ssh_key', 'token', - 'access_key', 'passphrase', 'api_key' + 'secret_type', 'secret_strategy', 'password_rules', + 'secret', 'ssh_key', 'token', 'access_key', 'passphrase', 'api_key' ]], [vm.$t('accounts.AutoPush'), [ 'auto_push', 'platforms', 'push_params' @@ -93,6 +94,11 @@ export const templateFieldsMeta = (vm) => { }, hidden: (formValue) => formValue.secret_type !== 'api_key' || formValue.secret_strategy === 'random' }, + password_rules: { + component: PasswordRule, + label: i18n.t('accounts.AccountChangeSecret.PasswordRule'), + hidden: ({ secret_strategy, secret_type }) => (secret_strategy === 'specific' || secret_type !== 'password') + }, platforms: { el: { multiple: true, From 1350573ee2a386d4ecbb6a117b8758c04cb1613f Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 19 Sep 2023 10:58:47 +0800 Subject: [PATCH 2/2] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=E7=BF=BB?= =?UTF-8?q?=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/i18n/langs/zh.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i18n/langs/zh.json b/src/i18n/langs/zh.json index f8bece0fc..b7afa62bd 100644 --- a/src/i18n/langs/zh.json +++ b/src/i18n/langs/zh.json @@ -49,7 +49,7 @@ "RecipientHelpText": "当前只支持邮件发送, 若收件人 A B 都设置,账号的密钥将被拆分成前后两部分" }, "AccountChangeSecret": { - "PasswordRule": "密码规则", + "PasswordRule": "密码生成规则", "ParamsHelpText": "改密参数设置,目前仅对平台种类为主机的资产生效。", "ContainAttachment": "含附件", "AddAsset": "添加资产", @@ -474,7 +474,7 @@ "ReLoginErr": "登录时长已超过 5 分钟,请重新登录" }, "common": { - "PasswordRule": "密码规则", + "PasswordRule": "密码生成规则", "Length": "长度", "Uppercase": "大写字母", "Lowercase": "小写字母",