From b25d2016a681d4d4049c686e5a5cc35c8431bddd Mon Sep 17 00:00:00 2001 From: ibuler Date: Mon, 18 Nov 2024 14:35:43 +0800 Subject: [PATCH] perf: using checkbox replace switch --- src/components/Form/AutoDataForm/utils.js | 6 +++--- .../Form/FormFields/PasswordRule.vue | 8 ++++---- .../AccountDiscover/TaskCreateUpdate.vue | 4 ++-- src/views/accounts/const.js | 2 +- .../Cloud/Account/AccountCreateUpdate.vue | 6 +++--- .../SyncInstanceTaskCreateUpdate.vue | 13 ++++++------ .../Platform/AutomationParamsSetting.vue | 1 + src/views/assets/const.js | 2 +- src/views/ops/Job/JobUpdateCreate.vue | 2 +- .../AccountCheck/AccountCheckCreateUpdate.vue | 16 ++++++++++++++- .../AccountCheckExecutionList.vue | 20 ++++++++++++++----- src/views/pam/AccountCheck/index.vue | 2 +- .../AssetPermissionDetail.vue | 2 +- .../Auth/Ldap/HaSyncSettingDialog.vue | 2 +- .../settings/Auth/Ldap/SyncSettingDialog.vue | 2 +- 15 files changed, 57 insertions(+), 31 deletions(-) diff --git a/src/components/Form/AutoDataForm/utils.js b/src/components/Form/AutoDataForm/utils.js index 55deadb1b..a1a3826bd 100644 --- a/src/components/Form/AutoDataForm/utils.js +++ b/src/components/Form/AutoDataForm/utils.js @@ -1,7 +1,6 @@ import Vue from 'vue' import ObjectSelect2 from '@/components/Form/FormFields/NestedObjectSelect2.vue' import NestedField from '@/components/Form/AutoDataForm/components/NestedField.vue' -import Switcher from '@/components/Form/FormFields/Switcher.vue' import rules from '@/components/Form/DataForm/rules' import BasicTree from '@/components/Form/FormFields/BasicTree.vue' import JsonEditor from '@/components/Form/FormFields/JsonEditor.vue' @@ -65,8 +64,9 @@ export class FormFieldGenerator { } break case 'boolean': - type = '' - field.component = Switcher + type = 'checkbox' + // field.component = Switcher + // field.type = 'checkbox' break case 'list': type = 'input' diff --git a/src/components/Form/FormFields/PasswordRule.vue b/src/components/Form/FormFields/PasswordRule.vue index 8f7424833..cd8b18679 100644 --- a/src/components/Form/FormFields/PasswordRule.vue +++ b/src/components/Form/FormFields/PasswordRule.vue @@ -54,22 +54,22 @@ export default { { id: 'uppercase', label: this.$t('Uppercase'), - type: 'switch' + type: 'checkbox' }, { id: 'lowercase', label: this.$t('Lowercase'), - type: 'switch' + type: 'checkbox' }, { id: 'digit', label: this.$t('Digit'), - type: 'switch' + type: 'checkbox' }, { id: 'symbol', label: this.$t('SpecialSymbol'), - type: 'switch' + type: 'checkbox' }, { id: 'exclude_symbols', diff --git a/src/views/accounts/AccountDiscover/TaskCreateUpdate.vue b/src/views/accounts/AccountDiscover/TaskCreateUpdate.vue index a15b5534c..c9bf2dfa4 100644 --- a/src/views/accounts/AccountDiscover/TaskCreateUpdate.vue +++ b/src/views/accounts/AccountDiscover/TaskCreateUpdate.vue @@ -15,7 +15,7 @@ export default { return { fields: [ [this.$t('Basic'), ['name', 'nodes', 'assets']], - [this.$t('发现配置'), ['is_sync_account', 'recipients']], + [this.$t('DiscoverConfig'), ['is_sync_account', 'check_risk', 'recipients']], [this.$t('Periodic'), ['is_periodic', 'crontab', 'interval']], [this.$t('Other'), ['is_active', 'comment']] ], @@ -23,10 +23,10 @@ export default { hasDetailInMsg: false, fieldsMeta: { is_sync_account: { - type: 'switch', label: this.$t('IsSyncAccountLabel'), helpText: this.$t('IsSyncAccountHelpText') }, + check_risk: {}, is_periodic, crontab, interval, diff --git a/src/views/accounts/const.js b/src/views/accounts/const.js index a55068c6b..67e378268 100644 --- a/src/views/accounts/const.js +++ b/src/views/accounts/const.js @@ -38,7 +38,7 @@ export const interval = { } export const is_periodic = { - type: 'switch', + type: 'checkbox', hidden: (formValue) => { return !store.getters.hasValidLicense } diff --git a/src/views/assets/Cloud/Account/AccountCreateUpdate.vue b/src/views/assets/Cloud/Account/AccountCreateUpdate.vue index 38c8a19c0..2652b6346 100644 --- a/src/views/assets/Cloud/Account/AccountCreateUpdate.vue +++ b/src/views/assets/Cloud/Account/AccountCreateUpdate.vue @@ -214,12 +214,12 @@ export default { helpTip: this.$t('HostnameStrategy') }, is_always_update: { - type: 'switch', + type: 'checkbox', label: this.$t('IsAlwaysUpdate'), helpTip: this.$t('IsAlwaysUpdateHelpTip') }, fully_synchronous: { - type: 'switch', + type: 'checkbox', label: this.$t('FullySynchronous'), helpTip: this.$t('FullySynchronousHelpTip') }, @@ -238,7 +238,7 @@ export default { } }, is_periodic: { - type: 'switch' + type: 'checkbox' }, crontab: { component: CronTab, diff --git a/src/views/assets/Cloud/SyncInstanceTask/SyncInstanceTaskCreateUpdate.vue b/src/views/assets/Cloud/SyncInstanceTask/SyncInstanceTaskCreateUpdate.vue index 8ed6c35a9..87a1c48ce 100644 --- a/src/views/assets/Cloud/SyncInstanceTask/SyncInstanceTaskCreateUpdate.vue +++ b/src/views/assets/Cloud/SyncInstanceTask/SyncInstanceTaskCreateUpdate.vue @@ -59,12 +59,12 @@ export default { helpTips: this.$t('xpack.Cloud.HostnameStrategy') }, is_always_update: { - type: 'switch', + type: 'checkbox', label: this.$t('xpack.Cloud.IsAlwaysUpdate'), helpTips: this.$t('xpack.Cloud.IsAlwaysUpdateHelpTips') }, fully_synchronous: { - type: 'switch', + type: 'checkbox', label: this.$t('xpack.Cloud.FullySynchronous'), helpTips: this.$t('xpack.Cloud.FullySynchronousHelpTips') }, @@ -87,7 +87,7 @@ export default { } }, is_periodic: { - type: 'switch' + type: 'checkbox' }, crontab: { component: CronTab, @@ -125,7 +125,9 @@ export default { if (!Array.isArray(ipNetworkSegments)) { value.ip_network_segment_group = ipNetworkSegments ? ipNetworkSegments.split(',') : [] } - value.strategy = strategy.map(item => { return item.id }) + value.strategy = strategy.map(item => { + return item.id + }) return value }, onPerformError(error, method, vm) { @@ -155,8 +157,7 @@ export default { this.fieldsMeta.regions.el.ajax.url = form.account?.id ? `/api/v1/xpack/cloud/regions/?account_id=${form.account.id}` : `/api/v1/xpack/cloud/regions/` } }, - methods: { - } + methods: {} } diff --git a/src/views/assets/Platform/AutomationParamsSetting.vue b/src/views/assets/Platform/AutomationParamsSetting.vue index 1d0b723db..c893b38ed 100644 --- a/src/views/assets/Platform/AutomationParamsSetting.vue +++ b/src/views/assets/Platform/AutomationParamsSetting.vue @@ -153,6 +153,7 @@ export default { break case 'boolean': component = Switcher + // component = 'checkbox' break } diff --git a/src/views/assets/const.js b/src/views/assets/const.js index aa41b1776..4d0a65e30 100644 --- a/src/views/assets/const.js +++ b/src/views/assets/const.js @@ -161,7 +161,7 @@ export const assetFieldsMeta = (vm) => { } }, is_active: { - type: 'switch' + type: 'checkbox' }, cluster: { label: i18n.t('Cluster') diff --git a/src/views/ops/Job/JobUpdateCreate.vue b/src/views/ops/Job/JobUpdateCreate.vue index a99c94713..d70ee2d95 100644 --- a/src/views/ops/Job/JobUpdateCreate.vue +++ b/src/views/ops/Job/JobUpdateCreate.vue @@ -145,7 +145,7 @@ export default { } }, is_periodic: { - type: 'switch', + type: 'checkbox', hidden: () => { return this.instantTask } diff --git a/src/views/pam/AccountCheck/AccountCheckCreateUpdate.vue b/src/views/pam/AccountCheck/AccountCheckCreateUpdate.vue index 89717a576..c00ac753c 100644 --- a/src/views/pam/AccountCheck/AccountCheckCreateUpdate.vue +++ b/src/views/pam/AccountCheck/AccountCheckCreateUpdate.vue @@ -7,6 +7,7 @@ import { GenericCreateUpdatePage } from '@/layout/components' import { getChangeSecretFields } from '@/views/accounts/AccountChangeSecret/fields' import { AssetSelect } from '@/components' import { crontab, interval, is_periodic } from '@/views/accounts/const' +import i18n from '@/i18n/i18n' export default { name: 'AccountPushCreateUpdate', @@ -32,7 +33,7 @@ export default { fields: [ [this.$t('Basic'), ['name']], [this.$t('Asset'), ['assets', 'nodes']], - [this.$t('Engine'), ['engines']], + [this.$t('Check config'), ['engines', 'recipients']], [this.$t('Periodic'), ['is_periodic', 'interval', 'crontab']], [this.$t('Other'), ['is_active', 'comment']] ], @@ -70,6 +71,19 @@ export default { } } }, + recipients: { + label: i18n.t('Recipients'), + helpText: i18n.t('OnlyMailSend'), + el: { + value: [], + ajax: { + url: '/api/v1/users/users/?fields_size=mini', + transformOption: (item) => { + return { label: item.name + '(' + item.username + ')', value: item.id } + } + } + } + }, nodes: { el: { multiple: true, diff --git a/src/views/pam/AccountCheck/AccountCheckExecutionList.vue b/src/views/pam/AccountCheck/AccountCheckExecutionList.vue index 1357c914d..04e2bf9a8 100644 --- a/src/views/pam/AccountCheck/AccountCheckExecutionList.vue +++ b/src/views/pam/AccountCheck/AccountCheckExecutionList.vue @@ -22,14 +22,15 @@ export default { data() { return { tableConfig: { - url: '/api/v1/accounts/push-account-executions/?' + `${this.object.id ? 'automation_id=' + this.object.id : ''}`, + url: '/api/v1/accounts/check-account-executions/', columns: [ - 'automation', 'push_user_name', 'asset_amount', 'node_amount', 'status', - 'trigger', 'date_start', 'date_finished', 'actions' + 'task_name', 'asset_amount', + 'node_amount', 'status', 'trigger', + 'date_start', 'date_finished', 'actions' ], columnsShow: { default: [ - 'automation', 'push_user_name', 'status', + 'automation', 'task_name', 'status', 'date_start', 'date_finished', 'actions' ] }, @@ -40,7 +41,7 @@ export default { return {row.automation} } }, - push_user_name: { + task_name: { label: this.$t('DisplayName'), formatter: DetailFormatter, formatterArgs: { @@ -96,6 +97,15 @@ export default { callback: function({ row }) { return this.$router.push({ name: 'AccountCheckExecutionDetail', params: { id: row.id }}) } + }, + { + name: 'report', + title: this.$t('Report'), + type: 'success', + can: this.$hasPerm('accounts.view_pushaccountexecution'), + callback: function({ row }) { + window.open(`/api/v1/accounts/check-account-executions/${row.id}/report/`) + } } ] } diff --git a/src/views/pam/AccountCheck/index.vue b/src/views/pam/AccountCheck/index.vue index 7f21759a5..75c2414aa 100644 --- a/src/views/pam/AccountCheck/index.vue +++ b/src/views/pam/AccountCheck/index.vue @@ -31,7 +31,7 @@ export default { title: this.$t('执行历史'), name: 'AccountCheckExecution', hidden: !this.$hasPerm('accounts.view_accountcheckautomation'), - component: () => import('@/views/accounts/AccountPush/AccountPushExecutionList.vue') + component: () => import('./AccountCheckExecutionList.vue') }, { title: this.$t('检查引擎'), diff --git a/src/views/perms/AssetPermission/AssetPermissionDetail/AssetPermissionDetail.vue b/src/views/perms/AssetPermission/AssetPermissionDetail/AssetPermissionDetail.vue index 94f6c118a..39e654ad4 100644 --- a/src/views/perms/AssetPermission/AssetPermissionDetail/AssetPermissionDetail.vue +++ b/src/views/perms/AssetPermission/AssetPermissionDetail/AssetPermissionDetail.vue @@ -30,7 +30,7 @@ export default { quickActions: [ { title: this.$t('Active'), - type: 'switch', + type: 'checkbox', attrs: { model: this.object.is_active, disabled: !this.$hasPerm('perms.change_assetpermission') diff --git a/src/views/settings/Auth/Ldap/HaSyncSettingDialog.vue b/src/views/settings/Auth/Ldap/HaSyncSettingDialog.vue index f60734e84..ee7f0f63c 100644 --- a/src/views/settings/Auth/Ldap/HaSyncSettingDialog.vue +++ b/src/views/settings/Auth/Ldap/HaSyncSettingDialog.vue @@ -57,7 +57,7 @@ export default { } }, AUTH_LDAP_HA_SYNC_IS_PERIODIC: { - type: 'switch' + type: 'checkbox' }, AUTH_LDAP_HA_SYNC_CRONTAB: { component: CronTab, diff --git a/src/views/settings/Auth/Ldap/SyncSettingDialog.vue b/src/views/settings/Auth/Ldap/SyncSettingDialog.vue index dc542b38a..cf8823933 100644 --- a/src/views/settings/Auth/Ldap/SyncSettingDialog.vue +++ b/src/views/settings/Auth/Ldap/SyncSettingDialog.vue @@ -54,7 +54,7 @@ export default { } }, AUTH_LDAP_SYNC_IS_PERIODIC: { - type: 'switch' + type: 'checkbox' }, AUTH_LDAP_SYNC_CRONTAB: { component: CronTab,