diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 618c1f5..2792e5f 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -11,6 +11,7 @@ import { UpdateResultComponent } from './confirmation/update-result/updateResult import { LoginComponent } from './auth/login/login.component'; import { SignupComponent } from './auth/signup/signup.component'; import { AboutComponent } from './about/about.component'; +import { SecyComponent } from './secy/secy.component'; import { AuthGuard } from './auth/auth.guard'; const routes: Routes = [ @@ -24,6 +25,7 @@ const routes: Routes = [ { path: 'login', component: LoginComponent }, { path: 'signup', component: SignupComponent }, { path: 'about', component: AboutComponent }, + { path: 'harsh/1434/secy/:sport', component: SecyComponent }, ]; @NgModule({ diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 36ecbac..0879d73 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -41,6 +41,7 @@ import { AuthInterceptor } from './auth/auth-interceptor'; import { ServiceWorkerModule } from '@angular/service-worker'; import { environment } from '../environments/environment'; import { AboutComponent } from './about/about.component'; +import { SecyComponent } from './secy/secy.component'; @NgModule({ declarations: [ @@ -55,7 +56,8 @@ import { AboutComponent } from './about/about.component'; UpdateResultComponent, LoginComponent, SignupComponent, - AboutComponent + AboutComponent, + SecyComponent ], imports: [ BrowserModule, diff --git a/src/app/app.service.ts b/src/app/app.service.ts index e8402a1..b0c2019 100644 --- a/src/app/app.service.ts +++ b/src/app/app.service.ts @@ -59,6 +59,9 @@ export class LadderService { private tennisRankUpdate = new Subject(); private badmintonRankUpdate = new Subject(); + private categoryData: any; + private categoryUpdate = new Subject(); + constructor( private http: HttpClient, private router: Router, @@ -411,6 +414,19 @@ export class LadderService { }); } +// Secy Category + secyCategory(sport: string) { + this.http.get(BackendURLSecy + 'players/' + sport) + .subscribe(data => { + this.categoryData = data; + this.categoryUpdate.next(this.categoryData); + }); + } + + secyCategoryUpdateListener() { + return this.categoryUpdate.asObservable(); + } + // SnackBar for all! openSnackBar(message: string, action: string) { this.snackBar.open(message, action, { duration: 4000 }); diff --git a/src/app/ladder-table/ladder-table.component.ts b/src/app/ladder-table/ladder-table.component.ts index 1d9fbc4..d8b581c 100644 --- a/src/app/ladder-table/ladder-table.component.ts +++ b/src/app/ladder-table/ladder-table.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit, OnDestroy } from '@angular/core'; import { animate, state, style, transition, trigger } from '@angular/animations'; import { FormControl } from '@angular/forms'; import { LadderRanking } from './ladder.model'; -import { Subscription, timer } from 'rxjs'; +import { Subscription } from 'rxjs'; import { LadderService } from '../app.service'; import { Router } from '@angular/router'; import { MatTableDataSource } from '@angular/material'; diff --git a/src/app/secy/secy.component.css b/src/app/secy/secy.component.css new file mode 100644 index 0000000..24e6a65 --- /dev/null +++ b/src/app/secy/secy.component.css @@ -0,0 +1,5 @@ +table { + width: 80%; + margin-left:10%; + margin-top: 20px; +} diff --git a/src/app/secy/secy.component.html b/src/app/secy/secy.component.html new file mode 100644 index 0000000..77cbbe5 --- /dev/null +++ b/src/app/secy/secy.component.html @@ -0,0 +1,14 @@ + + + + + + + + + + + + + +
Name {{element.name}} Category {{element.category}}
diff --git a/src/app/secy/secy.component.ts b/src/app/secy/secy.component.ts new file mode 100644 index 0000000..39b11fc --- /dev/null +++ b/src/app/secy/secy.component.ts @@ -0,0 +1,41 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { LadderService } from '../app.service'; +import { Subscription } from 'rxjs'; +import { ActivatedRoute, ParamMap } from '@angular/router'; + +export interface CategoryTable { + name: string; + category: string; +} + +@Component({ + selector: 'app-secy', + templateUrl: './secy.component.html', + styleUrls: ['./secy.component.css'] +}) + +export class SecyComponent implements OnInit, OnDestroy { + + displayedColumns: string[] = ['name', 'category']; + dataSource: any; + sport: string; + public tableSub: Subscription; + + constructor(public ladderService: LadderService, public route: ActivatedRoute) {} + + ngOnInit() { + this.route.paramMap.subscribe((paramMap: ParamMap) => { + this.sport = paramMap.get('sport'); + }); + this.ladderService.secyCategory(this.sport); + this.tableSub = this.ladderService.secyCategoryUpdateListener() + .subscribe(data => { + this.dataSource = data; + }); + } + + ngOnDestroy() { + this.tableSub.unsubscribe(); + } + +}