Skip to content

Commit

Permalink
Merge pull request #12 from deniskond/feature/gh-11
Browse files Browse the repository at this point in the history
DFWC integration
  • Loading branch information
deniskond committed Dec 29, 2019
2 parents f88c76e + 589ae0e commit e1ef018
Show file tree
Hide file tree
Showing 36 changed files with 3,386 additions and 2,569 deletions.
5,141 changes: 2,597 additions & 2,544 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@ngrx/store": "^7.2.0",
"chart.js": "^2.8.0",
"core-js": "^2.4.1",
"html-entities": "^1.2.1",
"less": "^3.9.0",
"lodash": "^4.17.11",
"moment": "^2.24.0",
Expand Down
10 changes: 8 additions & 2 deletions src/app/components/player-cell/player-cell.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<div mat-ripple
<div *ngIf="playerId"
mat-ripple
[@hoveredCell]="getHoveredState()"
(mouseenter)="darkenPlayerRow()"
(mouseleave)="lightenPlayerRow()"
Expand All @@ -7,4 +8,9 @@

<app-flag [country]="country" [class.light]="style === playerCellStyles.TRANSPARENT" class="flag"></app-flag>
<div [class.light]="style === playerCellStyles.TRANSPARENT" class="player-nick">{{ nick }}</div>
</div>
</div>

<div *ngIf="!playerId" class="player-nick-container no-hover">
<app-flag [country]="country" [class.light]="style === playerCellStyles.TRANSPARENT" class="flag"></app-flag>
<div [class.light]="style === playerCellStyles.TRANSPARENT" class="player-nick">{{ nick }}</div>
</div>
4 changes: 4 additions & 0 deletions src/app/components/player-cell/player-cell.component.less
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
font-family: inherit;
letter-spacing: inherit;

&.no-hover {
cursor: default;
}

.flag {
margin-left: 8px;

Expand Down
7 changes: 5 additions & 2 deletions src/app/components/player-cell/player-cell.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input } from '@angular/core';
import { Component, Input, ChangeDetectionStrategy } from '@angular/core';
import {
hoverableCellAnimation,
HOVERABLE_CELL_HOVERED_STATE,
Expand All @@ -14,6 +14,7 @@ import { PlayerCellStyles } from './enums/player-cell-styles.enum';
templateUrl: './player-cell.component.html',
styleUrls: ['./player-cell.component.less'],
animations: [hoverableCellAnimation],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class PlayerCellComponent {
@Input() country: string;
Expand Down Expand Up @@ -43,6 +44,8 @@ export class PlayerCellComponent {
}

public navigateToPlayerProfile(playerId: string): void {
this.router.navigate([`/profile/${playerId}`]);
if (playerId) {
this.router.navigate([`/profile/${playerId}`]);
}
}
}
1 change: 1 addition & 0 deletions src/app/enums/news-types.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export enum NewsTypes {
ONLINE_RESULTS = 'online_results',
MULTICUP_RESULTS = 'multicup_results',
SIMPLE = 'text',
DFWC_RESULTS = 'dfwc_round_results',
}
4 changes: 2 additions & 2 deletions src/app/interfaces/cup.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ export interface CupInterface {
type: string;
useTwoServers: string;
youtube: string;
customMap: string;
customNews: string;
customMap?: string;
customNews?: string;
}
2 changes: 2 additions & 0 deletions src/app/interfaces/valid-demo.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ export interface ValidDemoInterface {
rating: string;
row: string;
time: string;
isPreliminaryResult?: boolean;
absoluteLink?: boolean;
}
375 changes: 375 additions & 0 deletions src/app/pages/dfwc2019/constants/results.constants.ts

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions src/app/pages/dfwc2019/dfwc2019.page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<div class="shadowed-main-block">
<h1 class="h1-block-header">DFWC 2019 Results</h1>

<div style="display: flex;">
<div style="flex-grow:1;margin-right:20px;">
<div class="physics-header">
VQ3
</div>
<div class="cup-results-row">
<div class="place-column">#</div>
<div class="player-column">Player</div>
<div class="points-column">Points</div>
<div class="rating-column">Rating</div>
</div>
<div *ngFor="let result of vq3TableWithChange; let i = index" class="cup-results-row">
<div class="place-column">
<app-player-place [place]="result.place"></app-player-place>
</div>
<div class="player-column">
<app-player-cell
[class.transparent]="!result.playerId"
[country]="result.country"
[nick]="result.nick"
[playerId]="result.playerId">
</app-player-cell>
</div>
<div class="points-column">{{ result.points }}</div>
<div class="rating-column">
<app-rating-change [change]="result.change" [zeroIfNull]="false"></app-rating-change>
</div>
</div>
</div>
<div style="flex-grow:1;">
<div class="physics-header">
CPM
</div>
<div class="cup-results-row">
<div class="place-column">#</div>
<div class="player-column">Player</div>
<div class="points-column">Points</div>
<div class="rating-column">Rating</div>
</div>
<div *ngFor="let result of cpmTableWithChange; let i = index" class="cup-results-row">
<div class="place-column">
<app-player-place [place]="i + 1"></app-player-place>
</div>
<div class="player-column">
<app-player-cell
[class.transparent]="!result.playerId"
[country]="result.country"
[nick]="result.nick"
[playerId]="result.playerId">
</app-player-cell>
</div>
<div class="points-column">{{ result.points }}</div>
<div class="rating-column">
<app-rating-change [change]="result.change" [zeroIfNull]="false"></app-rating-change>
</div>
</div>
</div>
</div>
</div>
54 changes: 54 additions & 0 deletions src/app/pages/dfwc2019/dfwc2019.page.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
.physics-header {
text-transform: uppercase;
font-weight: bold;
display: flex;
align-items: center;
justify-content: center;
background: #eeeeee;
border: 1px solid #cccccc;
height: 32px;
}

.cup-results-row {
display: flex;
height: 32px;
border: 1px solid #ccc;
border-top: 0px;

.place-column {
display: flex;
justify-content: center;
align-items: center;
width: 32px;
border-right: 1px solid #ccc;
}

.player-column {
display: flex;
justify-content: center;
align-items: center;
flex-grow: 1;
border-right: 1px solid #ccc;
position: relative;
}

.points-column {
display: flex;
justify-content: center;
align-items: center;
width: 80px;
border-right: 1px solid #ccc;
}

.rating-column {
display: flex;
justify-content: center;
align-items: center;
width: 80px;
position: relative;
}
}

.transparent {
opacity: 0.5;
}
18 changes: 18 additions & 0 deletions src/app/pages/dfwc2019/dfwc2019.page.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { SharedModule } from '../../modules/shared.module';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { Dfwc2019PageComponent } from './dfwc2019.page';

const routes: Routes = [
{
path: '',
component: Dfwc2019PageComponent,
},
];

@NgModule({
declarations: [Dfwc2019PageComponent],
imports: [SharedModule, CommonModule, RouterModule.forChild(routes)],
})
export class Dfwc2019PageModule {}
24 changes: 24 additions & 0 deletions src/app/pages/dfwc2019/dfwc2019.page.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Dfwc2019PageComponent } from './dfwc2019.page';
import { Dfwc2019PageModule } from './dfwc2019.page.module';

