From 84578d89dad59a6e3b0ca61698a34aec9c9321d7 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Tue, 26 Apr 2016 01:14:15 +0000 Subject: [PATCH] Added frontend pages and trying to model wrestlers on frontend --- app/views/api/tournament.jbuilder | 15 +++++ .../js/controllers/tournament-controller.js | 5 +- frontend/app/js/models/wrestler.js | 19 ++++++ .../app/js/services/tournaments-service.js | 4 +- frontend/app/pages/index.us | 61 +++++++++++-------- frontend/app/pages/static_pages/about.html | 4 +- frontend/app/pages/static_pages/home.html | 4 +- .../app/pages/static_pages/tutorials.html | 4 +- .../pages/tournaments/tournaments-show.html | 3 +- 9 files changed, 79 insertions(+), 40 deletions(-) create mode 100644 frontend/app/js/models/wrestler.js diff --git a/app/views/api/tournament.jbuilder b/app/views/api/tournament.jbuilder index 9216cb7..3241efb 100644 --- a/app/views/api/tournament.jbuilder +++ b/app/views/api/tournament.jbuilder @@ -13,6 +13,7 @@ json.cache! ["api_tournament", @tournament] do json.max weight.max json.bracket_size weight.bracket_size json.wrestlers weight.wrestlers do |wrestler| + json.id wrestler.id json.name wrestler.name json.school wrestler.school.name json.original_seed wrestler.original_seed @@ -27,6 +28,8 @@ json.cache! ["api_tournament", @tournament] do json.mats @tournament.mats do |mat| json.name mat.name json.unfinishedMatches mat.unfinishedMatches do |match| + json.w1 = match.w1 + json.w2 = match.w2 json.bout_number match.bout_number json.w1_name match.w1_name json.w2_name match.w2_name @@ -39,5 +42,17 @@ json.cache! ["api_tournament", @tournament] do json.w2_name match.w2_name json.weightClass match.weight.max json.round match.round + json.w1 = match.w1 + json.w2 = match.w2 + end + + json.matches @tournament.matches do |match| + json.bout_number match.bout_number + json.w1_name match.w1_name + json.w2_name match.w2_name + json.weightClass match.weight.max + json.round match.round + json.w1 = match.w1 + json.w2 = match.w2 end end diff --git a/frontend/app/js/controllers/tournament-controller.js b/frontend/app/js/controllers/tournament-controller.js index 147281a..8c09a41 100644 --- a/frontend/app/js/controllers/tournament-controller.js +++ b/frontend/app/js/controllers/tournament-controller.js @@ -1,5 +1,5 @@ 'use strict'; -app.controller("tournamentController", function($scope, tournamentsService, $routeParams) { +app.controller("tournamentController", function($scope, tournamentsService, $routeParams, Wrestler) { $scope.message = "Test message in scope."; // $scope.tournamentData = "test"; @@ -9,4 +9,7 @@ app.controller("tournamentController", function($scope, tournamentsService, $rou $scope.tournament = data; }); + $scope.wrestler = Wrestler; + + }); \ No newline at end of file diff --git a/frontend/app/js/models/wrestler.js b/frontend/app/js/models/wrestler.js new file mode 100644 index 0000000..4f45c5e --- /dev/null +++ b/frontend/app/js/models/wrestler.js @@ -0,0 +1,19 @@ +'use strict'; + +app.factory('Wrestler', function Wrestler(){ + var vm = this; + + + vm.matches = function(matches,wrestler){ + var givenWrestler = wrestler; + + console.log(givenWrestler.id); + return _.filter(matches, function(match){ + return match.w1 == givenWrestler.id || match.w2 == givenWrestler.id; + }); + + + } + + return vm; +}); \ No newline at end of file diff --git a/frontend/app/js/services/tournaments-service.js b/frontend/app/js/services/tournaments-service.js index 9e1083d..0ac1a3f 100644 --- a/frontend/app/js/services/tournaments-service.js +++ b/frontend/app/js/services/tournaments-service.js @@ -31,8 +31,8 @@ function tournamentsService($http){ }; function successResponse(response){ - console.log("success log below"); - console.log(response); + // console.log("success log below"); + // console.log(response); return response.data; } diff --git a/frontend/app/pages/index.us b/frontend/app/pages/index.us index bf9c532..8ed5e16 100644 --- a/frontend/app/pages/index.us +++ b/frontend/app/pages/index.us @@ -10,41 +10,44 @@ -
- - +
+ + +
- +
- -
+
+
+
- +
-
+ +
@@ -62,8 +65,12 @@ + + + + diff --git a/frontend/app/pages/static_pages/about.html b/frontend/app/pages/static_pages/about.html index b4b7506..0e48f2a 100644 --- a/frontend/app/pages/static_pages/about.html +++ b/frontend/app/pages/static_pages/about.html @@ -1,5 +1,4 @@ -
-
+

About WrestlingDev


WrestlingDev was created to help bring wrestling into the 21st century for free. This site is open source and is supported by the ads on the sidebar.

@@ -47,4 +46,3 @@

Suggestions, criticism, and kind words are welcomed. Please contact us.

-
\ No newline at end of file diff --git a/frontend/app/pages/static_pages/home.html b/frontend/app/pages/static_pages/home.html index 861983e..ff9797e 100644 --- a/frontend/app/pages/static_pages/home.html +++ b/frontend/app/pages/static_pages/home.html @@ -1,5 +1,4 @@ -
-
+

Welcome to WrestlingDev


This website was created to help wrestling coaches run their tournaments. It is 2015, why are we still running bout sheets to tables and why are we still using resources to push cards on a bout board? This website was created as a free way for coaches to run a tournament smoothly with as few workers as possible.

@@ -9,4 +8,3 @@ Browse Tournaments

-
\ No newline at end of file diff --git a/frontend/app/pages/static_pages/tutorials.html b/frontend/app/pages/static_pages/tutorials.html index 05004b0..2124843 100644 --- a/frontend/app/pages/static_pages/tutorials.html +++ b/frontend/app/pages/static_pages/tutorials.html @@ -1,5 +1,4 @@ -
-
+

Tutorials


Unfortunately, I do not have tutorials available at this moment in time. If you would like to learn how to use this software, please email me at jacob.wimer@gmail.com and I will gladly provide an overview of how to use this software. I've done my best to make the software intuitive and easy to use.

@@ -18,4 +17,3 @@
  • Matches can be scored at the tables and submitted via computer or bout sheets can be brought to the head table and entered there
  • -
    \ No newline at end of file diff --git a/frontend/app/pages/tournaments/tournaments-show.html b/frontend/app/pages/tournaments/tournaments-show.html index 601d787..071fb0b 100644 --- a/frontend/app/pages/tournaments/tournaments-show.html +++ b/frontend/app/pages/tournaments/tournaments-show.html @@ -1,7 +1,9 @@ + Back to browse tournaments

    {{ tournament.name }}

    +

    {{ wrestler.matches(tournament.matches,tournament.weights[0].wrestlers[0]) }}

    Address: {{ tournament.address }} @@ -166,4 +168,3 @@ -