Skip to content

Commit

Permalink
secy support
Browse files Browse the repository at this point in the history
  • Loading branch information
harshbaldwa committed Oct 6, 2019
1 parent 5a420b2 commit 03f21f0
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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({
Expand Down
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -55,7 +56,8 @@ import { AboutComponent } from './about/about.component';
UpdateResultComponent,
LoginComponent,
SignupComponent,
AboutComponent
AboutComponent,
SecyComponent
],
imports: [
BrowserModule,
Expand Down
16 changes: 16 additions & 0 deletions src/app/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ export class LadderService {
private tennisRankUpdate = new Subject<number>();
private badmintonRankUpdate = new Subject<number>();

private categoryData: any;
private categoryUpdate = new Subject<any>();

constructor(
private http: HttpClient,
private router: Router,
Expand Down Expand Up @@ -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 });
Expand Down
2 changes: 1 addition & 1 deletion src/app/ladder-table/ladder-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
5 changes: 5 additions & 0 deletions src/app/secy/secy.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
table {
width: 80%;
margin-left:10%;
margin-top: 20px;
}
14 changes: 14 additions & 0 deletions src/app/secy/secy.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef> Name </th>
<td mat-cell *matCellDef="let element"> {{element.name}} </td>
</ng-container>

<ng-container matColumnDef="category">
<th mat-header-cell *matHeaderCellDef> Category </th>
<td mat-cell *matCellDef="let element"> {{element.category}} </td>
</ng-container>

<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
41 changes: 41 additions & 0 deletions src/app/secy/secy.component.ts
Original file line number Diff line number Diff line change
@@ -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();
}

}

0 comments on commit 03f21f0

Please sign in to comment.