Skip to content

Commit

Permalink
added
Browse files Browse the repository at this point in the history
  • Loading branch information
ezraroi committed Jul 7, 2024
1 parent 31260d6 commit 2ff9725
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 45 deletions.
21 changes: 1 addition & 20 deletions Mundialito/Client/src/Games/GameCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,31 +186,12 @@ angular.module('mundialitoApp').controller('GameCtrl', ['$scope', '$log', 'Const

function storeTeamForm(games, teamId) {
const form = _.chain(games).sortBy((game) => new Date(game.Date)).filter((game) => game.IsBetResolved).map((game) => {
return getGameMark(game, teamId);
return MundialitoUtils.getGameMark(game, teamId);
}).value();
$scope.teamsForm[teamId] = {
form : form,
games: _.filter(games, (game) => game.IsBetResolved)
}
}

function getGameMark(res, teamId) {
if (res.HomeTeam.TeamId === teamId) {
if (res.HomeScore > res.AwayScore) {
return { game : res.GameId, mark : "W" };
} else if (res.HomeScore < res.AwayScore) {
return { game : res.GameId, mark : "L" };
}
return { game : res.GameId, mark : "D" };
} else {
if (res.HomeScore > res.AwayScore) {
return { game : res.GameId, mark : "L" };
} else if (res.HomeScore < res.AwayScore) {
return { game : res.GameId, mark : "W" };
}
return { game : res.GameId, mark : "D" };
}
}

$scope.loadTeamsForm();
}]);
17 changes: 17 additions & 0 deletions Mundialito/Client/src/General/MundialitoUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ angular.module('mundialitoApp').factory('MundialitoUtils', [ 'Constants', functi
return temp[0].substring(0, 1) + '.' + temp[1].substring(0, 1);
}
return name.substring(0, 1);
},
getGameMark: (res, teamId) => {
if (res.HomeTeam.TeamId === teamId) {
if (res.HomeScore > res.AwayScore) {
return { game : res.GameId, mark : "W" };
} else if (res.HomeScore < res.AwayScore) {
return { game : res.GameId, mark : "L" };
}
return { game : res.GameId, mark : "D" };
} else {
if (res.HomeScore > res.AwayScore) {
return { game : res.GameId, mark : "L" };
} else if (res.HomeScore < res.AwayScore) {
return { game : res.GameId, mark : "W" };
}
return { game : res.GameId, mark : "D" };
}
}
};

