diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index 14c0f91..5c4adcd 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -10,9 +10,6 @@ import { Subscription, timer } from 'rxjs';
})
export class AppComponent implements OnInit, OnDestroy {
title = 'ladder-ranking';
- private notifN: Subscription;
- private notifC: Subscription;
- private notifP: Subscription;
private authSub: Subscription;
public id: string;
@@ -21,24 +18,12 @@ export class AppComponent implements OnInit, OnDestroy {
ngOnInit() {
this.authService.autoAuthUser();
this.id = localStorage.getItem('_id');
- this.notifN = timer(1000)
- .subscribe(data => {
- this.ladderService.getNumberChallenge(this.id);
- });
- this.notifC = timer(1000)
- .subscribe(data => {
- this.ladderService.getNumberConfirmations(this.id);
- });
- this.notifP = timer(1000)
- .subscribe(data => {
- this.ladderService.getNumberPrevious(this.id);
- });
+ this.ladderService.getNumberChallenge(this.id);
+ this.ladderService.getNumberConfirmations(this.id);
+ this.ladderService.getNumberPrevious(this.id);
}
ngOnDestroy() {
this.authSub.unsubscribe();
- this.notifC.unsubscribe();
- this.notifN.unsubscribe();
- this.notifP.unsubscribe();
}
}
diff --git a/src/app/auth/auth.service.ts b/src/app/auth/auth.service.ts
index 9693c91..12550b4 100644
--- a/src/app/auth/auth.service.ts
+++ b/src/app/auth/auth.service.ts
@@ -5,6 +5,7 @@ import { AuthData } from './auth-data.model';
import { Subject } from 'rxjs';
import { Router } from '@angular/router';
import { environment } from '../../environments/environment';
+import { MatSnackBar } from '@angular/material';
@Injectable({ providedIn: 'root' })
export class AuthService {
@@ -13,7 +14,8 @@ export class AuthService {
private isAuthenticated = false;
private authStatusListener = new Subject();
private wrongCredential = new Subject();
- constructor(private http: HttpClient, private router: Router) {}
+
+ constructor(private http: HttpClient, private router: Router, private snackBar: MatSnackBar) {}
getToken() {
return this.token;
@@ -43,6 +45,7 @@ export class AuthService {
const authData: AuthData = {name, roll, hostel, gender, category, preferred, contact, password};
this.http.post(environment.apiUrl + 'signup', authData)
.subscribe();
+ this.snackBar('Successfully signed up!', 'OK')
this.router.navigate(['/login']);
}
@@ -61,6 +64,7 @@ export class AuthService {
this.authStatusListener.next(true);
this.wrongCredential.next(false);
this.saveAuthData(token);
+ this.snackBar('Successfully logged in!', 'OK')
this.router.navigate(['/']);
}
}, error => {
@@ -84,6 +88,7 @@ export class AuthService {
this.isAuthenticated = false;
this.authStatusListener.next(false);
this.clearAuthData();
+ this.snackBar('Successfully logged out!', 'OK')
this.router.navigate(['/']);
}
@@ -100,4 +105,9 @@ export class AuthService {
private getAuthData() {
return localStorage.getItem('token');
}
+
+ openSnackBar(message: string, action: string) {
+ this.snackBar.open(message, action, { duration: 2000 });
+ }
+
}
diff --git a/src/app/challenge-list/challenge-list.component.ts b/src/app/challenge-list/challenge-list.component.ts
index 7286a19..f5ff209 100644
--- a/src/app/challenge-list/challenge-list.component.ts
+++ b/src/app/challenge-list/challenge-list.component.ts
@@ -15,16 +15,13 @@ export class ChallengeListComponent implements OnInit, OnDestroy {
challengesS: Challenges[] = [];
private challengesSubR: Subscription;
private challengesSubS: Subscription;
- private refresher: Subscription;
public id = localStorage.getItem('_id');
constructor(public ladderService: LadderService) {}
ngOnInit() {
- this.refresher = timer(0, 10000).subscribe(() => {
- this.ladderService.getChallengesR(this.id);
- this.ladderService.getChallengesS(this.id);
- });
+ this.ladderService.getChallengesR(this.id);
+ this.ladderService.getChallengesS(this.id);
this.challengesSubR = this.ladderService.getChallengesRUpdateListener()
.subscribe((challenges: Challenges[]) => {
for (const challenge of challenges) {
@@ -72,7 +69,6 @@ export class ChallengeListComponent implements OnInit, OnDestroy {
}
onDeleteR(id: string) {
- this.refresher.unsubscribe();
this.ladderService.deleteChallengeR(id);
this.ladderService.openSnackBar('Challenge Declined!', 'OK');
}
diff --git a/src/app/confirmation/confirm-result/confirmation.component.ts b/src/app/confirmation/confirm-result/confirmation.component.ts
index c1f6aee..ea38665 100644
--- a/src/app/confirmation/confirm-result/confirmation.component.ts
+++ b/src/app/confirmation/confirm-result/confirmation.component.ts
@@ -17,10 +17,7 @@ export class ConfirmationComponent implements OnInit, OnDestroy {
constructor(public ladderService: LadderService) { }
ngOnInit() {
- this.refresher = timer(0, 15000)
- .subscribe(data => {
- this.ladderService.getConfirmations(this.id);
- });
+ this.ladderService.getConfirmations(this.id);
this.confirmSub = this.ladderService.getConfirmationsUpdateListener()
.subscribe((confirmations: Confirmations[]) => {
this.confirmations = confirmations;
@@ -67,6 +64,5 @@ export class ConfirmationComponent implements OnInit, OnDestroy {
ngOnDestroy() {
this.confirmSub.unsubscribe();
- this.refresher.unsubscribe();
}
}
diff --git a/src/app/confirmation/update-result/updateResult.component.html b/src/app/confirmation/update-result/updateResult.component.html
index d4595cc..c8006ed 100644
--- a/src/app/confirmation/update-result/updateResult.component.html
+++ b/src/app/confirmation/update-result/updateResult.component.html
@@ -18,5 +18,7 @@ Update Result
How to enter score?
Enter the match score in first one
- Enter set score like this
11-0 11-10 11-9
+ Enter set score like this
11-5 11-10 11-9
+ First enter your score then opponent's,
+ so 11 would be your score and 5 would be opponent's score
diff --git a/src/app/header/header.component.html b/src/app/header/header.component.html
index 5002b0d..0e20146 100644
--- a/src/app/header/header.component.html
+++ b/src/app/header/header.component.html
@@ -6,6 +6,12 @@
+ -
+
+
-
+