From b19c79f48c5e8a57d75deb0cff848d786b539bca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chuailei000=E2=80=9D?= <2280131253@qq.com> Date: Thu, 29 Sep 2022 17:00:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B9=B3=E5=8F=B0=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BF=AB=E9=80=9F=E6=9B=B4=E6=96=B0=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/FormFields/JsonEditor.vue | 4 +- src/i18n/langs/en.json | 5 + src/i18n/langs/ja.json | 5 + src/i18n/langs/zh.json | 5 + src/router/console/assets.js | 2 +- src/views/assets/Platform/Detail.vue | 58 --------- .../assets/Platform/PlatformCreateUpdate.vue | 70 +--------- .../assets/Platform/PlatformDetail/Detail.vue | 121 ++++++++++++++++++ .../PlatformDetailUpdateDialog.vue | 73 +++++++++++ .../index.vue} | 0 src/views/assets/Platform/const.js | 75 +++++++++++ 11 files changed, 289 insertions(+), 129 deletions(-) delete mode 100644 src/views/assets/Platform/Detail.vue create mode 100644 src/views/assets/Platform/PlatformDetail/Detail.vue create mode 100644 src/views/assets/Platform/PlatformDetail/PlatformDetailUpdateDialog.vue rename src/views/assets/Platform/{PlatformDetail.vue => PlatformDetail/index.vue} (100%) create mode 100644 src/views/assets/Platform/const.js diff --git a/src/components/FormFields/JsonEditor.vue b/src/components/FormFields/JsonEditor.vue index f85ba4b60..6d90fb684 100644 --- a/src/components/FormFields/JsonEditor.vue +++ b/src/components/FormFields/JsonEditor.vue @@ -18,7 +18,7 @@ export default { components: { JsonEditor }, props: { value: { - type: String, + type: [String, Object], default: () => '' } }, @@ -29,7 +29,7 @@ export default { } }, created() { - this.resultInfo = JSON.parse(this.value) + this.resultInfo = typeof this.value === 'string' ? JSON.parse(this.value) : this.value }, methods: { // 数据改变 diff --git a/src/i18n/langs/en.json b/src/i18n/langs/en.json index 52da551c0..b9b45c91b 100644 --- a/src/i18n/langs/en.json +++ b/src/i18n/langs/en.json @@ -188,6 +188,11 @@ "Pending": "Pending", "Platform": "Platform", "PlatformDetail": "Platform detail", + "DomainEnabled": "Enable domain", + "ProtocolsEnabled": "Enable protocol", + "AccountEnabled": "Enable account switching", + "AutoEnabled": "Enable Automation", + "SupportedProtocol": "Supported protocol", "PriorityHelpMessage": "1-100, High level will be using login asset as default, if user was granted more than 2 system user", "Protocol": "Protocol", "Protocols": "Protocols", diff --git a/src/i18n/langs/ja.json b/src/i18n/langs/ja.json index fdd7a7f43..67d989d51 100644 --- a/src/i18n/langs/ja.json +++ b/src/i18n/langs/ja.json @@ -191,6 +191,11 @@ "Pending": "待つ", "Platform": "システムプラットフォーム", "PlatformDetail": "プラットフォームの詳細", + "DomainEnabled": "ドメインを有効化", + "ProtocolsEnabled": "プロトコルの有効化", + "AccountEnabled": "アカウントを有効にする", + "AutoEnabled": "自動化の有効化", + "SupportedProtocol": "サポートされるプロトコル", "PriorityHelpMessage": "1-100、1最低優先度、100最高優先度。複数のユーザーを許可する場合、優先度の高いシステムユーザーはデフォルトのログインユーザーになります", "Protocol": "プロトコル", "Protocols": "プロトコルグループ", diff --git a/src/i18n/langs/zh.json b/src/i18n/langs/zh.json index 9c7fc3824..02478be55 100644 --- a/src/i18n/langs/zh.json +++ b/src/i18n/langs/zh.json @@ -192,6 +192,11 @@ "Pending": "等待", "Platform": "系统平台", "PlatformDetail": "平台详情", + "DomainEnabled": "启用网域", + "ProtocolsEnabled": "启用协议", + "AccountEnabled": "启用切换账号", + "AutoEnabled": "启用自动化", + "SupportedProtocol": "支持的协议", "PriorityHelpMessage": "1-100, 1最低优先级,100最高优先级。授权多个用户时,高优先级的系统用户将会作为默认登录用户", "Protocol": "协议", "Protocols": "协议", diff --git a/src/router/console/assets.js b/src/router/console/assets.js index 4b4f22cfd..fb55c7caa 100644 --- a/src/router/console/assets.js +++ b/src/router/console/assets.js @@ -278,7 +278,7 @@ export default [ }, { path: ':id', - component: () => import('@/views/assets/Platform/PlatformDetail.vue'), // Parent router-view + component: () => import('@/views/assets/Platform/PlatformDetail'), // Parent router-view name: 'PlatformDetail', hidden: true, meta: { title: i18n.t('route.PlatformDetail') } diff --git a/src/views/assets/Platform/Detail.vue b/src/views/assets/Platform/Detail.vue deleted file mode 100644 index 9a2634c9f..000000000 --- a/src/views/assets/Platform/Detail.vue +++ /dev/null @@ -1,58 +0,0 @@ - - - - - diff --git a/src/views/assets/Platform/PlatformCreateUpdate.vue b/src/views/assets/Platform/PlatformCreateUpdate.vue index 9167da713..a61e1b40a 100644 --- a/src/views/assets/Platform/PlatformCreateUpdate.vue +++ b/src/views/assets/Platform/PlatformCreateUpdate.vue @@ -13,9 +13,7 @@ + + diff --git a/src/views/assets/Platform/PlatformDetail/PlatformDetailUpdateDialog.vue b/src/views/assets/Platform/PlatformDetail/PlatformDetailUpdateDialog.vue new file mode 100644 index 000000000..cd02ef79e --- /dev/null +++ b/src/views/assets/Platform/PlatformDetail/PlatformDetailUpdateDialog.vue @@ -0,0 +1,73 @@ + + + + + diff --git a/src/views/assets/Platform/PlatformDetail.vue b/src/views/assets/Platform/PlatformDetail/index.vue similarity index 100% rename from src/views/assets/Platform/PlatformDetail.vue rename to src/views/assets/Platform/PlatformDetail/index.vue diff --git a/src/views/assets/Platform/const.js b/src/views/assets/Platform/const.js new file mode 100644 index 000000000..319c14712 --- /dev/null +++ b/src/views/assets/Platform/const.js @@ -0,0 +1,75 @@ +import i18n from '@/i18n/i18n' +import rules from '@/components/DataForm/rules' +import { JsonEditor } from '@/components/FormFields' +import { assetFieldsMeta } from '@/views/assets/const' +const assetMeta = assetFieldsMeta() + +export const fieldsMeta = { + automation: { + initial: { + ansible_config: '' + }, + fields: [ + 'ansible_enabled', 'ansible_config', + 'ping_enabled', 'ping_method', + 'gather_facts_enabled', 'gather_facts_method', + 'create_account_enabled', 'create_account_method', + 'change_password_enabled', 'change_password_method', + 'verify_account_enabled', 'verify_account_method' + ], + fieldsMeta: { + ansible_config: { + component: JsonEditor, + el: { + value: '{}' + }, + hidden: (formValue) => !formValue['ansible_enabled'] + }, + ping_method: {}, + gather_facts_method: {}, + create_account_method: {}, + change_password_method: {}, + verify_account_method: {} + } + }, + category_type: { + type: 'cascader', + label: i18n.t('assets.Type'), + rules: [ + rules.Required + ], + el: { + multiple: false, + options: [], + disabled: true + }, + hidden: (formValue) => { + if (formValue.category_type[0] === undefined) { + formValue.category_type = this.initial.category_type + } + } + }, + charset: {}, + protocols_enabled: { + el: { + disabled: false + } + }, + domain_enabled: { + el: { + disabled: false + } + }, + protocols: { + label: i18n.t('assets.SupportedProtocol'), + ...assetMeta.protocols, + el: { + choices: [] + }, + hidden: (formValue) => !formValue['protocols_enabled'] + }, + su_method: { + type: 'select', + hidden: (form) => !form['su_enabled'] + } +}