-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
755 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
import { Constructor } from "./constructor"; | ||
import { Constructor } from './constructor'; | ||
|
||
export class ConstructorStanding { | ||
position: string; | ||
positionText: string; | ||
points: string; | ||
wins: string; | ||
|
||
position: string; | ||
positionText: string; | ||
points: string; | ||
wins: string; | ||
|
||
Constructor: Constructor; | ||
} | ||
Constructor: Constructor; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
import { Driver } from "./driver"; | ||
import { Constructor } from "./constructor"; | ||
import { Driver } from './driver'; | ||
import { Constructor } from './constructor'; | ||
|
||
export class DriverStanding { | ||
position: string; | ||
positionText: string; | ||
points: string; | ||
wins: string; | ||
|
||
position: string; | ||
positionText: string; | ||
points: string; | ||
wins: string; | ||
Driver: Driver; | ||
|
||
Driver: Driver; | ||
|
||
constructors: Constructor[]; | ||
} | ||
Constructors: Constructor[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ery/params/query-builder/query-builder.ts → ...ce-results/query-builder/query-builder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/app/pages/query/params/standings/models/search-type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export class SearchType { | ||
static readonly KEY_DRIVER_STANDINGS = 'driver-standings'; | ||
static readonly KEY_DRIVER_INFORMATION = 'driver-information'; | ||
|
||
static readonly KEY_CONSTRUCTOR_STANDINGS = 'constructor-standings'; | ||
static readonly KEY_CONSTRUCTOR_INFORMATION = 'constructor-information'; | ||
|
||
static readonly resultsSearchTypes = [ | ||
{ key: SearchType.KEY_DRIVER_STANDINGS, endPointName: 'driverStandings' }, | ||
{ | ||
key: SearchType.KEY_CONSTRUCTOR_STANDINGS, | ||
endPointName: 'constructorStandings', | ||
}, | ||
{ key: SearchType.KEY_DRIVER_INFORMATION, endPointName: 'drivers' }, | ||
{ | ||
key: SearchType.KEY_CONSTRUCTOR_INFORMATION, | ||
endPointName: 'constructors', | ||
}, | ||
{ key: 'season-list', endPointName: 'seasons' }, | ||
]; | ||
|
||
key: string; | ||
endPointName: string; | ||
|
||
public static getRsultsSearchTypes(): SearchType[] { | ||
return SearchType.resultsSearchTypes; | ||
} | ||
|
||
public static findByKey(key: string): SearchType { | ||
return SearchType.resultsSearchTypes.find(st => st.key === key); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/app/pages/query/params/standings/models/standings-model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { SearchType } from './search-type'; | ||
|
||
export class StandingsModel { | ||
public type: string = null; | ||
public season: string = null; | ||
public round: string = null; | ||
public driverStanding: string = null; | ||
public driverId: string = null; | ||
public constructorStanding: string = null; | ||
public constructorId: string = null; | ||
public resultPerPage: number = null; | ||
|
||
constructor() { | ||
this.type = SearchType.getRsultsSearchTypes()[0].key; | ||
this.resultPerPage = 20; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/app/pages/query/params/standings/query-builder/query-builder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { environment } from '../../../../../../environments/environment.prod'; | ||
import { StandingsModel } from '../models/standings-model'; | ||
import { SearchType } from '../models/search-type'; | ||
export class QueryBuilder { | ||
buildUrl(model: StandingsModel): string { | ||
// Remove last char ( last char = '/' ) | ||
let url = environment.ergastApiUrl.slice(0, -1); | ||
|
||
// append url generated from model params | ||
url += this.getUrlFromModel(model); | ||
|
||
// append resource to retreive | ||
url += `/${SearchType.findByKey(model.type).endPointName}.json`; | ||
|
||
// add query limit | ||
url += `?limit=${model.resultPerPage}`; | ||
|
||
return url; | ||
} | ||
|
||
private getUrlFromModel(model: StandingsModel): string { | ||
let url = ''; | ||
|
||
if (model.season !== null) { | ||
url += `/${model.season}`; | ||
} | ||
if (model.round !== null) { | ||
url += `/${model.round}`; | ||
} | ||
if (model.driverId !== null) { | ||
url += `/drivers/${model.driverId}`; | ||
} | ||
if (model.driverStanding !== null) { | ||
url += `/driverStandings/${model.driverStanding}`; | ||
} | ||
if (model.constructorId !== null) { | ||
url += `/constructors/${model.constructorId}`; | ||
} | ||
if (model.constructorStanding !== null) { | ||
url += `/constructorStanding/${model.constructorStanding}`; | ||
} | ||
|
||
return url; | ||
} | ||
} |
166 changes: 166 additions & 0 deletions
166
src/app/pages/query/params/standings/standings.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
<div class="container"> | ||
<form #paramsStandingsForm="ngForm" (ngSubmit)="onSubmit()"> | ||
<!-- Type --> | ||
<div class="form-group"> | ||
<label for="type">{{ 'type.sing' | translate | ngxCapitalize }}</label> | ||
|
||
<p-dropdown | ||
[options]="types" | ||
id="type" | ||
required | ||
[(ngModel)]="model.type" | ||
(onChange)="onTypeChange()" | ||
name="type" | ||
#type="ngModel" | ||
appendTo="body" | ||
[style]="{ width: '100%' }" | ||
[filter]="appSettings.filterVisible" | ||
></p-dropdown> | ||
</div> | ||
|
||
<!-- Season --> | ||
<div class="form-group"> | ||
<label for="season">{{ | ||
'season.sing' | translate | ngxCapitalize | ||
}}</label> | ||
|
||
<p-dropdown | ||
[options]="seasons" | ||
id="season" | ||
[(ngModel)]="model.season" | ||
(onChange)="onSeasonChange($event.value)" | ||
name="season" | ||
#season="ngModel" | ||
appendTo="body" | ||
[style]="{ width: '100%' }" | ||
[filter]="appSettings.filterVisible" | ||
></p-dropdown> | ||
</div> | ||
|
||
<!-- Round --> | ||
<div class="form-group"> | ||
<label for="round">{{ 'round.sing' | translate | ngxCapitalize }}</label> | ||
|
||
<p-dropdown | ||
[options]="rounds" | ||
id="round" | ||
[(ngModel)]="model.round" | ||
name="round" | ||
#round="ngModel" | ||
appendTo="body" | ||
[style]="{ width: '100%' }" | ||
[filter]="appSettings.filterVisible" | ||
[disabled]="roundsDisable" | ||
></p-dropdown> | ||
</div> | ||
|
||
<!-- Driver standings --> | ||
<div class="form-group"> | ||
<label for="drStandings">{{ | ||
'driver-standings' | translate | ngxCapitalize | ||
}}</label> | ||
|
||
<p-dropdown | ||
[options]="driverStandings" | ||
id="drStandings" | ||
[(ngModel)]="model.driverStandings" | ||
name="drStandings" | ||
#drStandings="ngModel" | ||
appendTo="body" | ||
[style]="{ width: '100%' }" | ||
[filter]="appSettings.filterVisible" | ||
[disabled]="driversDisable" | ||
></p-dropdown> | ||
</div> | ||
|
||
<!-- Driver --> | ||
<div class="form-group"> | ||
<label for="driverId">{{ | ||
'driver.sing' | translate | ngxCapitalize | ||
}}</label> | ||
|
||
<p-dropdown | ||
[options]="drivers" | ||
id="driverId" | ||
[(ngModel)]="model.driverId" | ||
name="driverId" | ||
#driverId="ngModel" | ||
appendTo="body" | ||
autoWidth="false" | ||
[style]="{ width: '100%' }" | ||
[filter]="appSettings.filterVisible" | ||
[disabled]="driversDisable" | ||
></p-dropdown> | ||
</div> | ||
|
||
<!-- Constructor standings --> | ||
<div class="form-group"> | ||
<label for="csStandings">{{ | ||
'constructor-standings' | translate | ngxCapitalize | ||
}}</label> | ||
|
||
<p-dropdown | ||
[options]="constructorStandings" | ||
id="csStandings" | ||
[(ngModel)]="model.constructorStandings" | ||
name="csStandings" | ||
#csStandings="ngModel" | ||
appendTo="body" | ||
[style]="{ width: '100%' }" | ||
[filter]="appSettings.filterVisible" | ||
[disabled]="constructorDisable" | ||
></p-dropdown> | ||
</div> | ||
|
||
<!-- Constructor --> | ||
<div class="form-group"> | ||
<label for="constructorId">{{ | ||
'constructor.sing' | translate | ngxCapitalize | ||
}}</label> | ||
|
||
<p-dropdown | ||
[options]="constructors" | ||
id="constructorId" | ||
[(ngModel)]="model.constructorId" | ||
name="constructorId" | ||
#constructorId="ngModel" | ||
appendTo="body" | ||
[style]="{ width: '100%' }" | ||
[filter]="appSettings.filterVisible" | ||
[disabled]="constructorDisable" | ||
></p-dropdown> | ||
</div> | ||
|
||
<!-- Result per page --> | ||
<div class="form-group"> | ||
<label for="resultPerPage">{{ | ||
'result.per-page' | translate | ngxCapitalize | ||
}}</label> | ||
|
||
<p-dropdown | ||
[options]="resultsPerPage" | ||
id="resultPerPage" | ||
required | ||
[(ngModel)]="model.resultPerPage" | ||
name="resultPerPage" | ||
#resultPerPage="ngModel" | ||
appendTo="body" | ||
[style]="{ width: '100%' }" | ||
></p-dropdown> | ||
</div> | ||
|
||
<div style="width: 100%;display:flex;justify-content:space-around;"> | ||
<button | ||
nbButton | ||
type="button" | ||
class="btn btn-default form-button" | ||
(click)="paramsStandingsForm.reset(); newModel()" | ||
> | ||
{{ 'cancel' | translate | ngxCapitalize }} | ||
</button> | ||
<button nbButton type="submit" class="btn btn-success form-button"> | ||
{{ 'search.sing' | translate | ngxCapitalize }} | ||
</button> | ||
</div> | ||
</form> | ||
</div> |
9 changes: 9 additions & 0 deletions
9
src/app/pages/query/params/standings/standings.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@import "../../../../@theme/styles/themes"; | ||
@import "~@nebular/theme/components/card/card.component.theme"; | ||
|
||
@include nb-install-component() { | ||
.form-button { | ||
width: 100%; | ||
margin: 0px 5px 0px 5px; | ||
} | ||
} |
Oops, something went wrong.