describe('Dfwc2019PageComponent', () => {
let component: Dfwc2019PageComponent;
let fixture: ComponentFixture<Dfwc2019PageComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [Dfwc2019PageModule],
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(Dfwc2019PageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
31 changes: 31 additions & 0 deletions src/app/pages/dfwc2019/dfwc2019.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { LanguageService } from '../../services/language/language.service';
import { Translations } from '../../components/translations/translations.component';
import { Component, ChangeDetectionStrategy, OnInit } from '@angular/core';
import { DfwcResultInterface } from './interfaces/dfwc-result.interface';
import { MAX_DFWC_RATING, vq3Table, cpmTable } from './constants/results.constants';

@Component({
templateUrl: './dfwc2019.page.html',
styleUrls: ['./dfwc2019.page.less'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class Dfwc2019PageComponent extends Translations implements OnInit {
public vq3TableWithChange: DfwcResultInterface[];
public cpmTableWithChange: DfwcResultInterface[];

constructor(protected languageService: LanguageService) {
super(languageService);
}

ngOnInit(): void {
this.vq3TableWithChange = vq3Table.map((result: DfwcResultInterface) => ({
...result,
change: Math.round((MAX_DFWC_RATING * result.points) / vq3Table[0].points),
}));

this.cpmTableWithChange = cpmTable.map((result: DfwcResultInterface) => ({
...result,
change: Math.round((MAX_DFWC_RATING * result.points) / cpmTable[0].points),
}));
}
}
8 changes: 8 additions & 0 deletions src/app/pages/dfwc2019/interfaces/dfwc-result.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface DfwcResultInterface {
place: number;
country: string;
nick: string;
points: number;
playerId?: number;
change?: number;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { DfwcSingleResultDtoInterface } from './dfwc-single-result.dto';

export interface DfwcResultsDtoInterface {
vq3: Record<string, DfwcSingleResultDtoInterface>;
cpm: Record<string, DfwcSingleResultDtoInterface>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export interface DfwcSingleResultDtoInterface {
rank: string;
flag: string;
name: string;
demo: string;
time: string;
points: string;
pid: string;
ref_id: string;
time_ms: string;
status: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<app-news-offline-results *ngIf="mappedOfflineNews" [news]="mappedOfflineNews" [customTable]="true"></app-news-offline-results>
<div style="font-weight: bold;margin-top: 12px;font-size: 16px;">
<a [href]="news.cup.customNews">>> {{ translations?.fullResultsTable }} <<</a>
</div>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { NewsDfwcResultsComponent } from './news-dfwc-results.component';

describe('NewsDfwcResultsComponent', () => {
let component: NewsDfwcResultsComponent;
let fixture: ComponentFixture<NewsDfwcResultsComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ NewsDfwcResultsComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(NewsDfwcResultsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { LanguageService } from '../../../../services/language/language.service';
import { Translations } from '../../../../components/translations/translations.component';
import { NewsOfflineResultsInterface } from '../../../../services/news-service/interfaces/news-offline-results.interface';
import { Component, Input, OnInit } from '@angular/core';
import { DfwcResultsService } from './services/dfwc-results.service';

@Component({
selector: 'app-news-dfwc-results',
templateUrl: './news-dfwc-results.component.html',
styleUrls: ['./news-dfwc-results.component.less'],
})
export class NewsDfwcResultsComponent extends Translations implements OnInit {
@Input()
news: NewsOfflineResultsInterface;

public mappedOfflineNews: NewsOfflineResultsInterface;

constructor(protected languageService: LanguageService, private dfwcResultsService: DfwcResultsService) {
super(languageService);
}

ngOnInit(): void {
this.mappedOfflineNews = this.dfwcResultsService.mapDfwcResultsToOfflineNews(this.news);
super.ngOnInit();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';
import { DfwcResultsService } from './dfwc-results.service';

describe('DfwcResultsService', () => {
beforeEach(() => TestBed.configureTestingModule({}));

it('should be created', () => {
const service: DfwcResultsService = TestBed.get(DfwcResultsService);

expect(service).toBeTruthy();
});
});
Loading

0 comments on commit e1ef018

Please sign in to comment.