From 1282b465f194a01f5fcc197603948d4c42d0ff29 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 15 Mar 2022 20:00:13 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E6=A0=91=EF=BC=8C=E7=BB=9F=E4=B8=80=20dropdown?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/AutoDataTable/index.vue | 12 +- .../applications/RemoteApp/RemoteAppList.vue | 7 +- src/views/applications/const.js | 161 +++++++++++++++++ .../SystemUserList/CommonUserList.vue | 79 +-------- src/views/assets/const.js | 30 ++++ .../ApplicationPermissionList.vue | 9 +- src/views/perms/const.js | 163 ------------------ src/views/users/User/UserList.vue | 6 +- 8 files changed, 223 insertions(+), 244 deletions(-) create mode 100644 src/views/applications/const.js create mode 100644 src/views/assets/const.js diff --git a/src/components/AutoDataTable/index.vue b/src/components/AutoDataTable/index.vue index 17358990e..85c6a05f4 100644 --- a/src/components/AutoDataTable/index.vue +++ b/src/components/AutoDataTable/index.vue @@ -64,7 +64,6 @@ export default { } }, computed: { - }, watch: { config: { @@ -211,7 +210,7 @@ export default { }, generateTotalColumns() { const config = _.cloneDeep(this.config) - const columns = [] + let columns = [] for (let col of config.columns) { if (typeof col === 'object') { columns.push(col) @@ -220,6 +219,15 @@ export default { columns.push(col) } } + columns = columns.filter(item => { + let has = item.has + if (has === undefined) { + has = true + } else if (typeof has === 'function') { + has = has() + } + return has + }) // 第一次初始化时记录 totalColumns this.totalColumns = columns config.columns = columns diff --git a/src/views/applications/RemoteApp/RemoteAppList.vue b/src/views/applications/RemoteApp/RemoteAppList.vue index 9d3733c25..4d2466a96 100644 --- a/src/views/applications/RemoteApp/RemoteAppList.vue +++ b/src/views/applications/RemoteApp/RemoteAppList.vue @@ -33,7 +33,12 @@ export default { showOverflowTooltip: true, formatter: function(row, column, cellValue, index) { const route = { to: { name: 'AssetDetail', params: { id: cellValue }}} - return { row.attrs.asset_info.hostname } + const hostname = row.attrs['asset_info'].hostname + if (vm.$hasPerm('assets.view_asset')) { + return { hostname } + } else { + return hostname + } } }, actions: { diff --git a/src/views/applications/const.js b/src/views/applications/const.js new file mode 100644 index 000000000..a1ad65145 --- /dev/null +++ b/src/views/applications/const.js @@ -0,0 +1,161 @@ +import i18n from '@/i18n/i18n' +import store from '@/store' +export const CHROME = 'chrome' +export const MYSQL_WORKBENCH = 'mysql_workbench' +export const VMWARE_CLIENT = 'vmware_client' +export const CUSTOM = 'custom' +export const REMOTEAPP_CATEGORY = 'remote_app' + +function hasLicence() { + return store.getters.hasValidLicense +} + +export const REMOTE_APP = [ + { + name: CHROME, + title: i18n.t(`applications.applicationsType.${CHROME}`), + type: 'primary', + group: i18n.t('applications.RemoteApp'), + category: REMOTEAPP_CATEGORY, + has: hasLicence + }, + { + name: MYSQL_WORKBENCH, + title: i18n.t(`applications.applicationsType.${MYSQL_WORKBENCH}`), + type: 'primary', + category: REMOTEAPP_CATEGORY, + has: hasLicence + }, + { + name: VMWARE_CLIENT, + title: i18n.t(`applications.applicationsType.${VMWARE_CLIENT}`), + type: 'primary', + category: REMOTEAPP_CATEGORY, + has: hasLicence + }, + { + name: CUSTOM, + title: i18n.t(`applications.applicationsType.${CUSTOM}`), + type: 'primary', + category: REMOTEAPP_CATEGORY, + has: hasLicence + } +] + +export const MYSQL = 'mysql' +export const ORACLE = 'oracle' +export const POSTGRESQL = 'postgresql' +export const MARIADB = 'mariadb' +export const DATABASE_CATEGORY = 'db' +export const SQLSERVER = 'sqlserver' +export const REDIS = 'redis' +export const MONGODB = 'mongodb' + +export const DATABASE = [ + { + name: MYSQL, + title: i18n.t(`applications.applicationsType.${MYSQL}`), + type: 'primary', + category: DATABASE_CATEGORY, + has: true, + group: i18n.t('applications.RDBProtocol') + }, + { + name: MARIADB, + title: i18n.t(`applications.applicationsType.${MARIADB}`), + type: 'primary', + category: DATABASE_CATEGORY, + has: true + }, + { + name: ORACLE, + title: i18n.t(`applications.applicationsType.${ORACLE}`), + type: 'primary', + category: DATABASE_CATEGORY, + has: hasLicence + }, + { + name: POSTGRESQL, + title: i18n.t(`applications.applicationsType.${POSTGRESQL}`), + type: 'primary', + category: DATABASE_CATEGORY, + has: hasLicence + }, + { + name: SQLSERVER, + title: i18n.t(`applications.applicationsType.${SQLSERVER}`), + type: 'primary', + category: DATABASE_CATEGORY, + has: hasLicence + }, + { + name: REDIS, + title: i18n.t(`applications.applicationsType.${REDIS}`), + type: 'primary', + category: DATABASE_CATEGORY, + has: true, + group: i18n.t('applications.NoSQLProtocol') + }, + { + name: MONGODB, + title: i18n.t(`applications.applicationsType.${MONGODB}`), + type: 'primary', + category: DATABASE_CATEGORY + } +] + +export const AppPlanDatabase = [ + { + name: MYSQL, + title: i18n.t(`applications.applicationsType.${MYSQL}`), + type: 'primary', + category: DATABASE_CATEGORY, + has: true, + group: i18n.t('applications.RDBProtocol') + }, + { + name: ORACLE, + title: i18n.t(`applications.applicationsType.${ORACLE}`), + type: 'primary', + category: DATABASE_CATEGORY, + has: hasLicence + }, + { + name: POSTGRESQL, + title: i18n.t(`applications.applicationsType.${POSTGRESQL}`), + type: 'primary', + category: DATABASE_CATEGORY, + has: hasLicence + }, + { + name: MARIADB, + title: i18n.t(`applications.applicationsType.${MARIADB}`), + type: 'primary', + category: DATABASE_CATEGORY + }, + { + name: SQLSERVER, + title: i18n.t(`applications.applicationsType.${SQLSERVER}`), + type: 'primary', + category: DATABASE_CATEGORY, + has: hasLicence + } +] + +export const KUBERNETES = 'k8s' +export const CLOUD_CATEGORY = 'cloud' + +export const CLOUD = [ + { + name: KUBERNETES, + title: i18n.t(`applications.applicationsType.${KUBERNETES}`), + group: i18n.t('applications.Cloud'), + type: 'primary', + category: CLOUD_CATEGORY, + has: true + } +] + +export const ApplicationTypes = [ + ...REMOTE_APP, ...DATABASE, ...CLOUD +] diff --git a/src/views/assets/SystemUser/SystemUserList/CommonUserList.vue b/src/views/assets/SystemUser/SystemUserList/CommonUserList.vue index ddc8cd1dd..4461835d1 100644 --- a/src/views/assets/SystemUser/SystemUserList/CommonUserList.vue +++ b/src/views/assets/SystemUser/SystemUserList/CommonUserList.vue @@ -9,6 +9,8 @@