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 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.
+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:
+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:
+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 development plans to support normal double elimination brackets are underway and are planned to be finished in time for the 2016-2017 wrestling season.
+Suggestions, criticism, and kind words are welcomed. Please contact us.
+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.
+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.
+Here is a list of features available:
++ Address: + {{ tournament.address }} +
++ Director: + {{ tournament.director }} +
++ Director email: + {{ tournament.director_email }} +
++ Tournament Type: + {{ tournament.tournament_type }} +
+| Name | +Score | +
|---|---|
| {{ school.name }} | +{{ school.score }} | +
Click weight class for seeds
+| Weight Class | +Bracket Size | +
|---|---|
| {{ weight.max }} | +{{ weight.bracket_size }} | +
| Name | +On Mat | +On Deck | +In The Hole | +Warm 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 }} | +
| Round | +Bout Number | +Weight Class | +Matchup | +
|---|---|---|---|
| Round {{ match.round }} | +{{ match.bout_number }} | +{{ match.weightClass }} | +{{ match.w1_name }} vs. {{ match.w2_name }} | +