Skip to content
This repository was archived by the owner on Oct 10, 2018. It is now read-only.

Commit 1989dbc

Browse files
author
kennydee
committed
Merge pull request #85 from M6Web/feature-improve-hp
HP Refactoring + small improvements
2 parents 8307374 + 13e565d commit 1989dbc

File tree

11 files changed

+167
-79
lines changed

11 files changed

+167
-79
lines changed

app/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
<script src="scripts/controllers/babitchAdminPlayers.js"></script>
6363
<script src="scripts/controllers/babitchAdminPlayer.js"></script>
6464
<script src="scripts/controllers/babitchAdminPlayerEdit.js"></script>
65-
<script src="scripts/controllers/babitchStats.js"></script>
65+
<script src="scripts/controllers/babitchHome.js"></script>
6666
<script src="scripts/httpBackendStub.js"></script>
6767
<script src="scripts/filters/prettyTime.js"></script>
6868
<script src="scripts/filters/gravatarize.js"></script>

app/scripts/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ angular.module('babitchFrontendApp', [
2929
url: '',
3030
views: {
3131
'main': {
32-
templateUrl: 'views/partial/statsOverall.html',
33-
controller: 'babitchStatsCtrl'
32+
templateUrl: 'views/partial/home.html',
33+
controller: 'babitchHomeCtrl'
3434
}
3535
}
3636
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
angular.module('babitchFrontendApp').controller('babitchStatsCtrl', function($scope, $rootScope, babitchStats) {
3+
angular.module('babitchFrontendApp').controller('babitchHomeCtrl', function($scope, $rootScope, babitchStats) {
44

55
$scope.menuSelect = '';
66

app/views/partial/home.html

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<div class="container">
2+
3+
<div class="page-header">
4+
<h1>Overview</h1>
5+
</div>
6+
7+
<h2>Last 3 games</h2>
8+
9+
<table class="table table-hover table-condensed lastGames">
10+
<thead>
11+
<tr>
12+
<th>Red Team</th>
13+
<th class="text-center">Score</th>
14+
<th class="text-right">Blue Team</th>
15+
</tr>
16+
</thead>
17+
<tbody>
18+
<tr ng-repeat="games in stats.gamesList | limitTo:(3)">
19+
<td class="team red">
20+
<a ng-href="/#/stats/players/{{ stats.playersList[games.redDefense].id }}">
21+
<img gravatar-src="stats.playersList[games.redDefense].email || ''" gravatar-default="wavatar" gravatar-size="30" />
22+
{{ stats.playersList[games.redDefense].name }}
23+
</a>
24+
<a ng-href="/#/stats/players/{{ stats.playersList[games.redAttack].id }}">
25+
<img gravatar-src="stats.playersList[games.redAttack].email || ''" gravatar-default="wavatar" gravatar-size="30" />
26+
{{ stats.playersList[games.redAttack].name }}
27+
</a>
28+
</td>
29+
<td class="score">
30+
<a ng-href="/#/stats/games/{{ games.id }}" class="score-{{ games.red_score }}">{{ games.red_score }}</a>
31+
<span>:</span>
32+
<a ng-href="/#/stats/games/{{ games.id }}" class="score-{{ games.blue_score }}">{{ games.blue_score }}</a>
33+
</td>
34+
<td class="team blue">
35+
<a ng-href="/#/stats/players/{{ stats.playersList[games.blueDefense].id }}">
36+
{{ stats.playersList[games.blueDefense].name }}
37+
<img gravatar-src="stats.playersList[games.blueDefense].email || ''" gravatar-default="wavatar" gravatar-size="30" />
38+
</a>
39+
<a ng-href="/#/stats/players/{{ stats.playersList[games.blueAttack].id }}">
40+
{{ stats.playersList[games.blueAttack].name }}
41+
<img gravatar-src="stats.playersList[games.blueAttack].email || ''" gravatar-default="wavatar" gravatar-size="30" />
42+
</a>
43+
</td>
44+
</tr>
45+
</tbody>
46+
</table>
47+
48+
<h2>Player's highlight</h2>
49+
50+
<div class="row">
51+
<div ng-repeat="player in stats.statsPlayers | orderBy:'eloRanking':true| minGamePlayed:stats.minGamePlayedPlayers | limitTo:1" class="col-xs-6 col-sm-3 placeholder">
52+
<a ng-href="/#/stats/players/{{ player.id }}">
53+
<img gravatar-src="stats.playersList[player.id].email || ''" gravatar-default="wavatar" gravatar-size="200" class="img-thumbnail" />
54+
</a>
55+
<h4>Best Elo Ranking</h4>
56+
<span class="text-muted">{{ player.name }} ({{ stats.statsPlayers[player.id].eloRanking }})</span>
57+
</div>
58+
<div ng-repeat="player in stats.statsPlayers | orderBy:'percentGoalPerBall':true| minGamePlayed:stats.minGamePlayedPlayers | limitTo:1" class="col-xs-6 col-sm-3 placeholder">
59+
<a ng-href="/#/stats/players/{{ player.id }}">
60+
<img gravatar-src="stats.playersList[player.id].email || ''" gravatar-default="wavatar" gravatar-size="200" class="img-thumbnail" />
61+
</a>
62+
<h4>Top Goaler</h4>
63+
<span class="text-muted">{{ player.name }} ({{ stats.statsPlayers[player.id].percentGoalPerBall }}%)</span>
64+
</div>
65+
<div ng-repeat="player in stats.statsPlayers | orderBy:'percentVictory':true| minGamePlayed:stats.minGamePlayedPlayers | limitTo:1" class="col-xs-6 col-sm-3 placeholder">
66+
<a ng-href="/#/stats/players/{{ player.id }}">
67+
<img gravatar-src="stats.playersList[player.id].email || ''" gravatar-default="wavatar" gravatar-size="200" class="img-thumbnail" />
68+
</a>
69+
<h4>Top Victory</h4>
70+
<span class="text-muted">{{ player.name }} ({{ stats.statsPlayers[player.id].percentVictory }}%)</span>
71+
</div>
72+
<div ng-repeat="player in stats.statsPlayers | orderBy:'gamePlayed':true| minGamePlayed:stats.minGamePlayedPlayers | limitTo:1" class="col-xs-6 col-sm-3 placeholder">
73+
<a ng-href="/#/stats/players/{{ player.id }}">
74+
<img gravatar-src="stats.playersList[player.id].email || ''" gravatar-default="wavatar" gravatar-size="200" class="img-thumbnail" />
75+
</a>
76+
<h4>Play the most</h4>
77+
<span class="text-muted">{{ player.name }} ({{ stats.statsPlayers[player.id].gamePlayed }})</span>
78+
</div>
79+
<div ng-repeat="player in stats.statsPlayers | orderBy:'eloRanking':false| minGamePlayed:stats.minGamePlayedPlayers | limitTo:1" class="col-xs-6 col-sm-3 placeholder">
80+
<a ng-href="/#/stats/players/{{ player.id }}">
81+
<img gravatar-src="stats.playersList[player.id].email || ''" gravatar-default="wavatar" gravatar-size="200" class="img-thumbnail" />
82+
</a>
83+
<h4>Worst Elo Ranking</h4>
84+
<span class="text-muted">{{ player.name }} ({{ stats.statsPlayers[player.id].eloRanking }})</span>
85+
</div>
86+
<div ng-repeat="player in stats.statsPlayers | orderBy:'percentGoalPerBall':false| minGamePlayed:stats.minGamePlayedPlayers | limitTo:1" class="col-xs-6 col-sm-3 placeholder">
87+
<a ng-href="/#/stats/players/{{ player.id }}">
88+
<img gravatar-src="stats.playersList[player.id].email || ''" gravatar-default="wavatar" gravatar-size="200" class="img-thumbnail" />
89+
</a>
90+
<h4>Worst Goaler</h4>
91+
<span class="text-muted">{{ player.name }} ({{ stats.statsPlayers[player.id].percentGoalPerBall }}%)</span>
92+
</div>
93+
<div ng-repeat="player in stats.statsPlayers | orderBy:'percentLoose':true| minGamePlayed:stats.minGamePlayedPlayers | limitTo:1" class="col-xs-6 col-sm-3 placeholder">
94+
<a ng-href="/#/stats/players/{{ player.id }}">
95+
<img gravatar-src="stats.playersList[player.id].email || ''" gravatar-default="wavatar" gravatar-size="200" class="img-thumbnail" />
96+
</a>
97+
<h4>Top Looser</h4>
98+
<span class="text-muted">{{ player.name }} ({{ stats.statsPlayers[player.id].percentLoose }}%)</span>
99+
</div>
100+
<div ng-repeat="player in stats.statsPlayers | orderBy:'owngoal':true| minGamePlayed:stats.minGamePlayedPlayers | limitTo:1" class="col-xs-6 col-sm-3 placeholder">
101+
<a ng-href="/#/stats/players/{{ player.id }}">
102+
<img gravatar-src="stats.playersList[player.id].email || ''" gravatar-default="wavatar" gravatar-size="200" class="img-thumbnail" />
103+
</a>
104+
<h4>Top Own Goal</h4>
105+
<span class="text-muted">{{ player.name }} ({{ stats.statsPlayers[player.id].owngoal }})</span>
106+
</div>
107+
</div>
108+
</div>

app/views/partial/statsOverall.html

Lines changed: 0 additions & 37 deletions
This file was deleted.

test/e2e/babitchHome.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
'use strict';
2+
3+
var BabitchHomePage = require('./page/home.js');
4+
5+
var page = null;
6+
7+
describe('Babitch : Home', function() {
8+
9+
beforeEach(function() {
10+
browser.clearMockModules();
11+
page = new BabitchHomePage(browser);
12+
});
13+
14+
it('should display title', function() {
15+
expect(page.title.getText()).toBe('Babitch');
16+
});
17+
18+
it('should display best elo ranking player', function() {
19+
expect(page.overallStats.get(0).getText()).toBe('Best Elo Ranking');
20+
});
21+
22+
it('should display top goaler', function() {
23+
expect(page.overallStats.get(1).getText()).toBe('Top Goaler');
24+
});
25+
26+
it('should display top victory player', function() {
27+
expect(page.overallStats.get(2).getText()).toBe('Top Victory');
28+
});
29+
30+
it('should display the player who played the most', function() {
31+
expect(page.overallStats.get(3).getText()).toBe('Play the most');
32+
});
33+
34+
it('should display worst elo ranking', function() {
35+
expect(page.overallStats.get(4).getText()).toBe('Worst Elo Ranking');
36+
});
37+
38+
it('should display worst goaler', function() {
39+
expect(page.overallStats.get(5).getText()).toBe('Worst Goaler');
40+
});
41+
42+
it('should display worst top looser', function() {
43+
expect(page.overallStats.get(6).getText()).toBe('Top Looser');
44+
});
45+
46+
it('should display top own goal', function() {
47+
expect(page.overallStats.get(7).getText()).toBe('Top Own Goal');
48+
});
49+
});

test/e2e/babitchStats.js

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
var BabitchIndexPage = require('./page/index.js');
43
var BabitchStatsGamesPage = require('./page/statsGames.js');
54
var BabitchStatsGamePage = require('./page/statsGame.js');
65
var BabitchStatsPlayersPage = require('./page/statsPlayers.js');
@@ -9,37 +8,10 @@ var BabitchStatsPlayerPage = require('./page/statsPlayer.js');
98

109
var page = null;
1110

12-
describe('Babitch : Index', function() {
13-
14-
beforeEach(function() {
15-
browser.clearMockModules();
16-
page = new BabitchIndexPage(browser);
17-
});
18-
19-
it('should display title', function() {
20-
expect(page.title.getText()).toBe('Babitch');
21-
});
22-
23-
it('should display topGoaler', function() {
24-
expect(page.overallStats.get(0).getText()).toBe('Top Goaler');
25-
});
26-
27-
it('should display topVictory', function() {
28-
expect(page.overallStats.get(1).getText()).toBe('Top Victory');
29-
});
30-
31-
it('should display topOwnGoal', function() {
32-
expect(page.overallStats.get(2).getText()).toBe('Top Own Goal');
33-
});
34-
35-
it('should display topLooser', function() {
36-
expect(page.overallStats.get(3).getText()).toBe('Top Looser');
37-
});
38-
});
39-
4011
describe('Babitch : Game view', function() {
4112

4213
beforeEach(function() {
14+
browser.clearMockModules();
4315
page = new BabitchStatsGamePage(browser);
4416
});
4517

@@ -60,8 +32,6 @@ describe('Babitch : Game view', function() {
6032
expect( page.timelineGoals.count()).toBe(19);
6133
});
6234
});
63-
64-
6535
});
6636

6737
describe('Babitch : Last Games', function() {
@@ -160,5 +130,4 @@ describe('Babitch : Player view', function() {
160130
page.selectStatd3.get(2).click();
161131
expect( $$('svg').count()).toBe(1);
162132
});
163-
164133
});
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
var BabitchIndexPage = function(browser) {
1+
var BabitchHomePage = function(browser) {
22
browser.get(browser.baseUrl + '#/?nobackend');
33
this.title = $('.navbar-brand');
44
this.overallStats = $$('h4');
55
this.navbar = $$('ul.nav li')
66
this.navbarActive = $('ul.nav li.active');
77
};
88

9-
module.exports = BabitchIndexPage;
9+
module.exports = BabitchHomePage;

0 commit comments

Comments
 (0)