From 5b9f64b3f9c60c7f300d358556356f51ba68df59 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Tue, 12 Apr 2016 21:11:18 +0000 Subject: [PATCH] Created basic viewing pages in angular Can now search and view tournaments. Can now view team scores, weights and seeds, mats and bout board --- app/views/api/tournament.jbuilder | 44 ++++- frontend/app/js/app.js | 3 +- .../js/controllers/tournament-controller.js | 12 ++ .../tournaments-controller.js | 3 +- frontend/app/js/directives/loading.js | 24 +++ frontend/app/js/routes.js | 44 +++-- .../app/js/{ => services}/auth-service.js | 0 .../app/js/services/tournaments-service.js | 47 +++++ frontend/app/js/tournaments-service.js | 35 ---- frontend/app/pages/index.us | 12 +- frontend/app/pages/static_pages/about.html | 50 ++++++ frontend/app/pages/static_pages/home.html | 12 ++ .../app/pages/static_pages/tutorials.html | 21 +++ .../tournaments/tournaments-search.html} | 6 +- .../pages/tournaments/tournaments-show.html | 169 ++++++++++++++++++ frontend/config/files.js | 3 + 16 files changed, 423 insertions(+), 62 deletions(-) create mode 100644 frontend/app/js/controllers/tournament-controller.js rename frontend/app/js/{ => controllers}/tournaments-controller.js (91%) create mode 100644 frontend/app/js/directives/loading.js rename frontend/app/js/{ => services}/auth-service.js (100%) create mode 100644 frontend/app/js/services/tournaments-service.js delete mode 100644 frontend/app/js/tournaments-service.js create mode 100644 frontend/app/pages/static_pages/about.html create mode 100644 frontend/app/pages/static_pages/home.html create mode 100644 frontend/app/pages/static_pages/tutorials.html rename frontend/app/{templates/tournaments.html => pages/tournaments/tournaments-search.html} (82%) create mode 100644 frontend/app/pages/tournaments/tournaments-show.html diff --git a/app/views/api/tournament.jbuilder b/app/views/api/tournament.jbuilder index 171625c..9216cb7 100644 --- a/app/views/api/tournament.jbuilder +++ b/app/views/api/tournament.jbuilder @@ -1 +1,43 @@ -json.(@tournament, :id, :name, :address, :director, :director_email, :schools, :weights, :mats, :matches) \ No newline at end of file + +json.cache! ["api_tournament", @tournament] do + json.content(@tournament) + json.(@tournament, :id, :name, :address, :director, :director_email, :tournament_type, :created_at, :updated_at) + + json.schools @tournament.schools do |school| + json.name school.name + json.score school.score + end + + json.weights @tournament.weights do |weight| + json.id weight.id + json.max weight.max + json.bracket_size weight.bracket_size + json.wrestlers weight.wrestlers do |wrestler| + json.name wrestler.name + json.school wrestler.school.name + json.original_seed wrestler.original_seed + json.criteria wrestler.criteria + json.extra wrestler.extra + json.seasonWinPercentage wrestler.seasonWinPercentage + json.season_win wrestler.season_win + json.season_loss wrestler.season_loss + end + end + + json.mats @tournament.mats do |mat| + json.name mat.name + json.unfinishedMatches mat.unfinishedMatches do |match| + json.bout_number match.bout_number + json.w1_name match.w1_name + json.w2_name match.w2_name + end + end + + json.unassignedMatches @tournament.matches.select{|m| m.mat_id == nil}.sort_by{|m| m.bout_number}[0...9] 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 + end +end diff --git a/frontend/app/js/app.js b/frontend/app/js/app.js index 62abfd5..db68ef9 100644 --- a/frontend/app/js/app.js +++ b/frontend/app/js/app.js @@ -7,4 +7,5 @@ var app = angular.module("wrestlingdev", ["ngRoute"]).run(function($rootScope) $rootScope.alert = function(thing) { alert(thing); }; -}); \ No newline at end of file +}); + diff --git a/frontend/app/js/controllers/tournament-controller.js b/frontend/app/js/controllers/tournament-controller.js new file mode 100644 index 0000000..147281a --- /dev/null +++ b/frontend/app/js/controllers/tournament-controller.js @@ -0,0 +1,12 @@ +'use strict'; +app.controller("tournamentController", function($scope, tournamentsService, $routeParams) { + $scope.message = "Test message in scope."; + + // $scope.tournamentData = "test"; + tournamentsService.tournamentDetails($routeParams.id).then(function(data) { + //this will execute when the + //AJAX call completes. + $scope.tournament = data; + }); + +}); \ No newline at end of file diff --git a/frontend/app/js/tournaments-controller.js b/frontend/app/js/controllers/tournaments-controller.js similarity index 91% rename from frontend/app/js/tournaments-controller.js rename to frontend/app/js/controllers/tournaments-controller.js index 1efcb89..5054906 100644 --- a/frontend/app/js/tournaments-controller.js +++ b/frontend/app/js/controllers/tournaments-controller.js @@ -1,5 +1,6 @@ +'use strict'; + app.controller("tournamentsController", function($scope, tournamentsService) { - $scope.message = "Test message in scope."; tournamentsService.getAllTournaments().then(function(data) { //this will execute when the diff --git a/frontend/app/js/directives/loading.js b/frontend/app/js/directives/loading.js new file mode 100644 index 0000000..9635bea --- /dev/null +++ b/frontend/app/js/directives/loading.js @@ -0,0 +1,24 @@ +(function(){ + app.directive('usSpinner', ['$http', '$rootScope' ,function ($http, $rootScope){ + return { + link: function (scope, elm, attrs) + { + $rootScope.spinnerActive = false; + scope.isLoading = function () { + return $http.pendingRequests.length > 0; + }; + + scope.$watch(scope.isLoading, function (loading) + { + $rootScope.spinnerActive = loading; + if(loading){ + elm.removeClass('ng-hide'); + }else{ + elm.addClass('ng-hide'); + } + }); + } + }; + + }]); +}).call(this); \ No newline at end of file diff --git a/frontend/app/js/routes.js b/frontend/app/js/routes.js index 1b2f71b..2c97620 100644 --- a/frontend/app/js/routes.js +++ b/frontend/app/js/routes.js @@ -13,18 +13,32 @@ -app.config(['$routeProvider', - function($routeProvider) { - $routeProvider. - when('/tournaments', { - templateUrl: 'tournaments.html', - controller: 'tournamentsController' - }). - // when('/phones/:phoneId', { - // templateUrl: 'partials/phone-detail.html', - // controller: 'PhoneDetailCtrl' - // }). - otherwise({ - redirectTo: '/tournaments' - }); - }]); \ No newline at end of file +app.config(['$routeProvider', '$locationProvider', function($routeProvider,$locationProvider) { + + $routeProvider.when('/', { + templateUrl: 'home.html', + }); + + $routeProvider.when('/tournaments', { + templateUrl: 'tournaments-search.html', + controller: 'tournamentsController' + }); + + $routeProvider.when('/tournaments/:id', { + templateUrl: 'tournaments-show.html', + controller: 'tournamentController' + }); + + $routeProvider.when('/about', { + templateUrl: 'about.html', + }); + + $routeProvider.when('/tutorials', { + templateUrl: 'tutorials.html', + }); + + $routeProvider.otherwise({redirectTo: '/'}); + + //this give me normal routes instead of /#/ + $locationProvider.html5Mode(true); +}]); \ No newline at end of file diff --git a/frontend/app/js/auth-service.js b/frontend/app/js/services/auth-service.js similarity index 100% rename from frontend/app/js/auth-service.js rename to frontend/app/js/services/auth-service.js diff --git a/frontend/app/js/services/tournaments-service.js b/frontend/app/js/services/tournaments-service.js new file mode 100644 index 0000000..9e1083d --- /dev/null +++ b/frontend/app/js/services/tournaments-service.js @@ -0,0 +1,47 @@ + +app.factory('tournamentsService', tournamentsService); + +function tournamentsService($http){ + var service = {}; + + + + service.getAllTournaments = function(){ + return $http({ + url: '/api/tournaments/', + method: "GET" + }).then(successResponse, errorCallback); + }; + + service.searchTournaments = function(search){ + return $http({ + method: 'GET', + url: '/api/tournaments/', + params: { + search: search + } + }).then(successResponse, errorCallback); + }; + + service.tournamentDetails = function(tournamentId){ + return $http({ + url: '/api/tournaments/' + tournamentId, + method: "GET" + }).then(successResponse, errorCallback); + }; + + function successResponse(response){ + console.log("success log below"); + console.log(response); + return response.data; + } + + function errorCallback(err){ + console.log("error log below"); + console.log(err); + return err; + } + + return service; +} + diff --git a/frontend/app/js/tournaments-service.js b/frontend/app/js/tournaments-service.js deleted file mode 100644 index 4e426bd..0000000 --- a/frontend/app/js/tournaments-service.js +++ /dev/null @@ -1,35 +0,0 @@ -app.factory('tournamentsService', function($http){ - - - return { - getAllTournaments: function() { - //since $http.get returns a promise, - //and promise.then() also returns a promise - //that resolves to whatever value is returned in it's - //callback argument, we can return that. - return $http.get('/api/tournaments/').then(function(result) { - return result.data; - }); - }, - - searchTournaments: function(search){ - return $http({ - method: 'GET', - url: '/api/tournaments/', - params: { - search: search - } - }).then(function successCallback(response) { - // this callback will be called asynchronously - // when the response is available - return response.data; - }, function errorCallback(response) { - // called asynchronously if an error occurs - // or server returns response with an error status. - return response; - }); - } - }; - -}); - diff --git a/frontend/app/pages/index.us b/frontend/app/pages/index.us index 0e2a372..bf9c532 100644 --- a/frontend/app/pages/index.us +++ b/frontend/app/pages/index.us @@ -1,6 +1,7 @@ + WrestlingDev @@ -9,6 +10,8 @@ +
+
-
+
+ diff --git a/frontend/app/pages/static_pages/about.html b/frontend/app/pages/static_pages/about.html new file mode 100644 index 0000000..b4b7506 --- /dev/null +++ b/frontend/app/pages/static_pages/about.html @@ -0,0 +1,50 @@ +
+
+

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.

+
+

Features

+
+

At this moment in time, WrestlingDev supports a pool to bracket type tournament for up to 16 teams. The bracket format follows OHSAA's 5 match per day rule. WrestlingDev will automatically generate brackets, generate bout numbers, generate and update a bout board, track team points, and update brackets.

+

For pool to bracket tournaments, pool tie breakers are the following:

+
    +
  • Least team points deducted
  • +
  • Head to head
  • +
  • Most team points scored
  • +
  • Most wins by fall, default, dq
  • +
  • Most wins by tech fall
  • +
  • Most wins by major
  • +
  • Most points scored in decisions
  • +
  • Quickest pin
  • +
  • Coin flip
  • +
+

If three wrestlers are tied, they will be put through this sequence until two wrestlers are left. Once two wrestlers are left, the pool runner up will be decided by head to head.

+

For pool to bracket tournaments, team points will be calculated as follows:

+
    +
  • Pool win: 2pt
  • +
  • Win in championship bracket: 2pt
  • +
  • Win in consolation bracket: 1pt
  • +
  • Win by major: 1pt extra
  • +
  • Win by tech fall: 1.5pt extra
  • +
  • Win by fall, default, dq: 2pt extra
  • +
  • 1st place: 16pt
  • +
  • 2nd place: 12pt
  • +
  • 3rd place: 10pt
  • +
  • 4th place: 9pt
  • +
  • 5th place: 7pt
  • +
  • 6th place: 6pt
  • +
  • 7th place: 4pt
  • +
  • 8th place: 3pt
  • +
+

Finals matches will only recieve extra placement points for placing higher and bonus points for pin, tech, major, etc. Please note, only brackets with four pools place up to 8. Brackets with 1 or 2 pools only place top 4.

+
+

Future Plans

+
+

Future development plans to support normal double elimination brackets are underway and are planned to be finished in time for the 2016-2017 wrestling season.

+
+

Contact

+
+

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 new file mode 100644 index 0000000..861983e --- /dev/null +++ b/frontend/app/pages/static_pages/home.html @@ -0,0 +1,12 @@ +
+
+

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.

+
+

If you would like to run a tournament, please click log in and then click sign up.

+
+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 new file mode 100644 index 0000000..05004b0 --- /dev/null +++ b/frontend/app/pages/static_pages/tutorials.html @@ -0,0 +1,21 @@ +
+
+

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.

+
+

Planning on using this software?

+
+

Here is a list of features available:

+
+
    +
  • Pool to bracket type bracket generation for up to 16 man brackets
  • +
  • Delegate control to coaches for lineup entry
  • +
  • Automatically updated bout board
  • +
  • Automatically updated brackets
  • +
  • Automatically updated team scores
  • +
  • Delegate director privileges to multiple people for tournament administration
  • +
  • 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/templates/tournaments.html b/frontend/app/pages/tournaments/tournaments-search.html similarity index 82% rename from frontend/app/templates/tournaments.html rename to frontend/app/pages/tournaments/tournaments-search.html index d8fab1f..52d8282 100644 --- a/frontend/app/templates/tournaments.html +++ b/frontend/app/pages/tournaments/tournaments-search.html @@ -1,5 +1,3 @@ -
-

Upcoming Tournaments


@@ -20,10 +18,8 @@ - {{ tournament.name }} + {{ tournament.name }} {{ tournament.date }} -
-
\ No newline at end of file diff --git a/frontend/app/pages/tournaments/tournaments-show.html b/frontend/app/pages/tournaments/tournaments-show.html new file mode 100644 index 0000000..601d787 --- /dev/null +++ b/frontend/app/pages/tournaments/tournaments-show.html @@ -0,0 +1,169 @@ + Back to browse tournaments +

+ {{ tournament.name }} +

+

+ Address: + {{ tournament.address }} +

+

+ Director: + {{ tournament.director }} +

+

+ Director email: + {{ tournament.director_email }} +

+

+ Tournament Type: + {{ tournament.tournament_type }} +

+
+
+ +
+
+ + + + + + + + + + + + + + + +
NameScore
{{ school.name }}{{ school.score }}
+
+
+
+ +
+ +
+
+

Click weight class for seeds

+
+ + + + + + + + + + + + + + +
Weight ClassBracket Size
{{ weight.max }}{{ weight.bracket_size }}
+
+
+
+ +
+ +
+
+ + + + + + + + + + + + + + + + + + + + +
NameOn MatOn DeckIn The HoleWarm Up
{{ mat.name }}{{ mat.unfinishedMatches[0].bout_number }} {{ mat.unfinishedMatches[0].w1_name }} vs. {{ mat.unfinishedMatches[0].w2_name }}{{ mat.unfinishedMatches[1].bout_number }} {{ mat.unfinishedMatches[0].w1_name }} vs. {{ mat.unfinishedMatches[0].w2_name }}{{ mat.unfinishedMatches[2].bout_number }} {{ mat.unfinishedMatches[0].w1_name }} vs. {{ mat.unfinishedMatches[0].w2_name }}{{ mat.unfinishedMatches[3].bout_number }} {{ mat.unfinishedMatches[0].w1_name }} vs. {{ mat.unfinishedMatches[0].w2_name }}
+
+

Matches not assigned

+
+ + + + + + + + + + + + + + + + + + +
RoundBout NumberWeight ClassMatchup
Round {{ match.round }}{{ match.bout_number }}{{ match.weightClass }}{{ match.w1_name }} vs. {{ match.w2_name }}
+
+
+
+ + +
+ +
+ + + + + diff --git a/frontend/config/files.js b/frontend/config/files.js index a64ab32..255275a 100644 --- a/frontend/config/files.js +++ b/frontend/config/files.js @@ -18,6 +18,9 @@ module.exports = function(lineman) { // "vendor/js/**/*.js" // ] // } + + //Override file patterns here + }; };