Expand Down
5 changes: 4 additions & 1 deletion Mundialito/Client/src/Teams/Team.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ <h5 ng-show="team.TeamPage !== null"><a target="_blank" ng-href="{{team.TeamPage
<div class="row">
<div class="col-md-12">
<div class="panel panel-success" cg-busy="{tracker:'getTeamGames'}">
<div class="panel-heading">{{team.Name}} Games</div>
<div class="panel-heading">
<i ng-class="['flag','flag-fifa-{{team.ShortName | lowercase}}']"
title=" {{team.Name}}"></i> {{team.Name}} Games <span ng-repeat="mark in teamsForm[team.TeamId].form"><span ng-class="{'label-success': mark.mark === 'W', 'label-default': mark.mark === 'D', 'label-danger': mark.mark === 'L'}" class="label">{{mark.mark}}</span> </span>
</div>
<div class="panel-body">
<mundialito-games info="games" show-only="true"></mundialito-games>
</div>
Expand Down
10 changes: 9 additions & 1 deletion Mundialito/Client/src/Teams/TeamCtrl.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use strict';
angular.module('mundialitoApp').controller('TeamCtrl', ['$scope', '$log', 'TeamsManager', 'team', 'games', 'Alert', 'PluginsProvider', function ($scope, $log, TeamsManager, team, games, Alert, PluginsProvider) {
angular.module('mundialitoApp').controller('TeamCtrl', ['$scope', '$log', 'TeamsManager', 'team', 'games', 'Alert', 'PluginsProvider', 'MundialitoUtils', function ($scope, $log, TeamsManager, team, games, Alert, PluginsProvider, MundialitoUtils) {
$scope.team = team;
$scope.games = games;
$scope.plugins = {};
$scope.teamsForm = {};
$scope.showEditForm = false;
$scope.toKeyValue = (object) => {
return _.keys(object).map((key) => { return { 'name': key, 'value': object[key] } });
Expand All @@ -18,6 +19,13 @@ angular.module('mundialitoApp').controller('TeamCtrl', ['$scope', '$log', 'Teams
return res;
};

const form = _.chain($scope.games).sortBy((game) => new Date(game.Date)).filter((game) => game.IsBetResolved).map((game) => {
return MundialitoUtils.getGameMark(game, $scope.team.TeamId);
}).value();
$scope.teamsForm[$scope.team.TeamId] = {
form : form,
games: _.filter($scope.games, (game) => game.IsBetResolved)
}
PluginsProvider.getTeamDetailsFromAll($scope.team).then((results) => {
results.forEach((result) => {
$scope.plugins[result.property] = { data: result.data, template: result.template };
Expand Down
5 changes: 4 additions & 1 deletion Mundialito/wwwroot/App/Teams/Team.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ <h5 ng-show="team.TeamPage !== null"><a target="_blank" ng-href="{{team.TeamPage
<div class="row">
<div class="col-md-12">
<div class="panel panel-success" cg-busy="{tracker:'getTeamGames'}">
<div class="panel-heading">{{team.Name}} Games</div>
<div class="panel-heading">
<i ng-class="['flag','flag-fifa-{{team.ShortName | lowercase}}']"
title=" {{team.Name}}"></i> {{team.Name}} Games <span ng-repeat="mark in teamsForm[team.TeamId].form"><span ng-class="{'label-success': mark.mark === 'W', 'label-default': mark.mark === 'D', 'label-danger': mark.mark === 'L'}" class="label">{{mark.mark}}</span> </span>
</div>
<div class="panel-body">
<mundialito-games info="games" show-only="true"></mundialito-games>
</div>
Expand Down
2 changes: 1 addition & 1 deletion Mundialito/wwwroot/js/app-min.js

Large diffs are not rendered by default.

48 changes: 27 additions & 21 deletions Mundialito/wwwroot/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1044,32 +1044,13 @@ angular.module('mundialitoApp').controller('GameCtrl', ['$scope', '$log', 'Const

function storeTeamForm(games, teamId) {
const form = _.chain(games).sortBy((game) => new Date(game.Date)).filter((game) => game.IsBetResolved).map((game) => {
return getGameMark(game, teamId);
return MundialitoUtils.getGameMark(game, teamId);
}).value();
$scope.teamsForm[teamId] = {
form : form,
games: _.filter(games, (game) => game.IsBetResolved)
}
}

function getGameMark(res, teamId) {
if (res.HomeTeam.TeamId === teamId) {
if (res.HomeScore > res.AwayScore) {
return { game : res.GameId, mark : "W" };
} else if (res.HomeScore < res.AwayScore) {
return { game : res.GameId, mark : "L" };
}
return { game : res.GameId, mark : "D" };
} else {
if (res.HomeScore > res.AwayScore) {
return { game : res.GameId, mark : "L" };
} else if (res.HomeScore < res.AwayScore) {
return { game : res.GameId, mark : "W" };
}
return { game : res.GameId, mark : "D" };
}
}

$scope.loadTeamsForm();
}]);
'use strict';
Expand Down Expand Up @@ -1462,6 +1443,23 @@ angular.module('mundialitoApp').factory('MundialitoUtils', [ 'Constants', functi
return temp[0].substring(0, 1) + '.' + temp[1].substring(0, 1);
}
return name.substring(0, 1);
},
getGameMark: (res, teamId) => {
if (res.HomeTeam.TeamId === teamId) {
if (res.HomeScore > res.AwayScore) {
return { game : res.GameId, mark : "W" };
} else if (res.HomeScore < res.AwayScore) {
return { game : res.GameId, mark : "L" };
}
return { game : res.GameId, mark : "D" };
} else {
if (res.HomeScore > res.AwayScore) {
return { game : res.GameId, mark : "L" };
} else if (res.HomeScore < res.AwayScore) {
return { game : res.GameId, mark : "W" };
}
return { game : res.GameId, mark : "D" };
}
}
};

Expand Down Expand Up @@ -2055,10 +2053,11 @@ angular.module('mundialitoApp').factory('Team', ['$http','$log', function($http,
}]);

'use strict';
angular.module('mundialitoApp').controller('TeamCtrl', ['$scope', '$log', 'TeamsManager', 'team', 'games', 'Alert', 'PluginsProvider', function ($scope, $log, TeamsManager, team, games, Alert, PluginsProvider) {
angular.module('mundialitoApp').controller('TeamCtrl', ['$scope', '$log', 'TeamsManager', 'team', 'games', 'Alert', 'PluginsProvider', 'MundialitoUtils', function ($scope, $log, TeamsManager, team, games, Alert, PluginsProvider, MundialitoUtils) {
$scope.team = team;
$scope.games = games;
$scope.plugins = {};
$scope.teamsForm = {};
$scope.showEditForm = false;
$scope.toKeyValue = (object) => {
return _.keys(object).map((key) => { return { 'name': key, 'value': object[key] } });
Expand All @@ -2074,6 +2073,13 @@ angular.module('mundialitoApp').controller('TeamCtrl', ['$scope', '$log', 'Teams
return res;
};

const form = _.chain($scope.games).sortBy((game) => new Date(game.Date)).filter((game) => game.IsBetResolved).map((game) => {
return MundialitoUtils.getGameMark(game, $scope.team.TeamId);
}).value();
$scope.teamsForm[$scope.team.TeamId] = {
form : form,
games: _.filter($scope.games, (game) => game.IsBetResolved)
}
PluginsProvider.getTeamDetailsFromAll($scope.team).then((results) => {
results.forEach((result) => {
$scope.plugins[result.property] = { data: result.data, template: result.template };
Expand Down

0 comments on commit 2ff9725

Please sign in to comment.