aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/_pages/profile/profile.component.ts
diff options
context:
space:
mode:
authorDanijel Anđelković <adanijel99@gmail.com>2022-05-20 04:02:03 +0200
committerDanijel Anđelković <adanijel99@gmail.com>2022-05-20 04:02:03 +0200
commit0d476fb3a73921bbea0994509bc95a19cebae70c (patch)
treea1f2071655b4bd2d78f46c7bb0424a08985664b8 /frontend/src/app/_pages/profile/profile.component.ts
parent60d486a636230074350ac19900125098fd07f3f7 (diff)
parent9930bdb624f9511e9f4ead7abd435d25fbdcac4a (diff)
Merge branch 'redesign' of http://gitlab.pmf.kg.ac.rs/igrannonica/neuronstellar
Diffstat (limited to 'frontend/src/app/_pages/profile/profile.component.ts')
-rw-r--r--frontend/src/app/_pages/profile/profile.component.ts46
1 files changed, 27 insertions, 19 deletions
diff --git a/frontend/src/app/_pages/profile/profile.component.ts b/frontend/src/app/_pages/profile/profile.component.ts
index fdcd347c..aed8e40c 100644
--- a/frontend/src/app/_pages/profile/profile.component.ts
+++ b/frontend/src/app/_pages/profile/profile.component.ts
@@ -7,7 +7,8 @@ import { PICTURES } from 'src/app/_data/ProfilePictures';
import { Picture } from 'src/app/_data/ProfilePictures';
import shared from '../../Shared';
import { share } from 'rxjs';
-
+import { MatDialog } from '@angular/material/dialog';
+import { AlertDialogComponent } from 'src/app/_modals/alert-dialog/alert-dialog.component';
@Component({
selector: 'app-profile',
@@ -43,13 +44,13 @@ export class ProfileComponent implements OnInit {
wrongNewPass2Bool: boolean = false;
pattName: RegExp = /^[a-zA-ZšŠđĐčČćĆžŽ]+([ \-][a-zA-ZšŠđĐčČćĆžŽ]+)*$/;
- pattUsername: RegExp = /^[a-zA-Z0-9]{6,18}$/;
+ pattUsername: RegExp = /^[a-zA-Z0-9]{4,18}$/;
pattTwoSpaces: RegExp = / /;
pattEmail: RegExp = /^[a-zA-Z0-9]+([\.\-\+][a-zA-Z0-9]+)*\@([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}$/;
pattPassword: RegExp = /.{6,30}$/;
- constructor(private userInfoService: UserInfoService, private authService: AuthService, private router: Router) { }
+ constructor(private userInfoService: UserInfoService, private authService: AuthService, private router: Router, public dialog?: MatDialog) { }
ngOnInit(): void {
this.userInfoService.getUserInfo().subscribe((response) => {
@@ -95,19 +96,24 @@ export class ProfileComponent implements OnInit {
if (this.user.username != editedUser.username) { //promenio username, ide logout
this.user = editedUser;
this.resetInfo();
- shared.openDialog("Obaveštenje", "Nakon promene korisničkog imena, moraćete ponovo da se ulogujete.");
- this.authService.logOut();
- this.router.navigate(['']);
- return;
+ const dialogRef = this.dialog?.open(AlertDialogComponent, {
+ width: '350px',
+ data: { title: "Obaveštenje", message: "Nakon promene korisničkog imena, moraćete ponovo da se ulogujete." }
+ });
+ dialogRef?.afterClosed().subscribe(res => {
+ this.authService.logOut();
+ this.router.navigate(['']);
+ return;
+ });
+ }
+ else {
+ shared.openDialog("Obaveštenje", "Podaci su uspešno promenjeni.");
+ this.user = editedUser;
+ this.resetInfo();
}
- shared.openDialog("Obaveštenje", "Podaci su uspešno promenjeni.");
- this.user = editedUser;
- this.resetInfo();
}, (error: any) =>{
if (error.error == "Username already exists!") {
shared.openDialog("Obaveštenje", "Ukucano korisničko ime je već zauzeto! Izaberite neko drugo.");
- //(<HTMLSelectElement>document.getElementById("inputUsername")).focus();
- //poruka obavestenja ispod inputa
this.resetInfo();
}
});
@@ -122,12 +128,10 @@ export class ProfileComponent implements OnInit {
if (this.newPass1 == '' && this.newPass2 == '') //ne zeli da promeni lozinku
return;
- //console.log("zeli da promeni lozinku");
if (this.newPass1 != this.newPass2) { //netacno ponovio novu lozinku
this.wrongNewPassBool = true;
this.resetNewPassInputs();
- //console.log("Netacno ponovljena lozinka");
return;
}
@@ -135,19 +139,23 @@ export class ProfileComponent implements OnInit {
this.userInfoService.changeUserPassword(passwordArray).subscribe((response: any) => {
//console.log("PROMENIO LOZINKU");
this.resetNewPassInputs();
- shared.openDialog("Obaveštenje", "Nakon promene lozinke, moraćete ponovo da se ulogujete.");
- this.authService.logOut();
- this.router.navigate(['']);
+ const dialogRef = this.dialog?.open(AlertDialogComponent, {
+ width: '350px',
+ data: { title: "Obaveštenje", message: "Nakon promene lozinke, moraćete ponovo da se ulogujete." }
+ });
+ dialogRef?.afterClosed().subscribe(res => {
+ this.authService.logOut();
+ this.router.navigate(['']);
+ return;
+ });
}, (error: any) => {
if (error.error == 'Wrong old password!') {
this.wrongPassBool = true;
- //(<HTMLSelectElement>document.getElementById("inputPassword")).focus();
return;
}
else if (error.error == 'Identical password!') {
shared.openDialog("Obaveštenje", "Stara i nova lozinka su identične.");
this.resetNewPassInputs();
- //(<HTMLSelectElement>document.getElementById("inputNewPassword")).focus();
return;
}
});