diff --git a/Mundialito/Client/src/Constants.js b/Mundialito/Client/src/Constants.js index cda8ffc..87c0123 100644 --- a/Mundialito/Client/src/Constants.js +++ b/Mundialito/Client/src/Constants.js @@ -12,11 +12,12 @@ angular.module('mundialitoApp').constant('Constants', rowTemplate: '
', columnDefs: [ { field: 'Place', displayName: '', resizable: false, maxWidth: 30 }, - { field: 'Name', displayName: 'Name', resizable: true, minWidth: 120 }, - { field: 'Points', displayName: 'Points', resizable: true, minWidth: 45 }, + { field: 'Name', displayName: 'Name', resizable: true, minWidth: 115 }, + { field: 'Points', displayName: 'Points', resizable: true, minWidth: 45, maxWidth: 75}, + { field: 'GeneralBet.WinningTeam', displayName: 'Team', resizable: false, maxWidth: 45, cellTemplate: '
' }, + { field: 'GeneralBet.GoldenBootPlayer', displayName: 'Player', resizable: false, minWidth: 50, maxWidth: 50 }, { field: 'TotalMarks', displayName: 'Total Marks', resizable: true }, { field: 'Results', displayName: 'Results', resizable: true }, - { field: 'Marks', displayName: 'Marks', resizable: true }, { field: 'YellowCards', displayName: 'Yellow Cards Marks', resizable: true }, { field: 'Corners', displayName: 'Corners Marks', resizable: true }, { field: 'PlaceDiff', displayName: '', resizable: false, maxWidth: 45, cellTemplate: '
{{::COL_FIELD}}
' } diff --git a/Mundialito/Client/src/Dashboard/Dashboard.html b/Mundialito/Client/src/Dashboard/Dashboard.html index 8bb09e0..53dd2e3 100644 --- a/Mundialito/Client/src/Dashboard/Dashboard.html +++ b/Mundialito/Client/src/Dashboard/Dashboard.html @@ -186,50 +186,16 @@
-
General Bets - Team
+
General Bets
-
+
-
-
-
- - - - - - - - - - - - - - -
NameWinning TeamGolden Boot Player
{{bet.OwnerName}}{{teamsDic[bet.WinningTeamId].Name}}{{playersDic[bet.GoldenBootPlayerId].Name}}
-
-
-
-
-
-
-
-
-
-
-
-
General Bets - Golden Boot Player
-
-
-
-
-
+
@@ -239,13 +205,14 @@ + - + diff --git a/Mundialito/Client/src/Dashboard/DashboardCtrl.js b/Mundialito/Client/src/Dashboard/DashboardCtrl.js index 4bf87a1..7fb0af9 100644 --- a/Mundialito/Client/src/Dashboard/DashboardCtrl.js +++ b/Mundialito/Client/src/Dashboard/DashboardCtrl.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('mundialitoApp').controller('DashboardCtrl', ['$scope', '$log', 'Constants', '$location', '$timeout', 'GamesManager', 'UsersManager', 'GeneralBetsManager', 'teams', 'players', 'BetsManager', - function ($scope, $log, Constants, $location, $timeout, GamesManager, UsersManager, GeneralBetsManager, teams, players, BetsManager) { +angular.module('mundialitoApp').controller('DashboardCtrl', ['$scope', '$log', 'Constants', '$location', '$timeout', 'GamesManager', 'UsersManager', 'GeneralBetsManager', 'teams', 'players', 'BetsManager', 'MundialitoUtils', + function ($scope, $log, Constants, $location, $timeout, GamesManager, UsersManager, GeneralBetsManager, teams, players, BetsManager, MundialitoUtils) { $scope.generalBetsAreOpen = false; $scope.submittedGeneralBet = true; $scope.pendingUpdateGames = false; @@ -135,8 +135,18 @@ angular.module('mundialitoApp').controller('DashboardCtrl', ['$scope', '$log', ' }); } }); - UsersManager.getTable().then((users) => { + UsersManager.loadAllUsers().then((users) => { $scope.users = users; + $scope.users.forEach((user) => { + if (angular.isDefined(user.GeneralBet)) { + user.GeneralBet.WinningTeam = $scope.teamsDic[user.GeneralBet.WinningTeamId].Name; + user.GeneralBet.GoldenBootPlayer = MundialitoUtils.shortName($scope.playersDic[user.GeneralBet.GoldenBootPlayerId].Name); + } + }); + $scope.usersDic = users.reduce((acc, item) => { + acc[item.Id] = item; + return acc; + }, {}); }); $scope.isOpenForBetting = (item) => item.IsOpen; $scope.isPendingUpdate = (item) => item.IsPendingUpdate; @@ -157,6 +167,9 @@ angular.module('mundialitoApp').controller('DashboardCtrl', ['$scope', '$log', ' } }; + $scope.test = (grid,row) => { + return ""; } + function saveState() { var state = $scope.gridApi.saveState.save(); localStorage.setItem('gridState', state); diff --git a/Mundialito/Client/src/Games/GameCtrl.js b/Mundialito/Client/src/Games/GameCtrl.js index eb5e9cc..81112f9 100644 --- a/Mundialito/Client/src/Games/GameCtrl.js +++ b/Mundialito/Client/src/Games/GameCtrl.js @@ -1,6 +1,8 @@ 'use strict'; -angular.module('mundialitoApp').controller('GameCtrl', ['$scope', '$log', 'Constants', 'UsersManager', 'GamesManager', 'BetsManager', 'game', 'userBet', 'Alert', '$location', 'PluginsProvider', 'keyValueEditorUtils', function ($scope, $log, Constants, UsersManager, GamesManager, BetsManager, game, userBet, Alert, $location, PluginsProvider, keyValueEditorUtils) { +angular.module('mundialitoApp').controller('GameCtrl', ['$scope', '$log', 'Constants', 'UsersManager', 'GamesManager', 'BetsManager', 'game', 'userBet', 'Alert', '$location', 'PluginsProvider', 'keyValueEditorUtils', 'MundialitoUtils', 'teams', 'players', function ($scope, $log, Constants, UsersManager, GamesManager, BetsManager, game, userBet, Alert, $location, PluginsProvider, keyValueEditorUtils, MundialitoUtils, teams, players) { $scope.game = game; + $scope.teamsDic = {}; + $scope.playersDic = {}; $scope.simulatedGame = {}; $scope.plugins = {}; $scope.userBet = userBet; @@ -10,7 +12,12 @@ angular.module('mundialitoApp').controller('GameCtrl', ['$scope', '$log', 'Const return _.keys(object).map((key) => { return { 'name': key, 'value': object[key] } }); }; $scope.integrationsData = $scope.toKeyValue($scope.game.IntegrationsData); - + for (var i = 0; i < teams.length; i++) { + $scope.teamsDic[teams[i].TeamId] = teams[i]; + } + for (var i = 0; i < players.length; i++) { + $scope.playersDic[players[i].PlayerId] = players[i]; + } PluginsProvider.getGameDetailsFromAll($scope.game).then((results) => { results.forEach((result) => { $scope.plugins[result.property] = { data: result.data, template: result.template }; @@ -21,7 +28,6 @@ angular.module('mundialitoApp').controller('GameCtrl', ['$scope', '$log', 'Const BetsManager.getGameBets($scope.game.GameId).then((data) => { $log.debug("GameCtrl: get game bets" + angular.toJson(data)); $scope.gameBets = data; - var chart1 = {}; chart1.type = "PieChart"; chart1.options = { @@ -84,6 +90,12 @@ angular.module('mundialitoApp').controller('GameCtrl', ['$scope', '$log', 'Const $log.debug('GameCtrl: simulating game'); GamesManager.simulateGame($scope.game.GameId, $scope.simulatedGame).then((data) => { $scope.users = data; + $scope.users.forEach((user) => { + if (angular.isDefined(user.GeneralBet)) { + user.GeneralBet.WinningTeam = $scope.teamsDic[user.GeneralBet.WinningTeamId].Name; + user.GeneralBet.GoldenBootPlayer = MundialitoUtils.shortName($scope.playersDic[user.GeneralBet.GoldenBootPlayerId].Name); + } + }); Alert.success('Table updated with simulation result'); }).catch((err) => { Alert.error('Failed to simulate game, please try again'); @@ -135,7 +147,7 @@ angular.module('mundialitoApp').controller('GameCtrl', ['$scope', '$log', 'Const return $scope.usersMap.get(user.Username).Place; } $scope.$watch('simulatedGame', () => { $scope.users = undefined }, true); - UsersManager.getTable().then((users) => { + UsersManager.loadAllUsers().then((users) => { $scope.usersMap = new Map(); users.forEach((obj) => { $scope.usersMap.set(obj.Username, obj); diff --git a/Mundialito/Client/src/Games/gamesTemplate.html b/Mundialito/Client/src/Games/gamesTemplate.html index 5c1e6bd..70877eb 100644 --- a/Mundialito/Client/src/Games/gamesTemplate.html +++ b/Mundialito/Client/src/Games/gamesTemplate.html @@ -4,10 +4,10 @@
-
+
-
+
Pending Update
@@ -16,7 +16,7 @@
-
-
+
NamePoints Winning Team Golden Boot Player
{{bet.OwnerName}}{{usersDic[bet.OwnerId].Points}} {{teamsDic[bet.WinningTeamId].Name}} {{playersDic[bet.GoldenBootPlayerId].Name}}
- - - - - - - - - - - - - -
NameWinning TeamGolden Boot Player
{{bet.OwnerName}}{{teamsDic[bet.WinningTeamId].Name}}{{playersDic[bet.GoldenBootPlayerId].Name}}
-
-
-
-
-
-
-
-
-
-
-
-
General Bets - Golden Boot Player
-
-
-
-
-
+
@@ -239,13 +205,14 @@ + - + diff --git a/Mundialito/wwwroot/App/Games/gamesTemplate.html b/Mundialito/wwwroot/App/Games/gamesTemplate.html index f6bb587..8bcfd4c 100644 --- a/Mundialito/wwwroot/App/Games/gamesTemplate.html +++ b/Mundialito/wwwroot/App/Games/gamesTemplate.html @@ -4,10 +4,10 @@
-
+
-
+
Pending Update
@@ -16,7 +16,7 @@
-
-
+
NamePoints Winning Team Golden Boot Player
{{bet.OwnerName}}{{usersDic[bet.OwnerId].Points}} {{teamsDic[bet.WinningTeamId].Name}} {{playersDic[bet.GoldenBootPlayerId].Name}}