From bf413e40149a438718463c918f6b99873f88d6dd Mon Sep 17 00:00:00 2001 From: shibanglin Date: Tue, 7 Mar 2023 11:32:25 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=BA=94=E7=94=A8=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=88=86=E7=B1=BB=202=E3=80=81=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E4=BF=AE=E6=94=B9=E6=96=B0=E5=A2=9E=E5=BC=BA=E5=BA=A6?= =?UTF-8?q?=E8=AF=B4=E6=98=8E=203=E3=80=81=E5=BF=98=E8=AE=B0=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E9=A1=B5=E6=96=B0=E5=A2=9E=E5=BC=BA=E5=BA=A6=E8=AF=B4?= =?UTF-8?q?=E6=98=8E=204=E3=80=81=E7=99=BB=E5=BD=95=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E6=97=A0=E6=8F=90=E7=A4=BA=E7=9A=84=E5=8A=9F=E8=83=BD=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/password/password.component.html | 52 ++-- .../config/password/password.component.ts | 178 +++++++++++-- .../routes/dashboard/home/home.component.html | 116 ++++---- .../routes/dashboard/home/home.component.less | 11 + .../routes/dashboard/home/home.component.ts | 136 +++++++++- .../passport/forgot/forgot.component.html | 25 +- .../passport/forgot/forgot.component.ts | 247 +++++++++++++++--- .../routes/passport/login/login.component.ts | 4 +- .../app/service/forgot-password.service.ts | 8 + .../src/app/service/password.service.ts | 3 + .../maxkey-web-app/src/assets/i18n/en-US.json | 12 +- .../maxkey-web-app/src/assets/i18n/zh-CN.json | 10 +- .../maxkey-web-app/src/assets/i18n/zh-TW.json | 10 +- 13 files changed, 671 insertions(+), 141 deletions(-) diff --git a/maxkey-web-frontend/maxkey-web-app/src/app/routes/config/password/password.component.html b/maxkey-web-frontend/maxkey-web-app/src/app/routes/config/password/password.component.html index ca261c95..fe89f6ea 100644 --- a/maxkey-web-frontend/maxkey-web-app/src/app/routes/config/password/password.component.html +++ b/maxkey-web-frontend/maxkey-web-app/src/app/routes/config/password/password.component.html @@ -1,14 +1,15 @@ -
+
-
-
+
id + + {{ 'mxk.password.displayName' | i18n }} @@ -38,14 +39,14 @@ {{ 'mxk.password.oldPassword' | i18n }} - + @@ -57,36 +58,43 @@ {{ 'mxk.password.password' | i18n }} - + + {{ 'mxk.password.confirmPassword' | i18n - }} - + }} + + @@ -95,7 +103,15 @@
+ +
+

{{'validation.password.conformance-strength'| i18n}}

+
    +
  • {{item}}
  • +
