From 47d602302f9a90f896182e4a1fd1a771f60b3a93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chuailei000=E2=80=9D?= <2280131253@qq.com> Date: Fri, 14 Apr 2023 11:23:42 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E8=B4=A6=E5=8F=B7=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=8E=A8=E9=80=81=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AccountCreateUpdateForm/index.vue | 18 ++++- src/i18n/langs/en.json | 2 +- src/i18n/langs/ja.json | 2 +- src/i18n/langs/zh.json | 2 +- .../accounts/Account/AccountDetail/Detail.vue | 47 +++++++++-- .../Platform/AutomationParamsSetting.vue | 77 ++++++++++--------- 6 files changed, 100 insertions(+), 48 deletions(-) diff --git a/src/components/AccountCreateUpdateForm/index.vue b/src/components/AccountCreateUpdateForm/index.vue index 2b968a9fb..9c316f29f 100644 --- a/src/components/AccountCreateUpdateForm/index.vue +++ b/src/components/AccountCreateUpdateForm/index.vue @@ -14,6 +14,7 @@ import Select2 from '@/components/FormFields/Select2' import AssetSelect from '@/components/AssetSelect' import { encryptPassword } from '@/utils/crypto' import { Required, RequiredChange } from '@/components/DataForm/rules' +import AutomationParamsForm from '@/views/assets/Platform/AutomationParamsSetting.vue' export default { name: 'AccountCreateForm', @@ -69,7 +70,7 @@ export default { 'secret_type', 'secret', 'ssh_key', 'token', 'access_key', 'passphrase' ]], - [this.$t('common.Other'), ['push_now', 'on_invalid', 'is_active', 'comment']] + [this.$t('common.Other'), ['push_now', 'params', 'on_invalid', 'is_active', 'comment']] ], fieldsMeta: { assets: { @@ -206,6 +207,21 @@ export default { return !automation.push_account_enabled || !automation.ansible_enabled || !this.$hasPerm('accounts.push_account') || this.addTemplate } }, + params: { + label: this.$t('assets.PushParams'), + component: AutomationParamsForm, + el: { + method: this.asset?.auto_config?.push_account_method + }, + hidden: (formValue) => { + const automation = this.iPlatform.automation || {} + return !formValue.push_now || + !automation.push_account_enabled || + !automation.ansible_enabled || + !this.$hasPerm('accounts.push_account') || + this.addTemplate + } + }, comment: { hidden: () => { return this.addTemplate diff --git a/src/i18n/langs/en.json b/src/i18n/langs/en.json index 45b0b4dc8..72b617cd9 100644 --- a/src/i18n/langs/en.json +++ b/src/i18n/langs/en.json @@ -359,7 +359,7 @@ "Protocols": "Protocols", "PublicIp": "Public ip", "Push": "Push", - "PushSetting": "Push setting", + "PushParams": "Push params", "PushSystemUserNow": "Push system user now", "PushAllSystemUsersToAsset": "Push all system users to asset", "QuickUpdate": "Quick update", diff --git a/src/i18n/langs/ja.json b/src/i18n/langs/ja.json index 2aef75aaf..243bf0a3a 100644 --- a/src/i18n/langs/ja.json +++ b/src/i18n/langs/ja.json @@ -353,7 +353,7 @@ "LoginOption": "ログインオプション", "PublicIp": "パブリックネットワークIP", "Push": "プッシュ", - "PushSetting": "プッシュ設定", + "PushParams": "プッシュパラメータ", "PushSystemUserNow": "プッシュシステムユーザー", "PushAllSystemUsersToAsset": "すべてのシステムユーザーをアセットにプッシュ", "QuickUpdate": "クイックアップデート", diff --git a/src/i18n/langs/zh.json b/src/i18n/langs/zh.json index 869bd45f7..42cbc550b 100644 --- a/src/i18n/langs/zh.json +++ b/src/i18n/langs/zh.json @@ -371,7 +371,7 @@ "LoginOption": "登录选项", "PublicIp": "公网IP", "Push": "推送", - "PushSetting": "推送设置", + "PushParams": "推送参数", "PushSystemUserNow": "推送系统用户", "PushAllSystemUsersToAsset": "推送所有系统用户到资产", "QuickUpdate": "快速更新", diff --git a/src/views/accounts/Account/AccountDetail/Detail.vue b/src/views/accounts/Account/AccountDetail/Detail.vue index 88c3719c7..be5021e1d 100644 --- a/src/views/accounts/Account/AccountDetail/Detail.vue +++ b/src/views/accounts/Account/AccountDetail/Detail.vue @@ -11,6 +11,13 @@ :url="secretUrl" :visible.sync="showViewSecretDialog" /> + @@ -20,12 +27,14 @@ import AutoDetailCard from '@/components/DetailCard/auto' import QuickActions from '@/components/QuickActions' import ViewSecret from '@/components/AccountListTable/ViewSecret' import { openTaskPage } from '@/utils/jms' +import AutomationParamsForm from '@/views/assets/Platform/AutomationParamsSetting.vue' export default { name: 'Detail', components: { AutoDetailCard, QuickActions, + AutomationParamsForm, ViewSecret }, props: { @@ -39,6 +48,8 @@ export default { const filterSuFrom = ['database', 'device', 'cloud', 'web', 'windows'] return { + needSetAutoPushParams: false, + autoPushVisible: false, secretUrl: `/api/v1/accounts/account-secrets/${this.object.id}/`, showViewSecretDialog: false, quickActions: [ @@ -117,12 +128,16 @@ export default { }, callbacks: Object.freeze({ click: () => { - this.$axios.post( - `/api/v1/accounts/accounts/tasks/`, - { action: 'push', accounts: [this.object.id] } - ).then(res => { - openTaskPage(res['task']) - }) + if (this.needSetAutoPushParams) { + this.autoPushVisible = true + } else { + this.$axios.post( + `/api/v1/accounts/accounts/tasks/`, + { action: 'push', accounts: [this.object.id] } + ).then(res => { + openTaskPage(res['task']) + }) + } } }) }, @@ -205,6 +220,26 @@ export default { } }, computed: { + pushAccountMethod() { + return this.object.asset?.auto_config?.push_account_method || '' + } + }, + methods: { + onCanSetting(item) { + this.needSetAutoPushParams = item + }, + onSubmit(form) { + this.$axios.post( + `/api/v1/accounts/accounts/tasks/`, + { + action: 'push', + accounts: [this.object.id], + params: form + } + ).then(res => { + openTaskPage(res['task']) + }) + } } } diff --git a/src/views/assets/Platform/AutomationParamsSetting.vue b/src/views/assets/Platform/AutomationParamsSetting.vue index 31d7f695b..aac964dd7 100644 --- a/src/views/assets/Platform/AutomationParamsSetting.vue +++ b/src/views/assets/Platform/AutomationParamsSetting.vue @@ -1,18 +1,20 @@