From 4f3f8d3a0365b329d9baba2365e12aeed31a3231 Mon Sep 17 00:00:00 2001 From: Bai Date: Tue, 26 May 2020 11:54:40 +0800 Subject: [PATCH 1/4] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9=E6=94=B9?= =?UTF-8?q?=E5=AF=86=E8=AE=A1=E5=88=92=E6=9B=B4=E6=96=B0api=20url=E7=9A=84?= =?UTF-8?q?=E5=90=8E=E7=BC=80/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/xpack/ChangeAuthPlan/ChangeAuthPlanCreateUpdate.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/xpack/ChangeAuthPlan/ChangeAuthPlanCreateUpdate.vue b/src/views/xpack/ChangeAuthPlan/ChangeAuthPlanCreateUpdate.vue index 19fe55f59..080d3b642 100644 --- a/src/views/xpack/ChangeAuthPlan/ChangeAuthPlanCreateUpdate.vue +++ b/src/views/xpack/ChangeAuthPlan/ChangeAuthPlanCreateUpdate.vue @@ -13,7 +13,7 @@ export default { }, data() { return { - url: '/api/v1/xpack/change-auth-plan/plan/', + url: '/api/v1/xpack/change-auth-plan/plan', fields: [ [this.$t('xpack.Basic'), ['name']], [this.$t('xpack.Asset'), ['username', 'assets', 'nodes']], From 9573164a0360446df66a6f59460d722ee0093ba8 Mon Sep 17 00:00:00 2001 From: Bai Date: Wed, 27 May 2020 10:37:20 +0800 Subject: [PATCH 2/4] =?UTF-8?q?[Update]=20=E6=94=B9=E5=AF=86=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E5=88=9B=E5=BB=BA/=E6=9B=B4=E6=96=B0=EF=BC=8C?= =?UTF-8?q?=E8=AE=BE=E7=BD=AEpassword=5Frules=20type=E4=B8=BAgroup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChangeAuthPlanCreateUpdate.vue | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/src/views/xpack/ChangeAuthPlan/ChangeAuthPlanCreateUpdate.vue b/src/views/xpack/ChangeAuthPlan/ChangeAuthPlanCreateUpdate.vue index 080d3b642..66d02d080 100644 --- a/src/views/xpack/ChangeAuthPlan/ChangeAuthPlanCreateUpdate.vue +++ b/src/views/xpack/ChangeAuthPlan/ChangeAuthPlanCreateUpdate.vue @@ -13,18 +13,20 @@ export default { }, data() { return { - url: '/api/v1/xpack/change-auth-plan/plan', + url: '/api/v1/xpack/change-auth-plan/plan/', fields: [ [this.$t('xpack.Basic'), ['name']], [this.$t('xpack.Asset'), ['username', 'assets', 'nodes']], - [this.$t('xpack.ChangeAuthPlan.PasswordStrategy'), ['password_strategy', 'password', 'password_rules_length']], + [this.$t('xpack.ChangeAuthPlan.PasswordStrategy'), ['password_strategy', 'password', 'password_rules']], [this.$t('xpack.Timer'), ['is_periodic', 'crontab', 'interval']], [this.$t('xpack.Other'), ['comment']] ], initial: { password_strategy: 'custom', - password_rules_length: 20, is_periodic: true, + password_rules: { + length: 20 + }, interval: 24 }, fieldsMeta: { @@ -42,14 +44,14 @@ export default { password: { hidden: (formValue) => { return formValue.password_strategy !== 'custom' - } + }, + rules: [ + { required: this.$route.meta.action === 'create', message: this.$t('common.fieldRequiredError'), trigger: 'blur' } + ] }, - password_rules_length: { - type: 'input', - label: this.$t('xpack.ChangeAuthPlan.PasswordLength'), - hidden: (formValue) => { - return ['random_one', 'random_all'].indexOf(formValue.password_strategy) === -1 - } + password_rules: { + type: 'group', + items: this.generatePasswordRulesItemsFields() }, nodes: { label: this.$t('xpack.Node'), @@ -92,22 +94,23 @@ export default { }, helpText: '(单位: 时)' } - }, - cleanFormValue(values) { - if (['random_one', 'random_all'].indexOf(values.password_strategy) !== -1) { - const password_rules = {} - const password_rules_prefix = 'password_rules_' - for (const key of Object.keys(values)) { - if (key.startsWith(password_rules_prefix)) { - password_rules[key.slice(password_rules_prefix.length)] = values[key] - delete values[key] - } - } - values['password_rules'] = password_rules - } - return values } } + }, + methods: { + generatePasswordRulesItemsFields() { + const itemsFields = [] + const items = [ + { id: 'length', prop: 'length', label: this.$t('xpack.ChangeAuthPlan.PasswordLength') } + ] + items.forEach((item, index, array) => { + itemsFields.push({ + id: item.id, prop: item.prop, el: {}, attrs: {}, type: 'input', label: item.label, required: true, + hidden: (formValue) => { return ['random_one', 'random_all'].indexOf(formValue.password_strategy) === -1 } + }) + }) + return itemsFields + } } } From 81fbec6a01aa97c32da97c3e9b5069d684b4c6ae Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 27 May 2020 15:13:35 +0800 Subject: [PATCH 3/4] update img src --- src/components/UploadField/index.vue | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/UploadField/index.vue b/src/components/UploadField/index.vue index d18184e77..51e6db66f 100644 --- a/src/components/UploadField/index.vue +++ b/src/components/UploadField/index.vue @@ -22,6 +22,9 @@ export default { }, computed: { src() { + if (process.env.VUE_APP_BASE_API === '/') { + return this.value + } return `${process.env.VUE_APP_BASE_API}${this.value}` } }, From d7447b43cb8ad4238ba94e2ba0a1ca0111071041 Mon Sep 17 00:00:00 2001 From: Bai Date: Wed, 27 May 2020 16:59:52 +0800 Subject: [PATCH 4/4] =?UTF-8?q?[Update]=20=E6=B7=BB=E5=8A=A0UserProfile?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=EF=BC=9BNav=20=E6=B7=BB=E5=8A=A0=20userProfi?= =?UTF-8?q?le=20=E8=B7=B3=E8=BD=AC=EF=BC=9Broutes=20=E6=B7=BB=E5=8A=A0comm?= =?UTF-8?q?onRoutes=EF=BC=88userProfile)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/i18n/langs/cn.json | 1 + .../components/NavHeader/AccountDropdown.vue | 3 ++ src/router/index.js | 37 ++++++++++----- .../users/{Detail.vue => UserProfile.vue} | 12 ++++- src/userviews/users/index.vue | 47 +++++++++---------- 5 files changed, 63 insertions(+), 37 deletions(-) rename src/userviews/users/{Detail.vue => UserProfile.vue} (92%) diff --git a/src/i18n/langs/cn.json b/src/i18n/langs/cn.json index 0227bdb36..3a0397279 100644 --- a/src/i18n/langs/cn.json +++ b/src/i18n/langs/cn.json @@ -69,6 +69,7 @@ "Role": "角色", "SerialNumber": "序列号", "SetMFA": "设置多因子认证", + "UpdateMFA": "更改多因子认证", "Source": "来源", "SystemUserDetail": "系统用户详情", "SystemUsers": "系统用户", diff --git a/src/layout/components/NavHeader/AccountDropdown.vue b/src/layout/components/NavHeader/AccountDropdown.vue index 7e7754e88..d8ceeeb7d 100644 --- a/src/layout/components/NavHeader/AccountDropdown.vue +++ b/src/layout/components/NavHeader/AccountDropdown.vue @@ -53,6 +53,9 @@ export default { methods: { handleClick(val) { switch (val) { + case 'profile': + this.$router.push({ name: 'userProfile' }) + break case 'AdminPage': setPermission('Admin') window.location.href = `/` diff --git a/src/router/index.js b/src/router/index.js index 2f8e5e248..40356ef63 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -54,7 +54,31 @@ export const constantRoutes = [ } ] +/** + * admin and user routes + * the routes that need to be dynamically loaded based on admin or user roles + */ +export const commonRoutes = { + userProfile: { + path: '/users/profile', + component: Layout, + children: [ + { + path: '', + name: 'userProfile', + component: () => import('@/userviews/users/index'), + meta: { title: i18n.t('route.UserProfile'), icon: 'user', activeMenu: '/users/profile' } + } + ] + } +} + +/** + * admin + * the routes that need to be dynamically loaded based on admin roles + */ export const adminRoutes = [ + Object.assign({}, commonRoutes.userProfile, { hidden: true }), { path: '/', component: Layout, @@ -187,18 +211,7 @@ export const userRoutes = [ } ] }, - { - path: '/users', - component: Layout, - children: [ - { - path: '/users/profile', - name: 'profile', - component: () => import('@/userviews/users/index'), - meta: { title: i18n.t('route.UserProfile'), icon: 'user' } - } - ] - }, + commonRoutes.userProfile, { path: '/command-executions', component: Layout, diff --git a/src/userviews/users/Detail.vue b/src/userviews/users/UserProfile.vue similarity index 92% rename from src/userviews/users/Detail.vue rename to src/userviews/users/UserProfile.vue index 62d49f1dd..83b557e63 100644 --- a/src/userviews/users/Detail.vue +++ b/src/userviews/users/UserProfile.vue @@ -14,7 +14,7 @@ import DetailCard from '@/components/DetailCard' import QuickActions from '@/components/QuickActions' import { toSafeLocalDateStr } from '@/utils/common' export default { - name: 'Detail', + name: 'UserProfile', components: { DetailCard, QuickActions @@ -38,6 +38,16 @@ export default { click: function() {} } }, + { + title: this.$t('assets.UpdateMFA'), + attrs: { + type: 'primary', + label: this.$t('common.Reset') + }, + callbacks: { + click: function() {} + } + }, { title: this.$t('assets.UpdatePassword'), attrs: { diff --git a/src/userviews/users/index.vue b/src/userviews/users/index.vue index 0fef748c9..0c71c3b2d 100644 --- a/src/userviews/users/index.vue +++ b/src/userviews/users/index.vue @@ -1,37 +1,36 @@