Skip to content

Commit f52e2e2

Browse files
committed
Loading spinner for invite component
1 parent acd0806 commit f52e2e2

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

frontend/src/app/invite/invite.component.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,15 @@ mat-hint {
5959
}
6060

6161
button {
62+
color: #494949;
6263
margin-top: 2%;
6364
padding-right: 10%;
6465
padding-left: 10%;
6566
display: inline-block;
6667
font-family: 'Ubuntu', sans-serif;
6768
font-size: 120%;
69+
}
70+
71+
#loadingSpinner {
72+
margin: auto auto;
6873
}

frontend/src/app/invite/invite.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
</mat-form-field>
2323
<div></div>
2424
</div>
25-
<button mat-flat-button color="accent" (click)="enterRoom()" [disabled]="!userSrv.isLogged && (!userName || !password)">Access room</button>
25+
<button mat-flat-button *ngIf="!loading" color="accent" (click)="enterRoom()" [disabled]="!userSrv.isLogged && (!userName || !password)" id="accessButton">Access room</button>
26+
<mat-spinner color="accent" *ngIf="loading" id="loadingSpinner"></mat-spinner>
2627
</div>
2728
</div>
2829
</div>

frontend/src/app/invite/invite.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export class InviteComponent implements OnInit {
1616
password: string;
1717
nameTaken: boolean = false;
1818
userErrorMsg: string;
19+
loading: boolean = false;
1920

2021
constructor(
2122
private roomSrv: RoomService,
@@ -33,6 +34,7 @@ export class InviteComponent implements OnInit {
3334

3435
enterRoom() {
3536
if(this.userSrv.isLogged) { //User is logged
37+
this.loading = true;
3638
this.userName = this.userSrv.user.name;
3739
if(this.userSrv.isModOfRoom(this.roomName)) { //Direct access if already a mod
3840
this.router.navigate(['/',this.roomName]);
@@ -43,6 +45,7 @@ export class InviteComponent implements OnInit {
4345
this.router.navigate(['/', this.roomName]);
4446
},
4547
error => {
48+
this.loading = false;
4649
console.log(error)
4750
}
4851
);
@@ -53,6 +56,7 @@ export class InviteComponent implements OnInit {
5356
} else if(this.password == null) {
5457
this.userErrorMsg = 'You must enter a password';
5558
} else {
59+
this.loading = true;
5660
this.userSrv.register(this.userName,this.password).subscribe(
5761
(_) => {
5862
this.roomSrv.enterRoom(this.code).subscribe(
@@ -62,11 +66,13 @@ export class InviteComponent implements OnInit {
6266
this.router.navigate(['/', this.roomName]);
6367
},
6468
error => {
69+
this.loading = false;
6570
console.log(error)
6671
}
6772
);
6873
},
6974
error => {
75+
this.loading = false;
7076
this.userErrorMsg = 'Username already taken';
7177
}
7278
);

0 commit comments

Comments
 (0)