+
-
+ + diff --git a/maxkey-web-frontend/maxkey-web-app/src/app/routes/config/password/password.component.ts b/maxkey-web-frontend/maxkey-web-app/src/app/routes/config/password/password.component.ts index dccd538b..4df1afce 100644 --- a/maxkey-web-frontend/maxkey-web-app/src/app/routes/config/password/password.component.ts +++ b/maxkey-web-frontend/maxkey-web-app/src/app/routes/config/password/password.component.ts @@ -19,10 +19,11 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { I18NService } from '@core'; import { SettingsService, User, ALAIN_I18N_TOKEN } from '@delon/theme'; import { NzMessageService } from 'ng-zorro-antd/message'; - +import { Router, ActivatedRoute } from '@angular/router'; import { ChangePassword } from '../../../entity/ChangePassword'; import { PasswordService } from '../../../service/password.service'; + @Component({ selector: 'app-password', templateUrl: './password.component.html', @@ -36,27 +37,28 @@ export class PasswordComponent implements OnInit { submitting: false, model: new ChangePassword() }; - - formGroup: FormGroup = new FormGroup({}); - + validateForm!: FormGroup; oldPasswordVisible = false; - + policy:any = {}; passwordVisible = false; - + policyMessage:any[] =[]; + dynamicallyCheckPasswordErrorMsg = ""; constructor( + private router: Router, private fb: FormBuilder, private settingsService: SettingsService, private passwordService: PasswordService, private msg: NzMessageService, @Inject(ALAIN_I18N_TOKEN) private i18n: I18NService, private cdr: ChangeDetectorRef - ) {} + ) { } ngOnInit(): void { - this.formGroup = this.fb.group({ + this.loadPolicy(); + this.validateForm = this.fb.group({ oldPassword: [null, [Validators.required]], confirmPassword: [null, [Validators.required]], - password: [1, [Validators.min(6), Validators.max(20)]] + password: [null, [Validators.required]], }); let user: any = this.settingsService.user; @@ -64,27 +66,151 @@ export class PasswordComponent implements OnInit { this.form.model.displayName = user.displayName; this.form.model.username = user.username; this.form.model.id = user.userId; - this.cdr.detectChanges(); } + + loadPolicy():void { + this.policyMessage=[]; + this.passwordService.passwordpolicy().subscribe(res => { + if(res.code == 0) { + let data = res.data; + this.policy = data; + this.policyMessage=res.data.policMessageList; + } + }); + } + + dynamicallyCheckConfirm(value:any):void { + if (value != this.form.model.password) { + this.dynamicallyCheckPasswordErrorMsg = this.i18n.fanyi('validation.password.twice') + } else { + this.dynamicallyCheckPasswordErrorMsg = ''; + } + } + + dynamicallyCheckPassword(value:any):void { + if (value == '') { + this.dynamicallyCheckPasswordErrorMsg = ''; + return; + } + let data = this.policy; + if (data.minLength != 0 && data.maxLength != 0) { + let inputLength = value.length; + if (inputLength < data.minLength || inputLength > data.maxLength) { + //this.dynamicallyCheckPasswordErrorMsg = "限定新密码长度为"+data.minLength+"-"+data.maxLength+"位" + this.dynamicallyCheckPasswordErrorMsg = this.i18n.fanyi('validation.password.non-conformance-strength') + return; + } + } + + if (data.lowerCase > 0) { + let strArr = Array.from(value) + let abc:any = []; + strArr.forEach(function (value:any, index, array) { + let code = value.charCodeAt() + if (code >= 'a'.charCodeAt(0) && code <= 'z'.charCodeAt(0)) { + abc.push(value) + } + }) + if(abc.length < data.lowerCase) { + //this.dynamicallyCheckPasswordErrorMsg = "限定新密码至少需要包含"+data.lowerCase+"位【a-z】小写字母" + this.dynamicallyCheckPasswordErrorMsg = this.i18n.fanyi('validation.password.non-conformance-strength') + return; + } + } + + + if(data.upperCase > 0) { + let strArr = Array.from(value) + let ABC:any = []; + strArr.forEach(function (value:any, index, array) { + let code = value.charCodeAt() + if (code >= 'A'.charCodeAt(0) && code <= 'Z'.charCodeAt(0)) { + ABC.push(value) + } + }) + if(ABC.length < data.upperCase) { + this.dynamicallyCheckPasswordErrorMsg = this.i18n.fanyi('validation.password.non-conformance-strength') + //this.dynamicallyCheckPasswordErrorMsg = "限定新密码至少需要包含"+data.lowerCase+"位【A-Z】大写字母" + return; + } + } + + if (data.digits > 0) { + let strArr = Array.from(value) + let number:any = []; + strArr.forEach(function (value:any, index, array) { + var regPos = /^[0-9]+.?[0-9]*/; //判断是否是数字。 + if(regPos.test(value) ){ + number.push(value) + } + }) + if(number.length < data.digits) { + //this.dynamicallyCheckPasswordErrorMsg = "限定新密码至少需要包含"+data.digits+"位【0-9】阿拉伯数字"; + this.dynamicallyCheckPasswordErrorMsg = this.i18n.fanyi('validation.password.non-conformance-strength') + return; + } + } + + + if(data.specialChar > 0) { + var AllNumIsSame = new Array("’","”","!","@","#","$","%","^","&","*","."); + let strArr = Array.from(value) + let number:any = []; + strArr.forEach(function (value:any, index, array) { + if(AllNumIsSame.indexOf(value) != -1){//$.type 是jquery的函数,用来判断对象类型 + number.push(value) + } + }) + if(number.length < data.specialChar) { + //this.dynamicallyCheckPasswordErrorMsg = "限定新密码至少需要包含"+data.specialChar+"位特殊字符"; + this.dynamicallyCheckPasswordErrorMsg = this.i18n.fanyi('validation.password.non-conformance-strength') + return; + } + } + this.dynamicallyCheckPasswordErrorMsg = ''; + + } + onSubmit(): void { - this.form.submitting = true; - this.form.model.trans(); - //if (this.formGroup.valid) { - this.passwordService.changePassword(this.form.model).subscribe(res => { - if (res.code == 0) { - this.form.model.init(res.data); - this.msg.success(this.i18n.fanyi('mxk.alert.operate.success')); - } else { - this.msg.error(this.i18n.fanyi('mxk.alert.operate.error')); + if (this.validateForm.valid) { + if (this.dynamicallyCheckPasswordErrorMsg == '') { + this.form.submitting = true; + this.form.model.trans(); + this.passwordService.changePassword(this.form.model).subscribe(res => { + if (res.code == 0) { + this.form.model.init(res.data); + this.msg.success(this.i18n.fanyi('mxk.alert.operate.success')); + this.form.model.password = ''; + this.form.model.oldPassword = ''; + this.form.model.confirmPassword = ''; + //设置密码正常,路由不进行拦截 + let user = this.settingsService.user; + user['passwordSetType'] = 0; + this.settingsService.setUser(user) + this.router.navigateByUrl('/'); + } else { + if (res.message) { + this.msg.error(res.message); + return + } + this.msg.error(this.i18n.fanyi('mxk.alert.operate.error')); + } + }); + this.form.submitting = false; + this.cdr.detectChanges(); } - }); - // } else { - // this.formGroup.updateValueAndValidity({ onlySelf: true }); - // this.msg.success(`提交失败`); - //} - this.form.submitting = false; - this.cdr.detectChanges(); + } else { + Object.values(this.validateForm.controls).forEach(control => { + if (control.invalid) { + control.markAsDirty(); + control.updateValueAndValidity({ onlySelf: true }); + } + }); + } } + + + } diff --git a/maxkey-web-frontend/maxkey-web-app/src/app/routes/dashboard/home/home.component.html b/maxkey-web-frontend/maxkey-web-app/src/app/routes/dashboard/home/home.component.html index db7ee118..eeb08957 100644 --- a/maxkey-web-frontend/maxkey-web-app/src/app/routes/dashboard/home/home.component.html +++ b/maxkey-web-frontend/maxkey-web-app/src/app/routes/dashboard/home/home.component.html @@ -1,55 +1,75 @@
- - - - - - - - - - - -
-
-

- -

-

{{ item.appName }}

-
-
-
-
+ + +
+
+ +
+
{{ 'mxk.menu.applist' | i18n }}
+
-
+ + + + + + + + + + + + + + + + + + +
+
+

+ +

+

{{ item.appName }}

+
+
+
+
+
+
+
diff --git a/maxkey-web-frontend/maxkey-web-app/src/app/routes/dashboard/home/home.component.less b/maxkey-web-frontend/maxkey-web-app/src/app/routes/dashboard/home/home.component.less index e69de29b..85018d7a 100644 --- a/maxkey-web-frontend/maxkey-web-app/src/app/routes/dashboard/home/home.component.less +++ b/maxkey-web-frontend/maxkey-web-app/src/app/routes/dashboard/home/home.component.less @@ -0,0 +1,11 @@ +.el_content { + display: flex; +} +.el-img img{ + width: 22px; +} + +.el-title{ + font-size: 18px; + margin-left: 5px; +} diff --git a/maxkey-web-frontend/maxkey-web-app/src/app/routes/dashboard/home/home.component.ts b/maxkey-web-frontend/maxkey-web-app/src/app/routes/dashboard/home/home.component.ts index 2b318373..c2744f48 100644 --- a/maxkey-web-frontend/maxkey-web-app/src/app/routes/dashboard/home/home.component.ts +++ b/maxkey-web-frontend/maxkey-web-app/src/app/routes/dashboard/home/home.component.ts @@ -31,6 +31,8 @@ import { AuthnService } from '../../../service/authn.service'; import { AccoutsComponent } from '../../config/accouts/accouts.component'; import { Console } from 'console'; +import {ALAIN_I18N_TOKEN} from "@delon/theme"; +import {I18NService} from "@core"; @Component({ selector: 'app-home', @@ -51,7 +53,9 @@ export class HomeComponent implements OnInit { loading: boolean = false; appList: any[] = []; baseUrl: String = ''; - + staticAppList: any[] = []; + appCategoryList: any[] = []; + appsCategory: String = ''; constructor( private modal: NzModalService, private viewContainerRef: ViewContainerRef, @@ -59,6 +63,7 @@ export class HomeComponent implements OnInit { private cdr: ChangeDetectorRef, private obSrv: OnboardingService, private platform: Platform, + @Inject(ALAIN_I18N_TOKEN) private i18n: I18NService, @Inject(DOCUMENT) private doc: NzSafeAny ) { // TODO: Wait for the page to load @@ -106,7 +111,136 @@ export class HomeComponent implements OnInit { this.appListService.appList().subscribe(res => { //console.log(res.data); this.appList = res.data; + this.staticAppList = this.appList; this.cdr.detectChanges(); }); + this.appCategoryList = [{ + id:'none', + name:this.i18n.fanyi('mxk.apps.category.none') + },{ + id:'1011', + name:this.i18n.fanyi('mxk.apps.category.1011') + }, + { + id:'1012', + name:this.i18n.fanyi('mxk.apps.category.1012') + }, + { + id:'1013', + name:this.i18n.fanyi('mxk.apps.category.1013') + }, + { + id:'1014', + name:this.i18n.fanyi('mxk.apps.category.1014') + }, + { + id:'1015', + name:this.i18n.fanyi('mxk.apps.category.1015') + }, + { + id:'1016', + name:this.i18n.fanyi('mxk.apps.category.1016') + }, + { + id:'1017', + name:this.i18n.fanyi('mxk.apps.category.1017') + }, + { + id:'1111', + name:this.i18n.fanyi('mxk.apps.category.1111') + }, + { + id:'1112', + name:this.i18n.fanyi('mxk.apps.category.1112') + }, + { + id:'1113', + name:this.i18n.fanyi('mxk.apps.category.1113') + }, + { + id:'1114', + name:this.i18n.fanyi('mxk.apps.category.1114') + }, + { + id:'1211', + name:this.i18n.fanyi('mxk.apps.category.1211') + }, + { + id:'1212', + name:this.i18n.fanyi('mxk.apps.category.1212') + }, + { + id:'1213', + name:this.i18n.fanyi('mxk.apps.category.1213') + }, + { + id:'1214', + name:this.i18n.fanyi('mxk.apps.category.1214') + }, + { + id:'1215', + name:this.i18n.fanyi('mxk.apps.category.1215') + }, + { + id:'1215', + name:this.i18n.fanyi('mxk.apps.category.1215') + }, + { + id:'1311', + name:this.i18n.fanyi('mxk.apps.category.1311') + }, + { + id:'1411', + name:this.i18n.fanyi('mxk.apps.category.1411') + }, + { + id:'1511', + name:this.i18n.fanyi('mxk.apps.category.1511') + }, + { + id:'1512', + name:this.i18n.fanyi('mxk.apps.category.1512') + }, + { + id:'1611', + name:this.i18n.fanyi('mxk.apps.category.1611') + }, + { + id:'1711', + name:this.i18n.fanyi('mxk.apps.category.1711') + }, + { + id:'1712', + name:this.i18n.fanyi('mxk.apps.category.1712') + }, + { + id:'1811', + name:this.i18n.fanyi('mxk.apps.category.1811') + }, + { + id:'1812', + name:this.i18n.fanyi('mxk.apps.category.1812') + },{ + id:'1911', + name:this.i18n.fanyi('mxk.apps.category.1911') + }, + { + id:'1912', + name:this.i18n.fanyi('mxk.apps.category.1912') + } + ] + } + changeCategory (): void { + this.appList = []; + if (this.appsCategory === null || this.appsCategory === '') { + this.appList = this.staticAppList; + } else { + for(let i = 0;i