added selector for championships
This commit is contained in:
parent
2e9ae2fdfe
commit
0f1434bb25
@ -1,5 +1,7 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {ActivatedRoute} from '@angular/router';
|
import {ActivatedRoute} from '@angular/router';
|
||||||
|
import {MatDialog} from '@angular/material';
|
||||||
|
import {ChampionshipselectordialogComponent} from './championshipselectordialog/championshipselectordialog.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
@ -14,6 +16,8 @@ export class AppComponent implements OnInit {
|
|||||||
constructor(private route: ActivatedRoute) {
|
constructor(private route: ActivatedRoute) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
// listen to the path ... what's the championship we're at?
|
// listen to the path ... what's the championship we're at?
|
||||||
this.route.paramMap.subscribe(val => {
|
this.route.paramMap.subscribe(val => {
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import {NgModule} from '@angular/core';
|
|||||||
|
|
||||||
import {AppComponent} from './app.component';
|
import {AppComponent} from './app.component';
|
||||||
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
||||||
import {MatButtonModule, MatCardModule, MatCheckboxModule} from '@angular/material';
|
import {MatButtonModule, MatCardModule, MatCheckboxModule, MatDialogModule, MatListModule} from '@angular/material';
|
||||||
import {TopmenuComponent} from './topmenu/topmenu.component';
|
import {TopmenuComponent} from './topmenu/topmenu.component';
|
||||||
import {ReclamespinnerComponent} from './reclamespinner/reclamespinner.component';
|
import {ReclamespinnerComponent} from './reclamespinner/reclamespinner.component';
|
||||||
import {PouleComponent} from './content/poule/poule.component';
|
import {PouleComponent} from './content/poule/poule.component';
|
||||||
@ -11,6 +11,7 @@ import {TierComponent} from './content/tier/tier.component';
|
|||||||
import {HttpClientModule} from '@angular/common/http';
|
import {HttpClientModule} from '@angular/common/http';
|
||||||
import {AppRoutingModule} from './app-routing.module';
|
import {AppRoutingModule} from './app-routing.module';
|
||||||
import { ChampionshipComponent } from './championship/championship.component';
|
import { ChampionshipComponent } from './championship/championship.component';
|
||||||
|
import { ChampionshipselectordialogComponent } from './championshipselectordialog/championshipselectordialog.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@ -19,18 +20,25 @@ import { ChampionshipComponent } from './championship/championship.component';
|
|||||||
ReclamespinnerComponent,
|
ReclamespinnerComponent,
|
||||||
PouleComponent,
|
PouleComponent,
|
||||||
TierComponent,
|
TierComponent,
|
||||||
ChampionshipComponent
|
ChampionshipComponent,
|
||||||
|
ChampionshipselectordialogComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
MatDialogModule,
|
||||||
AppRoutingModule,
|
AppRoutingModule,
|
||||||
BrowserAnimationsModule,
|
BrowserAnimationsModule,
|
||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
MatButtonModule,
|
MatButtonModule,
|
||||||
MatCheckboxModule,
|
MatCheckboxModule,
|
||||||
|
MatListModule,
|
||||||
MatCardModule,
|
MatCardModule,
|
||||||
],
|
],
|
||||||
providers: [],
|
providers: [],
|
||||||
|
entryComponents: [
|
||||||
|
ChampionshipselectordialogComponent
|
||||||
|
],
|
||||||
|
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
})
|
})
|
||||||
export class AppModule {
|
export class AppModule {
|
||||||
|
|||||||
@ -0,0 +1,3 @@
|
|||||||
|
<mat-list>
|
||||||
|
<mat-list-item *ngFor="let championship of championships()"> {{championship.name}} </mat-list-item>
|
||||||
|
</mat-list>
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ChampionshipselectordialogComponent } from './championshipselectordialog.component';
|
||||||
|
|
||||||
|
describe('ChampionshipselectordialogComponent', () => {
|
||||||
|
let component: ChampionshipselectordialogComponent;
|
||||||
|
let fixture: ComponentFixture<ChampionshipselectordialogComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ ChampionshipselectordialogComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(ChampionshipselectordialogComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import {MatDialogRef} from '@angular/material';
|
||||||
|
import {ChampionshipService} from '../championship.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-championshipselectordialog',
|
||||||
|
templateUrl: './championshipselectordialog.component.html',
|
||||||
|
styleUrls: ['./championshipselectordialog.component.scss']
|
||||||
|
})
|
||||||
|
export class ChampionshipselectordialogComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor(public dialogRef: MatDialogRef<ChampionshipselectordialogComponent>,
|
||||||
|
private championshipService: ChampionshipService) { }
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
championships() {
|
||||||
|
return this.championshipService.getChampionships();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -13,8 +13,8 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr *ngFor="let team of teams">
|
<tr *ngFor="let team of teams">
|
||||||
<td>{{team.name}}</td>
|
<td>{{team.name}}</td>
|
||||||
<td *ngFor="let y of ' '.repeat(maxRaces).split(''), let x = index">
|
<td class="timetd" *ngFor="let y of ' '.repeat(maxRaces).split(''), let x = index">
|
||||||
{{getTime(x, team.idteam)}}
|
<span class="time" *ngFor="let time of getTime(x, team.idteam)">{{time/1000}}s</span>
|
||||||
</td>
|
</td>
|
||||||
<td>Gem. beste 2</td>
|
<td>Gem. beste 2</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@ -0,0 +1,5 @@
|
|||||||
|
.time {
|
||||||
|
background-color: aquamarine;
|
||||||
|
margin: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
@ -61,23 +61,21 @@ export class PouleComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
getPenaltySum(lapNr: number, idTeam: number) {
|
||||||
* Get an array of laps:
|
if (!this.timesIndexed
|
||||||
* [{ lap: 1, time: xxxx}, {lap : 2, time: yyyy}]
|
|| !this.timesIndexed[idTeam]
|
||||||
*/
|
|| !this.timesIndexed[idTeam][lapNr]
|
||||||
getTimesForRace(raceNr: number, idTeam: number) {
|
|| !this.timesIndexed[idTeam][lapNr].penaltysum) {
|
||||||
// what is the 'raceNr'd idrace? first get the unique idraces, they're already sorted, then take the 'raceNr'd one.
|
return null;
|
||||||
// const anies = this.times.filter(t => t.idteam === idTeam);
|
}
|
||||||
// if (anies && anies.length >= raceNr) {
|
const penaltysum = this.timesIndexed[idTeam][lapNr].penaltysum;
|
||||||
// console.log('anies');
|
if (!penaltysum) {
|
||||||
// console.log(anies);
|
return 0;
|
||||||
// return anies[raceNr - 1];
|
}
|
||||||
// } else {
|
return penaltysum;
|
||||||
// return [];
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getTime(lapNr: number, idTeam: number) {
|
getTime(lapNr: number, idTeam: number):number[] {
|
||||||
// console.log('lapnr/idteam' + lapNr + ' ' + idTeam);
|
// console.log('lapnr/idteam' + lapNr + ' ' + idTeam);
|
||||||
// console.log(this.timesIndexed);
|
// console.log(this.timesIndexed);
|
||||||
// console.log(this.timesIndexed[idTeam][lapNr]);
|
// console.log(this.timesIndexed[idTeam][lapNr]);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<div class="button-row">
|
<div class="button-row">
|
||||||
<!--pick a year-->
|
<!--pick a year-->
|
||||||
<button mat-raised-button>{{currentChampionship()}}</button>
|
<button mat-raised-button (click)="openDialog()">{{currentChampionship()}}</button>
|
||||||
<button mat-raised-button color="primary" *ngFor="let tier of tiers" routerLink="/championship/20/tier/{{tier}}">Tier {{tier}}</button>
|
<button mat-raised-button color="primary" *ngFor="let tier of tiers" routerLink="/championship/20/tier/{{tier}}">Tier {{tier}}</button>
|
||||||
<a mat-button routerLink=".">Link</a>
|
<a mat-button routerLink=".">Link</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {ChampionshipService} from '../championship.service';
|
import {ChampionshipService} from '../championship.service';
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
import {ActivatedRoute, Router} from '@angular/router';
|
||||||
|
import {ChampionshipselectordialogComponent} from '../championshipselectordialog/championshipselectordialog.component';
|
||||||
|
import {MatDialog} from '@angular/material';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-topmenu',
|
selector: 'app-topmenu',
|
||||||
@ -14,7 +16,7 @@ export class TopmenuComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(private championshipService: ChampionshipService,
|
constructor(private championshipService: ChampionshipService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private router: Router) {
|
private router: Router,public dialog: MatDialog) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -32,4 +34,15 @@ export class TopmenuComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openDialog(): void {
|
||||||
|
const dialogRef = this.dialog.open(ChampionshipselectordialogComponent, {
|
||||||
|
width: '500px',
|
||||||
|
data: {name: 'whatever'}
|
||||||
|
});
|
||||||
|
|
||||||
|
dialogRef.afterClosed().subscribe(result => {
|
||||||
|
console.log('The dialog was closed');
|
||||||
|
console.log(result);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user