Skip to content

Commit

Permalink
work
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Daw committed Jul 18, 2017
1 parent c54be33 commit 2005799
Show file tree
Hide file tree
Showing 8 changed files with 5,582 additions and 4,952 deletions.
1,040 changes: 624 additions & 416 deletions scripts/app-bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/app-bundle.js.map

Large diffs are not rendered by default.

9,318 changes: 4,790 additions & 4,528 deletions scripts/vendor-bundle.js

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions src/microservices/stats/majors/majors-stats-styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.table-green {
color: #00bb00;
}

.table-red {
color: #cc0000;
}

.table-grey {
color: #aaaaaa;
}

.form-control {

width: 75%;
transition: none;
}
37 changes: 35 additions & 2 deletions src/microservices/stats/majors/majors-stats.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
<template>
majors
</template>
<require from="./majors-stats-styles.css"></require>
<div class="col-lg-12" if.bind="poolies">
<h2><span style="margin-right: 20px">${season} Majors Stats</span><small>after week ${week - 1} / <span class="text-primary">${tournamentName}</span></small></h2>
<div class="card-box">
<table id="majorstable" class="table">
<thead>
<tr>
<th>Rank</th>
<th>Poolie</th>
<th>Points</th>
<th>Behind</th>
<th>Wins</th>
<th>Top 5s</th>
<th>Top 10s</th>
<th>Cuts</th>
<th>+/-</th>
</tr>
</thead>
<tbody>
<tr repeat.for="poolie of poolies">
<td>${poolie.Rank}</td>
<td>${poolie.LastFirst}</td>
<td>${poolie.Points}</td>
<td>${poolie.Behind}</td>
<td class="${poolie.Wins === maxWins ? 'table-green' : ''}">${poolie.Wins}</td>
<td class="${poolie.Top5 === maxTop5 ? 'table-green' : ''}">${poolie.Top5}</td>
<td class="${poolie.Top10 === maxTop10 ? 'table-green' : ''}">${poolie.Top10}</td>
<td class="${poolie.Cuts === 0 ? 'table-green' : ''}">${poolie.Cuts}</td>
<td class="${poolie.PlusMinus === maxPlusMinus ? 'table-green' : ''}">${poolie.PlusMinus}</td>
</tr>
</tbody>
</table>
</div>
</div>
</template>
102 changes: 100 additions & 2 deletions src/microservices/stats/majors/majors-stats.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,102 @@
import { inject } from 'aurelia-framework';
import { StatsClient } from '../statsClient';

@inject(StatsClient)
export class MajorsStatsCustomElement {

}
constructor(sc: StatsClient) {
this.statsClient = sc;
}

private readonly statsClient: StatsClient;
private poolies: Array<Object>;
private season: number;
private week: number;
private tournamentName: string;

private maxWins: number;
private maxTop5: number;
private maxTop10: number;
private maxCuts: number;
private maxPlusMinus: number;

async attached() {
await this.getData();
window.setTimeout(() => {
(<any>$('#majorstable')).dataTable(this.getTableConfig());
(<any>$('input')).addClass("form-control input-sm");
}, 1000);
}

async getData() {
let data = await this.statsClient.getMajorsStats();
this.week = <number>data["Week"];
this.season = <number>data["Season"];
this.tournamentName = <string>data["Tournament"]
this.tournamentName = this.tournamentName.toLowerCase().startsWith("the ") ? this.tournamentName : `The ${this.tournamentName}`;
this.poolies = <Array<Object>>data["Poolies"];
this.getMaxValues();
}

getTableConfig(): Object {
return {
columnDefs: [
{ type: "num" },
{ type: "num" },
{ type: "string" },
{ type: "num" },
{ type: "num" },
{ type: "num" },
{ type: "num" },
{ type: "num" },
{ type: "num" },
{ type: "num" }
],
order: [[0, 'asc']],
paging: false,
info: false
};
}

getMaxValues() {
let array = [];
this.poolies.forEach(poolie => {
if(poolie["Wins"]){
array.push(poolie["Wins"]);
}
});
this.maxWins = Math.max.apply(null, array);

array = [];
this.poolies.forEach(poolie => {
if(poolie["Top5"]){
array.push(poolie["Top5"]);
}
});
this.maxTop5 = Math.max.apply(null, array);

array = [];
this.poolies.forEach(poolie => {
if(poolie["Top10"]){
array.push(poolie["Top10"]);
}
});
this.maxTop10 = Math.max.apply(null, array);

array = [];
this.poolies.forEach(poolie => {
if(poolie["Cuts"]){
array.push(poolie["Cuts"]);
}
});
this.maxCuts = Math.max.apply(null, array);

array = [];
this.poolies.forEach(poolie => {
if(poolie["PlusMinus"]){
array.push(poolie["PlusMinus"]);
}
});
this.maxPlusMinus = Math.max.apply(null, array);

}
}
14 changes: 13 additions & 1 deletion src/microservices/stats/statsClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,16 @@ export class StatsClient {
});
return response.Data;
}
}


async getMajorsStats(
season: string = 'current',
tour: string = 'PGA TOUR'): Promise<Object>{
let response = await this.restService.post(`https://ppppoolmajors.azurewebsites.net/api/GetMajors`, {
season
}, {
Authorization: `Bearer ${this.authService.getWebToken().authToken}`
});
return response.Data;
}
}
4 changes: 2 additions & 2 deletions src/resources/services/restService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class RestService {
if(!headers){
headers = {}
}
headers['Content-Type'] = 'application/json; charset=utf-8';
headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
let response = await this.http.fetch(urlQuery, {
method: 'post',
headers: headers ? headers : {},
Expand Down Expand Up @@ -66,4 +66,4 @@ export class Response {
Status: number;
Data: any;
IsError: Boolean;
}
}

0 comments on commit 2005799

Please sign in to comment.