diff --git a/css/app.css b/css/app.css new file mode 100644 index 0000000..a4e5322 --- /dev/null +++ b/css/app.css @@ -0,0 +1,16 @@ +body { + padding-top: 58px; + overflow-x: hidden; +} + +.breadcrumbddd { + position: fixed; + top: 56px; + display: inline-block; + z-index: 1030; +} + +.large-glyph { + font-size : 24px; + color:lightgray; +} diff --git a/index.html b/index.html index caaff43..20a11c9 100644 --- a/index.html +++ b/index.html @@ -7,83 +7,69 @@ - - + + - - - + + + - - TimeY - Time Yourself! - + + Race manager + - - - - + + + + - - - - - - + + - - - - - - + + + + + + + - + + + + + + - + - - + + + + -
+
- - + + diff --git a/js/app.js b/js/app.js index 07d532e..80971de 100644 --- a/js/app.js +++ b/js/app.js @@ -9,7 +9,7 @@ angular.module('bananaraceApp', [ 'bananaraceApp.directives', 'bananaraceApp.controllers', // // 'textAngular', - // 'ngCookies', + 'ngCookies', 'angular-md5', // 'ui.bootstrap', // 'cfp.hotkeys', @@ -20,9 +20,14 @@ angular.module('bananaraceApp', [ config(['$routeProvider', function($routeProvider) { // $routeProvider.when('/news', {templateUrl: 'partials/news.html', controller: 'NewsCtrl'}); // $routeProvider.when('/view2', {templateUrl: 'partials/partial2.html', controller: 'MyCtrl2'}); - $routeProvider.when('/championships', {templateUrl: 'partials/championships.html', controller: 'ChampionshipCtrl'}); - $routeProvider.when('/teams/:idchampionship', {templateUrl: 'partials/teams.html', controller: 'TeamCtrl'}); - $routeProvider.when('/poules/:idchampionship', {templateUrl: 'partials/poules.html', controller: 'PouleCtrl'}); + $routeProvider.when('/championships', {templateUrl: 'partials/championships.html', controller: 'ChampionshipsCtrl'}); + $routeProvider.when('/championship/:idchampionship/poules', {templateUrl: 'partials/championship-poules.html', controller: 'ChampionshipCtrl'}); + $routeProvider.when('/championship/:idchampionship/poule/:tier/:poule/races', {templateUrl: 'partials/championship-poule-races.html', controller: 'PouleCtrl'}); + $routeProvider.when('/championship/:idchampionship/poule/:tier/:poule/teams', {templateUrl: 'partials/championship-poule-teams.html', controller: 'PouleCtrl'}); + $routeProvider.when('/championship/:idchampionship/poule/:tier/:poule/race/:idrace/drives', {templateUrl: 'partials/championship-poule-race-drives.html', controller: 'RaceCtrl'}); + $routeProvider.when('/championship/:idchampionship/teams', {templateUrl: 'partials/championship-teams.html', controller: 'TeamCtrl'}); + $routeProvider.when('/championship/:idchampionship/team/:idteam/drivers', {templateUrl: 'partials/championship-team-drivers.html', controller: 'DriverCtrl'}); + $routeProvider.when('/login', {templateUrl: 'partials/login.html', controller: 'LoginCtrl'}); $routeProvider.when('/register', {templateUrl: 'partials/register.html', controller: 'RegisterCtrl'}); // $routeProvider.when('/member', {templateUrl: 'partials/member.html', controller: 'MemberCtrl'}); @@ -30,3 +35,14 @@ config(['$routeProvider', function($routeProvider) { }]); //$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8'; +/* +/championships/:cid/teams +/championships/:cid/teams/:tid +/championships/:cid/poules +/championships/:cid/poules/:pid +/championships/:cid/poules/:pid/races +/championships/:cid/poules/:pid/races/:rid +/teams +/teams/:tid +/users +/users/:uid */ diff --git a/js/controllers.js b/js/controllers.js index e77772b..1a4be36 100644 --- a/js/controllers.js +++ b/js/controllers.js @@ -4,9 +4,7 @@ var mod = angular.module('bananaraceApp.controllers', ['bananaraceApp.services']); - - -mod.controller('ChampionshipCtrl', ['$scope', 'ChampionshipService', function($scope, ChampionshipService) { +mod.controller('ChampionshipsCtrl', ['$scope', 'ChampionshipService', function($scope, ChampionshipService) { var championships = []; $scope.refreshChampionships = function() { @@ -25,15 +23,6 @@ mod.controller('ChampionshipCtrl', ['$scope', 'ChampionshipService', function($s }); }; - $scope.setSelectedChampionship = function(championship) { - $scope.selectedChampionship = championship; - console.log('selected: '+championship.name); - }; - - $scope.isSelectedChampionship = function(championship) { - return championship == $scope.selectedChampionship; - }; - $scope.deleteChampionship = function(championship) { ChampionshipService.deleteChampionship(championship). success(function(data, status, headers, config) { @@ -69,10 +58,106 @@ mod.controller('ChampionshipCtrl', ['$scope', 'ChampionshipService', function($s $scope.refreshChampionships(); }]); -mod.controller('PouleCtrl', ['$scope', '$routeParams', 'PouleService', function($scope, $routeParams, PouleService) { + +mod.controller('RaceCtrl', ['$scope', '$routeParams', 'RaceService', function($scope, $routeParams, RaceService) { + //fetch all drives for the current race + var drives = []; + + //set route params in scope variables + $scope.currentChampionship = $routeParams.idchampionship; + $scope.currentTier = $routeParams.tier; + $scope.currentPoule = $routeParams.poule; + $scope.currentRace = $routeParams.idrace; + + //possible lapamounts + $scope.lapamounts = [1,2,3,4,5]; + //initial selection + $scope.selectedLapamount = 2; + + $scope.setSelectedLapamount = function(amount) { + $scope.selectedLapamount = amount; + } + + $scope.refreshDrives = function() { + console.log('doing refreshRaces'); + RaceService.getDrives($scope.currentRace). + success(function(data, status, headers, config) { + console.log('refreshDrives successful...'); + console.log(data); + if(data['ok']==true) { + $scope.drives = data.drives; + } else { + } + }). + error(function(data, status, headers, config) { + console.log('refreshDrives failed...'); + }); + }; + + $scope.refreshTeam = function() { + RaceService.getTeam($scope.currentRace). + success(function(data, status, headers, config) { + console.log('refreshTeam successful...'); + console.log(data); + if(data['ok']==true) { + $scope.team = data.team; + if(data.team.drivers.length > 0) { + $scope.selectedDriver = data.team.drivers[0]; + } + } else { + } + }). + error(function(data, status, headers, config) { + console.log('refreshDrivers failed...'); + }); + }; + + $scope.setSelectedDriver = function(driver) { + $scope.selectedDriver = driver; + }; + + $scope.addDrive = function() { + RaceService.addDrive($scope.currentRace, $scope.selectedDriver, $scope.selectedLapamount). + success(function(data, status, headers, config) { + console.log('addDrive successful...'); + console.log(data); + if(data['ok']==true) { + $scope.refreshDrives(); + } else { + } + }). + error(function(data, status, headers, config) { + console.log('addDrive failed...'); + }); + }; + + $scope.deleteDrive = function(drivenr, idrace) { + RaceService.deleteDrive(drivenr, idrace). + success(function(data, status, headers, config) { + console.log('deleteDrive successful...'); + console.log(data); + if(data['ok']==true) { + $scope.refreshDrives(); + } else { + } + }). + error(function(data, status, headers, config) { + console.log('deleteDrive failed...'); + }); + }; + + + $scope.refreshDrives(); + $scope.refreshTeam(); +}]); + +mod.controller('ChampionshipCtrl', ['$scope', '$routeParams', 'PouleService', 'TeamService', function($scope, $routeParams, PouleService, TeamService) { //fetch all poules for the given championship var poules = []; + //set scope vars + $scope.currentChampionship = $routeParams.idchampionship; + $scope.refreshPoules = function() { var idchampionship = $routeParams.idchampionship; console.log('doing refreshPoules'); @@ -91,8 +176,7 @@ mod.controller('PouleCtrl', ['$scope', '$routeParams', 'PouleService', function( }; $scope.addPoule = function(newpoule) { - var idchampionship = $routeParams.idchampionship; - PouleService.addPoule(newpoule, idchampionship). + PouleService.addPoule(newpoule, $scope.currentChampionship). success(function(data, status, headers, config) { console.log('addPoule successful...'); console.log(data); @@ -108,22 +192,298 @@ mod.controller('PouleCtrl', ['$scope', '$routeParams', 'PouleService', function( );; }; + //do initial refresh of poules $scope.refreshPoules(); }]); -mod.controller('TeamCtrl', ['$scope', '$routeParams', 'TeamService', function($scope, $routeParams, TeamService) { - //fetch all poules for the given championship - var teams = []; - $scope.refreshTeams = function() { - console.log('doing refreshTeams'); + + + + + +mod.controller('PouleCtrl', ['$scope', '$routeParams', 'PouleService', 'TeamService', 'MainService', function($scope, $routeParams, PouleService, TeamService, MainService) { + + $scope.currentChampionship = $routeParams.idchampionship; + $scope.currentTier = $routeParams.tier; + $scope.currentPoule = $routeParams.poule; + $scope.activeIdRace = null; + + $scope.addTeamToPoule = function(team) { var idchampionship = $routeParams.idchampionship; - TeamService.getTeams(idchampionship). + var tier = $routeParams.tier; + var poule = $routeParams.poule; + PouleService.addTeam(team, idchampionship, tier, poule). + success(function(data, status, headers, config) { + console.log('added team to poule...'); + if(data['ok']==true) { + $scope.refreshTeamsForPoule(); + $scope.refreshTeamsAvailableForPoule(); + } + }). + error(function(data, status, headers, config) { + console.log('addPoule failed...'); + } + ); + }; + + $scope.removeTeamFromPoule = function(team) { + var idchampionship = $routeParams.idchampionship; + var tier = $routeParams.tier; + var poule = $routeParams.poule; + PouleService.removeTeam(team, idchampionship, tier, poule). + success(function(data, status, headers, config) { + console.log('added team to poule...'); + if(data['ok']==true) { + $scope.refreshTeamsForPoule(); + $scope.refreshTeamsAvailableForPoule(); + } + }). + error(function(data, status, headers, config) { + console.log('addPoule failed...'); + } + ); + }; + + $scope.refreshTeamsForPoule = function() { + var idchampionship = $routeParams.idchampionship; + var tier = $routeParams.tier; + var poule = $routeParams.poule; + console.log('TeamCtrl refreshing team in poule'); + + TeamService.getTeamsInPoule(idchampionship, tier, poule). success(function(data, status, headers, config) { - console.log('refreshTeams successful...'); + console.log('getTeamsInPoule successful...'); console.log(data); if(data['ok']==true) { - $scope.teams = data.teams; + $scope.teamsInPoule = data.teams; + //set first to be selected + $scope.selectedTeam = data.teams[0]; + } else { + console.log('call returned but wasnt ok: '+data['error']); + } + }). + error(function(data, status, headers, config) { + console.log('getTeamsInPoule failed...'); + }); + }; + + $scope.refreshTeamsAvailableForPoule = function() { + var idchampionship = $routeParams.idchampionship; + var tier = $routeParams.tier; + var poule = $routeParams.poule; + console.log('TeamCtrl refreshing team in poule'); + + TeamService.getTeamsAvailableForPoule(idchampionship, tier, poule). + success(function(data, status, headers, config) { + console.log('refreshTeamsAvailableForPoule successful...'); + console.log(data); + if(data['ok']==true) { + $scope.teamsAvailableForPoule = data.teams; + } else { + console.log('call returned but wasnt ok: '+data['error']); + } + }). + error(function(data, status, headers, config) { + console.log('getTeamsInPoule failed...'); + }); + }; + + $scope.setSelectedTeam = function(team) { + $scope.selectedTeam = team; + console.log('team is selected: '+team); + }; + + $scope.addRace = function() { + var idchampionship = $routeParams.idchampionship; + var tier = $routeParams.tier; + var poule = $routeParams.poule; + var selectedTeam = $scope.selectedTeam; + + PouleService.addRace(idchampionship, tier, poule, selectedTeam.idteam). + success(function(data, status, headers, config) { + console.log('addRace successful...'); + console.log(data); + if(data['ok']==true) { + $scope.refreshRaces(); + } + }). + error(function(data, status, headers, config) { + console.log('addRace failed...'); + } + );; + }; + + $scope.deleteRace = function(race) { + var idchampionship = $routeParams.idchampionship; + var tier = $routeParams.tier; + var poule = $routeParams.poule; + console.log('PouleCtrl deleting race'); + + PouleService.deleteRace(idchampionship, tier, poule, race.idrace). + success(function(data, status, headers, config) { + console.log('deleteRace call successful...'); + console.log(data); + if(data['ok']==true) { + $scope.refreshRaces(); + } else { + console.log('deleteRace call returned but wasnt ok: '+data['error']); + } + }). + error(function(data, status, headers, config) { + console.log('deleteRace failed...'); + }); + }; + + $scope.refreshRaces = function() { + var idchampionship = $routeParams.idchampionship; + var tier = $routeParams.tier; + var poule = $routeParams.poule; + console.log('PouleCtrl refreshing races'); + + PouleService.getRacesInPoule(idchampionship, tier, poule). + success(function(data, status, headers, config) { + console.log('getRacesInPoule successful...'); + console.log(data); + if(data['ok']==true) { + $scope.racesInPoule = data.races; + } else { + console.log('getRacesInPoule call returned but wasnt ok: '+data['error']); + } + }). + error(function(data, status, headers, config) { + console.log('getTeamsInPoule failed...'); + }); + }; + + $scope.toggleActiveRace = function(race) { + var idchampionship = $routeParams.idchampionship; + var tier = $routeParams.tier; + var poule = $routeParams.poule; + MainService.toggleActiveRace(race.idrace, tier, poule, idchampionship); + }; + + $scope.getActiveRace = function() { + return MainService.getActiveRace(); + }; + + $scope.addRaceForAllteams = function() { + var idchampionship = $routeParams.idchampionship; + var tier = $routeParams.tier; + var poule = $routeParams.poule; + for(var i = 0; i<$scope.teamsInPoule.length; i++) { + PouleService.addRace(idchampionship, tier, poule, $scope.teamsInPoule[i].idteam). + success(function(data, status, headers, config) { + $scope.refreshRaces();; + }); + // this.addRace = function(idchampionship, tier, poule, idteam) { + } + }; + + $scope.$on('activeIdRaceChanged', function(event, message) { + //the raceid changed! + $scope.activeIdRace = message; + }); + + $scope.refreshTeamsForPoule(); + $scope.refreshTeamsAvailableForPoule(); + $scope.refreshRaces(); +}]); + + + + + + + + + + + + + + + + mod.controller('TeamCtrl', ['$scope', '$routeParams', 'TeamService', function($scope, $routeParams, TeamService) { + //fetch all poules for the given championship + var teams = []; + + $scope.currentChampionship = $routeParams.idchampionship; + + $scope.refreshTeams = function() { + console.log('doing refreshTeams'); + var idchampionship = $routeParams.idchampionship; + TeamService.getTeams(idchampionship). + success(function(data, status, headers, config) { + console.log('refreshTeams successful...'); + console.log(data); + if(data['ok']==true) { + $scope.teams = data.teams; + } else { + } + }). + error(function(data, status, headers, config) { + console.log('refreshTeams failed...'); + }); + }; + + $scope.addTeam = function(newteam) { + var idchampionship = $routeParams.idchampionship; + console.log('controller adding team... '+idchampionship); + TeamService.addTeam(newteam, idchampionship). + success(function(data, status, headers, config) { + console.log(data); + if(data['ok']==true) { + $scope.refreshTeams(); + newteam.name = ""; + } + }). + error(function(data, status, headers, config) { + console.log('addTeam failed...'); + } + );; + }; + + $scope.deleteTeam = function(team) { + var idchampionship = $routeParams.idchampionship; + console.log('controller deleting team...'); + TeamService.deleteTeam(team, idchampionship). + success(function(data, status, headers, config) { + console.log(data); + if(data['ok']==true) { + $scope.refreshTeams(); + } + }). + error(function(data, status, headers, config) { + console.log('deleteTeam failed...'); + } + ); + }; + + + + + $scope.refreshTeams(); +}]); + + +mod.controller('DriverCtrl', ['$scope', '$routeParams', 'DriverService', function($scope, $routeParams, DriverService) { + //fetch all drivers for the given team + var drivers = []; + + $scope.currentTeam = $routeParams.idteam; + $scope.currentChampionship = $routeParams.idchampionship; + + $scope.refreshDrivers = function() { + console.log('doing refreshTeams'); + var idchampionship = $routeParams.idchampionship; + var idteam = $routeParams.idteam; + DriverService.getDrivers(idchampionship, idteam). + success(function(data, status, headers, config) { + console.log('refreshDrivers successful...'); + console.log(data); + if(data['ok']==true) { + $scope.drivers = data.drivers; } else { } }). @@ -132,730 +492,66 @@ mod.controller('TeamCtrl', ['$scope', '$routeParams', 'TeamService', function($s }); }; - $scope.addTeam = function(newteam) { + $scope.addDriver = function(newdriver) { var idchampionship = $routeParams.idchampionship; - TeamService.addTeam(newteam, idchampionship). + var idteam = $routeParams.idteam; + console.log('controller adding driver... '+idchampionship+' '+idteam); + DriverService.addDriver(newdriver, idchampionship, idteam). success(function(data, status, headers, config) { - console.log('addTeam successful...'); console.log(data); if(data['ok']==true) { - $scope.refreshTeams(); - newteam.name = ""; + $scope.refreshDrivers(); + newdriver.name = ""; } }). error(function(data, status, headers, config) { - console.log('addTeam failed...'); + console.log('addDriver failed...'); } );; }; - $scope.refreshTeams(); + $scope.deleteDriver = function(driver) { + var idchampionship = $routeParams.idchampionship; + var idteam = $routeParams.idteam; + console.log('controller deleting driver... '); + console.log(driver); + DriverService.deleteDriver(driver). + success(function(data, status, headers, config) { + console.log(data); + if(data['ok']==true) { + $scope.refreshDrivers(); + } + }). + error(function(data, status, headers, config) { + console.log('deleteDriver failed...'); + } + ); + }; + + $scope.refreshDrivers(); }]); +mod.controller('NavCtrl', ['$scope', '$location', 'MainService', function ($scope, $location, MainService) { -// STOPWATCH CONTROLLER -mod.controller('StopwatchCtrl', ['$scope', 'StopwatchService', 'TemplateBackendService', 'hotkeys', function($scope, StopwatchService, TemplateBackendService, hotkeys) { - //set the interval in ms to 0ms - $scope.intervalValue = StopwatchService.getValue(); - //set the current templates: this can be refreshed when necessary. initialise with first call. - $scope.templates = refreshTemplates(); - //keep image of the current lefas here... update when necessary! - $scope.currentTemplateItems = StopwatchService.getCurrentTemplateItems(); - $scope.templateItemIndex = StopwatchService.currentlyRunningTemplateItemIndex(); - //get the current time - var stopwatchUpdateTimer; - - hotkeys.add({ - combo: 'space', - description: 'Tap to function... press space!', - callback: function(event, hotkey) { - console.log('pressed space'); - $scope.tap(); - event.preventDefault(); - } - }); - - - //keep track of leafs - //leaf1 - leaf2 - leaf3 - ... - //overall timer - //leaf timer - - //events (taps) - //start sequence - //end leaf1 (add timing) - //end leaf2 (add timing) - //final leaf done? end sequence -> save timings - - $scope.getCurrentStopwatchValue = function() { - return StopwatchService.getValue(); + $scope.loggedIn = function() { + return LoginService.isLoggedIn(); }; - $scope.readyForTapping = function() { - var currentTemplate = StopwatchService.getActiveTemplate(); - var ready = currentTemplate != null; - return ready; + $scope.getActiveCss = function (path) { + // console.log('get activecss: '+path+' '+$location.path()); + var ok = $location.path().indexOf(path) != -1; + return { + active: ok + }; }; - $scope.getActiveTemplate = function() { - return StopwatchService.getActiveTemplate(); - } - - $scope.tap = function() { - if(StopwatchService.isRunning()===false) { - //start refreshing timer! - stopwatchUpdateTimer = setInterval( - function () { - fireStopwatchTimer(); - }, 10); - } - - //now tap the thing - StopwatchService.tap(); - - $scope.templateItemIndex = StopwatchService.currentlyRunningTemplateItemIndex(); - - //if, after the tap, the timer isn't running: we stopped! stop listening - if(StopwatchService.isRunning()===false) { - console.log('clearing timeout!'); - clearTimeout(stopwatchUpdateTimer); - - //save the timings!? - //make assoc array for the timings - var currentTemplateItems = StopwatchService.getCurrentTemplateItems(); - var currentTemplateid = StopwatchService.getActiveTemplate().idtemplate; - - //just push them all to the database: everything is filled in - //save it to db - TemplateBackendService.saveTiming(currentTemplateid, currentTemplateItems). - success(function(data, status, headers, config) { - console.log('saveTiming call successfull...'); - if(data['ok']==true) { - $scope.refreshTimings(); - } else { - console.log('timing wasnt saved'); - } - console.log(data); - }). - error(function(data, status, headers, config) { - console.log('saveTiming call failed...'); - console.log(data); - }); - }; - }; - - $scope.cancel = function() { - StopwatchService.cancel(); - clearTimeout(stopwatchUpdateTimer); - }; - - $scope.isTimerRunning = function() { - return StopwatchService.isRunning(); - }; - - $scope.refreshTimings = function() { - console.log('HI refreshing timings'); - TemplateBackendService.getTimings(StopwatchService.getActiveTemplate().idtemplate) - .success(function(data, status, headers, config) { - console.log('getTimings call successful...'); - console.log(data); - - if(data['ok']==true) { - - //create header array for the table - var currentTemplateItems = StopwatchService.getCurrentTemplateItems(); - - $scope.timingheaders = []; - for(var i = 0; i0) { - $scope.setActiveTemplate($scope.templates[0]); - } - } else { - //not ok... do we explicitly call logout? - //TODO call logout - console.log('refresh templates went bad: '+data.error); - } - }). - error(function(data, status, headers, config) { - // called asynchronously if an error occurs - // or server returns response with an error status. - console.log('refresh templates ERROR'); - console.log(data); - }); - } - - }]); - - - - - - - - - - - - - - - - - mod.controller('TimerTemplateCtrl', ['$scope', 'TemplateBackendService', function($scope, TemplateBackendService) { - //init the list - $scope.timerTemplateList = []; - $scope.newpauselength = 1000; - - //some vars - var maxTreeDepth = 3; - - //init the template with default name - $scope.templateitems = []; - $scope.templatename = "defaultname"; - - $scope.removeItem = function(item) { - $scope.templateitems.splice($scope.templateitems.indexOf(item),1); - }; - - $scope.addItem = function() { - $scope.templateitems.push(null); - }; - - $scope.toggle = function(scope) { - scope.toggle(); - }; - - $scope.saveTemplate = function() { - console.log('saving template'); - console.log($scope.templatename); - console.log($scope.templateitems); - - //save a new one! - TemplateBackendService.saveTemplate($scope.templatename, $scope.templateitems). - success(function(data, status, headers, config) { - console.log("got this data"); - console.log(data); - console.log(data); - if(data.ok) { - //save succeeded - console.log('save ok'); - } else { - //not ok... do we explicitly call logout? - //TODO call logout - console.log('save bad'); - } - }). - error(function(data, status, headers, config) { - // called asynchronously if an error occurs - // or server returns response with an error status. - console.log('save template ERROR'); - console.log(data); - }) - ; - }; - }]); - - mod.controller('NavCtrl', ['$scope', 'LoginService', '$location', function ($scope, LoginService, $location) { - console.log('navctrller knows: '+LoginService.isLoggedIn()); - - $scope.loggedIn = function() { - return LoginService.isLoggedIn(); - }; - - $scope.getActiveCss = function (path) { - // console.log('get activecss: '+path+' '+$location.path()); - var ok = $location.path().indexOf(path) != -1; - return { - active: ok - }; - }; - - $scope.logout = function() { - LoginService.setLoggedIn(false); - }; - }]); - - mod.controller('LoginCtrl', ['$scope','LoginService', '$window', 'md5', '$location', function($scope, LoginService, $window, md5, $location) { - - $scope.loginErrorred = false; - $scope.loginError = "blablabla"; - - $scope.loggedIn = function() { - return LoginService.isLoggedIn(); - } - - $scope.loggedInUsername = function() { - var u = LoginService.getLoggedInUsername(); - // console.log('loggedinusername requested: '+u); - return u; - } - - $scope.doLogin = function () { - console.log($scope.auth); - LoginService.login($scope.auth.username, md5.createHash($scope.auth.password)). - success(function(data, status, headers, config) { - // this callback will be called asynchronously - // when the response is available - console.log('login call came back OK'); - console.log(data); - if(data.ok) { - //login succeeded - $scope.loginErrorred = false; - LoginService.setLoggedIn(true); - LoginService.setLoggedInUsername(data.user.username); - $location.path('/') - } else { - //didn't login, show error - $scope.loginErrorred = true; - $scope.loginError = "Couldn't login..."; - //logout - $scope.logout(); - } - //redirect to main - - }). - error(function(data, status, headers, config) { - // called asynchronously if an error occurs - // or server returns response with an error status. - console.log('login ERROR'); - console.log(data); - }) - ; - }; - - $scope.logout = function() { - LoginService.logout(). - success(function(data, status, headers, config) { - // this callback will be called asynchronously - // when the response is available - console.log('logout call came back OK'); - console.log(data); - if(data.ok) { - //login succeeded - LoginService.setLoggedIn(false); - LoginService.setLoggedInUsername(null); - } else { - //not ok... do we explicitly call logout? - //TODO call logout - } - //redirect to main - $location.path('/') - }). - error(function(data, status, headers, config) { - // called asynchronously if an error occurs - // or server returns response with an error status. - console.log('logout ERROR'); - console.log(data); - }) - ; - }; - }]); - - mod.controller('RegisterCtrl', ['$scope', 'LoginService', 'RegisterService', 'md5', '$location', function($scope, LoginService, RegisterService, md5, $location) { - - $scope.registerErrorred = false; - $scope.registerError = "blablabla"; - - $scope.doRegister = function () { - console.log('auth obj'); - console.log($scope.auth); - //reset the error... - $scope.registerErrorred = false; - - RegisterService.register($scope.auth.username, $scope.auth.email, md5.createHash($scope.auth.password)) - // .then( - // function (data, status) { - // console.log('register came back'); - // console.log(data); - // console.log(status); - // if (data.data.status != 200) { - // //$window.alert("Fout: "+data.data.errors[0]); - // console.log('got a loginservice error, register failed!'); - // } - // else { - // console.log('register came backl with this data...'); - // console.log(data.data); - // //$window.alert("GELUKT: "+data.data.user.username); - // LoginService.setLoggedIn(data.data.user != null); - // } - // } - // ) - .success(function(data, status, headers, config) { - // this callback will be called asynchronously - // when the response is available - console.log('register returned successfully'); - console.log(data); - console.log(status); - - if(data['ok']) { - console.log('logged in true :)'); - //set us to be logged in - LoginService.setLoggedIn(true); - LoginService.setLoggedInUsername(data.newuser.username); - $location.path('/') - } else { - console.log('logged in false :('); - } - }). - error(function(data, status, headers, config) { - // called asynchronously if an error occurs - // or server returns response with an error status. - console.log('register failed'); - console.log(data); - console.log(status); - if(status==400) { - $scope.registerError = data.error.message; - $scope.registerErrorred = true; - } - // $scope.registerError = status. - }); - }; - }]); - - mod.controller('MembersCtrl', ['$scope','LoginService', '$window', function($scope, $window) { - }]); - - mod.controller('MemberCtrl', ['$scope', '$routeParams', function($scope, $routeParams) { - console.log('member ctrl knows: '+$routeParams.id); - $scope.memberid = $routeParams.id; - }]); - - mod.controller('NewsCtrl', ['$scope', 'NewsService', 'LoginService', function($scope, NewsService, LoginService) { - - NewsService.fetchNews().then( - function (data, status) { - $scope.newsItems = data.data.news; - } - ); - - $scope.isLoggedIn = function() { - return LoginService.isLoggedIn(); - } - - $scope.submitNews = function(newNewsTitle, newNewsBody) { - NewsService.submitNews(newNewsTitle, newNewsBody).then( - function(data, status) { - console.log("submitnews has returned!"); - console.log(data); - console.log(data.data.news); - console.log(data.data.errors); - - //check if we are still logged in (login error might indicate we have to login again) - if(data.data.error!=null && data.data.error.nr == 2) { - console.log('we got a login error! setting the login service to loggedin = false'); - LoginService.setLoggedIn(false); - return; - } - - //add the result to the news items (so we don't have to reload the page) - $scope.newsItems.push(data.data.news); - - //empty the input fields - $scope.newNewsBody = ""; - $scope.newNewsTitle = ""; - } - ); - } - - $scope.saveNewsItemText = function(newsItemImage) { - NewsService.saveNewsItemText(newsItemImage).then( - function(data, status) { - console.log("save newsitemtext has returned!"); - console.log(data); - console.log(data.data.news); - console.log(data.data.errors); - - //check if we are still logged in (login error might indicate we have to login again) - if(data.data.error!=null && data.data.error.nr == 2) { - console.log('we got a login error! setting the login service to loggedin = false'); - LoginService.setLoggedIn(false); - return; - } - - //add the result to the news items (so we don't have to reload the page) - $scope.newsItems.push(data.data.news); - - //empty the input fields - $scope.newNewsBody = ""; - $scope.newNewsTitle = ""; - } - ); - } - - $scope.removeNewsItem = function(item) { - //look for the item to remove - var toremove = -1; - for(var i = 0; i<$scope.newsItems.length; i++) { - if($scope.newsItems[i].idnews == item.idnews) { - toremove = i; - break; - } - } - console.log('got index: '+toremove); - if(toremove>=0) { - $scope.newsItems.splice(toremove,1); - } - console.log('got to remove: '); - console.log(item); - - //let the backend know to remove it as well - NewsService.removeNewsItem(item); - } - - $scope.deleteNewsItemImage = function(newsItem, newsItemImage) { - //delete in the backend - NewsService.deleteNewsItemImage(newsItemImage); - - //remove it in the frontend - var toremove = -1; - for(var i = 0; i=0) { - newsItem.images.splice(toremove,1); - } - } - - $scope.onFileSelect = function($files,item) { - //$files: an array of files selected, each file has name, size, and type. - for (var i = 0; i < $files.length; i++) { - var file = $files[i]; - //upload the file to the news service - NewsService.addImageToNewsItem(item, file).progress(function(evt) { - var percent = parseInt(100.0 * evt.loaded / evt.total); - console.log('progress percent addImageToNewsItem (newsitem '+item.idnews+'): ' + percent); - }).success(function(data, status, headers, config) { - // file is uploaded successfully - console.log('addimagetonewsitemservicelog: '+data); - console.log(data.newsimage); - if(data.error == null) { - //file successfully uploaded! fetch the filename and add it to the list of items - console.log('added news image item...'); - console.log(data.data); - console.log(data); - item.images.push(data.newsimage); - } else { - console.log('addimagetonewsitem service errorred: '+data.error); - } - }); - } - }; - }]); + $scope.logout = function() { + LoginService.setLoggedIn(false); + }; + + $scope.getActiveRace = function() { + return MainService.getActiveRace(); + }; +}]); diff --git a/js/services.js b/js/services.js index af82456..5478312 100644 --- a/js/services.js +++ b/js/services.js @@ -27,258 +27,153 @@ appServices.service('PouleService', function($http) { this.addPoule = function(newpoule, idchampionship) { return $http.post('server/addpoule.php', {tier:newpoule.tier, poule:newpoule.poule, idchampionship:idchampionship}); }; + + this.addTeam = function(team, idchampionship, tier, poule) { + return $http.post('server/addteamtopoule.php', {idteam:team.idteam, tier:tier, poule:poule, idchampionship:idchampionship}); + }; + + this.removeTeam = function(team, idchampionship, tier, poule) { + return $http.post('server/removeteamfrompoule.php', {idteam:team.idteam, tier:tier, poule:poule, idchampionship:idchampionship}); + }; + + this.getRacesInPoule = function(idchampionship, tier, poule) { + return $http.post('server/getracesinpoule.php', {tier:tier, poule:poule, idchampionship:idchampionship}); + }; + + this.addRace = function(idchampionship, tier, poule, idteam) { + return $http.post('server/addracetopoule.php', {tier:tier, poule:poule, idchampionship:idchampionship, idteam:idteam}); + }; + + this.deleteRace = function(idchampionship, tier, poule, idrace) { + return $http.post('server/deleterace.php', {tier:tier, poule:poule, idchampionship:idchampionship, idrace:idrace}); + }; }); + + + + appServices.service('TeamService', function($http) { this.getTeams = function(idchampionship) { return $http.post('server/getteams.php', {idchampionship:idchampionship}); }; + this.getTeamsInPoule = function(idchampionship, tier, poule) { + return $http.post('server/getteams.php', {idchampionship:idchampionship, tier:tier, poule:poule}); + }; + + this.deleteTeam = function(team, idchampionship) { + return $http.post('server/deleteteam.php', {idteam:team.idteam, idchampionship:idchampionship}); + }; + + /** + * Filters: teams that are from the given championship and haven't been used in another poule... + */ + this.getTeamsAvailableForPoule = function(idchampionship, tier, poule) { + return $http.post('server/getteams.php', {idchampionship:idchampionship, tier:tier, poule:poule, available:true}); + }; + this.addTeam = function(newteam, idchampionship) { console.log('adding team'); return $http.post('server/addteam.php', {name:newteam.name, idchampionship:idchampionship}); }; }); - -appServices.service('StopwatchService', ['TemplateBackendService', function(TemplateBackendService) { - //init the stopwatch value in ms - var intervalMs = 0; - var startMs = null; - var running = false; - - var timings = null; - - //this is the currently tracked leaf - var templateItemIndex = -1; - //this is the starttime of the currently tracked leaf - var leafStart = null; - - //the currently active template - var activeTemplate = null; - - this.updateValue = function() { - var currentMs = +new Date(); - intervalMs = currentMs - startMs; - } - - this.isRunning = function() { - return running; - } - - this.getValue = function() { - if(running) { - this.updateValue(); - } - return intervalMs; +appServices.service('RaceService', function($http) { + this.getDrives = function(idrace) { + return $http.post('server/getdrives.php', {idrace:idrace}); }; - this.currentlyRunningTemplateItemIndex = function() { - return templateItemIndex; - } + this.getTeam = function(idrace) { + return $http.post('server/getraceteam.php', {idrace:idrace}); + }; - this.getCurrentTemplateItems = function() { - if(activeTemplate != null && activeTemplate.templateitems != null) { - return activeTemplate.templateitems; - } else { - return []; - } - } + this.addDrive = function(race, driver, laps) { + return $http.post('server/adddrive.php', {idrace:race, iddriver:driver.iddriver, laps}); + }; - this.getActiveTemplate = function() { - return activeTemplate; - } + this.deleteDrive = function(drivenr, idrace) { + return $http.post('server/deletedrive.php', {drivenr:drivenr, idrace:idrace}); + }; +}); - this.setActiveTemplate = function(template) { - console.log('setActiveTemplate called'); - activeTemplate = template; - console.log('active template: '+template.templatename); - console.log(template); +appServices.service('DriverService', function($http) { + this.getDrivers = function(idchampionship, idteam) { + return $http.post('server/getdrivers.php', {idchampionship:idchampionship, idteam:idteam}); + }; - //now, set up the timer so we can process the active template - //1) active template needs to be read from left to right, leaf to leaf - //2) time each leaf: start , tap , tap , end > save timings to db - //-- stop will break off the attempt + this.addDriver = function(newdriver, idchampionship, idteam) { + console.log('adding driver'); + return $http.post('server/adddriver.php', {idchampionship:idchampionship, name:newdriver.name, idteam:idteam}); + }; - //get the leafs of the active template - console.log('got these active items: '); - console.log(template.templateitems); - } + this.deleteDriver = function(driver) { + console.log('removing driver'); + return $http.post('server/deletedriver.php', {iddriver:driver.iddriver}); + }; +}); - this.cancel = function() { - running = false; - templateItemIndex = -1; - leafStart = 0; - } +appServices.service('MainService', function($http, $cookies) { - this.tap = function() { - //okay, if we are not running right now, initialise everything - var stopRunningTimer = false; + var activerace = null; - if(!running) { - //start up the first leaf - templateItemIndex = 0; - leafStart = 0; - running = true; - startMs = +new Date(); - } else { - //already running! - var temptime = this.getValue(); - var leafTime = temptime-leafStart; - activeTemplate.templateitems[templateItemIndex]['timing'] = leafTime; - //check if we're at the end - if(templateItemIndex==activeTemplate.templateitems.length-1) { - //reached the end, stop everything - console.log('got to the end...'); - console.log('leaf '+activeTemplate.templateitems[templateItemIndex].templateitemname+' got: '+leafTime); - var currentMs = +new Date(); - intervalMs = currentMs - startMs; - running = false; - templateItemIndex = -1; - stopRunningTimer = true; + this.refreshConfig = function() { + $http.post('server/config.php', {action:'getConfig'}). + success(function(data, status, headers, config) { + console.log('refreshConfig successful...'); + //refresh activerace + if(data.activeidrace != null) { + console.log('setting the activerace...'); + activerace = { + idrace:data.activeidrace, + tier:data.tier, + poule:data.poule, + idchampionship:data.idchampionship + }; } else { - //end the current leaf - console.log('leaf '+activeTemplate.templateitems[templateItemIndex].templateitemname+' got: '+leafTime); - //go to the next leaf - templateItemIndex++; - leafStart = temptime; + console.log('idrace was null, setting activerace to null'); + activerace = null; } - } - - return stopRunningTimer; - } -}]); - - - -appServices.service('TemplateBackendService', function($http) { - - this.saveTemplate = function(templateName, templateItems) { - console.log('gonna save this'); - console.log(templateName+' '+templateItems); - return $http.post('server/savetemplate.php', {templateName:templateName, templateItems:templateItems}); - }; - - this.getTemplates = function() { - console.log('TemplateBackendService.getTemplates called'); - return $http.post('server/gettemplates.php', {}); - }; - - this.removeTemplate = function(template) { - var idtemplate = template.idtemplate; - // var templateid = template->{'$id'}; - // console.log('going to remove: '+templateid); - return $http.post('server/removetemplate.php', {idtemplate:idtemplate}); - }; - - /** - Templateid: dbid of the template. timings: assoc array with nodeid=>timing(ms) - */ - this.saveTiming = function(idtemplate, templateitems) { - console.log('saving timing...'); - console.log(idtemplate); - console.log(templateitems); - return $http.post('server/savetiming.php', {idtemplate:idtemplate,templateitems:templateitems}); - }; - - /** - Fetch an array with all the timings for the given templateid, sorted on insert date. - */ - this.getTimings = function(idtemplate) { - return $http.post('server/gettimings.php', {idtemplate:idtemplate}); - } - - this.removeTiming = function(idtimingrun) { - return $http.post('server/removetiming.php', {idtimingrun:idtimingrun}); - } - - }); - - - - -appServices.service('TemplateCreationService', function() { - -}); - - -appServices.service('RegisterService', function($http) { - var url = "server/register.php"; - //?email=emailtest&md5pass=passtest&username=usertest - - this.register = function (username, email, md5pass) { - return $http.post(url, { - username:username, - md5pass:md5pass, - email:email - }); - }; -}); - -appServices.service('LoginService', function($http) { - var url = "server/login.php"; - // var loggedIn = $cookieStore.get('loggedIn'); - var email = null; - // console.log('cookiestore says loggedin is: '+loggedIn); - - this.login = function (username, md5password) { - console.log('doing the login... '+username+' '+md5password); - return $http.post(url, { - md5password:md5password, - username:username + console.log(activerace); + }). + error(function(data, status, headers, config) { + console.log('getConfig failed...'); }); }; - this.setLoggedInUsername = function(newusername) { - console.log('setting loggedin username: '+newusername); - $cookieStore.put('loggedInUsername', newusername); + this.setActiveRace = function(idrace, tier, poule, idchampionship) { + if(idrace == null) { + activerace = null; + } else { + activerace = { + idrace:idrace, + tier:tier, + poule:poule, + idchampionship:idchampionship + }; + } + $http.post('server/config.php', {action:'setActiveIdRace', idrace:idrace}). + success(function(data, status, headers, config) { + //do something? + }); }; - this.getLoggedInUsername = function() { - return $cookieStore.get('loggedInUsername'); + this.getActiveRace = function() { + return activerace; }; - this.setLoggedIn = function(newValue) { - console.log('set logged in : '+newValue); - // loggedIn = newValue; - $cookieStore.put('loggedIn', newValue); + this.toggleActiveRace = function(idrace, tier, poule, idchampionship) { + console.log('toggling active race'+idrace); + //if the race is not the same as the currently active on: switch it + if(activerace == null || activerace.idrace!=idrace) { + this.setActiveRace(idrace, tier, poule, idchampionship); + } else { + //well, it's the same: we're disabling the activeness of the race + activerace = null; + this.setActiveRace(null, null, null, null); + } }; - this.isLoggedIn = function() { - return false; - }; - - this.logout = function() { - return $http.post("server/logout.php"); - }; -}); - -appServices.service('NewsService', function($http,$upload) { - this.fetchNews = function() { - return $http.post("phpservices/news.php"); - }; - - this.submitNews = function(newNewsTitle, newNewsBody) { - var newNews = { - title:newNewsTitle, - body:newNewsBody - }; - console.log("submitnewsing service: "+newNews); - return $http.post("phpservices/addnews.php",newNews); - }; - - this.removeNewsItem = function(newsItem) { - var postObj = { - idnews:newsItem.idnews - }; - $http.post("phpservices/removenews.php", postObj); - }; - - this.saveNewsItemText = function(newsItemImage) { - return $http.post("phpservices/savenewsimagetext.php", newsItemImage); - }; - - this.deleteNewsItemImage = function(newsItemImage) { - return $http.post("phpservices/removenewsitemimage.php", newsItemImage); - }; + //load the current config + this.refreshConfig(); }); diff --git a/node_modules/angular-cookies/README.md b/node_modules/angular-cookies/README.md new file mode 100644 index 0000000..7b190d3 --- /dev/null +++ b/node_modules/angular-cookies/README.md @@ -0,0 +1,68 @@ +# packaged angular-cookies + +This repo is for distribution on `npm` and `bower`. The source for this module is in the +[main AngularJS repo](https://github.com/angular/angular.js/tree/master/src/ngCookies). +Please file issues and pull requests against that repo. + +## Install + +You can install this package either with `npm` or with `bower`. + +### npm + +```shell +npm install angular-cookies +``` + +Then add `ngCookies` as a dependency for your app: + +```javascript +angular.module('myApp', [require('angular-cookies')]); +``` + +### bower + +```shell +bower install angular-cookies +``` + +Add a ` +``` + +Then add `ngCookies` as a dependency for your app: + +```javascript +angular.module('myApp', ['ngCookies']); +``` + +## Documentation + +Documentation is available on the +[AngularJS docs site](http://docs.angularjs.org/api/ngCookies). + +## License + +The MIT License + +Copyright (c) 2010-2015 Google, Inc. http://angularjs.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/angular-cookies/angular-cookies.js b/node_modules/angular-cookies/angular-cookies.js new file mode 100644 index 0000000..1d85b4e --- /dev/null +++ b/node_modules/angular-cookies/angular-cookies.js @@ -0,0 +1,321 @@ +/** + * @license AngularJS v1.4.5 + * (c) 2010-2015 Google, Inc. http://angularjs.org + * License: MIT + */ +(function(window, angular, undefined) {'use strict'; + +/** + * @ngdoc module + * @name ngCookies + * @description + * + * # ngCookies + * + * The `ngCookies` module provides a convenient wrapper for reading and writing browser cookies. + * + * + *
+ * + * See {@link ngCookies.$cookies `$cookies`} for usage. + */ + + +angular.module('ngCookies', ['ng']). + /** + * @ngdoc provider + * @name $cookiesProvider + * @description + * Use `$cookiesProvider` to change the default behavior of the {@link ngCookies.$cookies $cookies} service. + * */ + provider('$cookies', [function $CookiesProvider() { + /** + * @ngdoc property + * @name $cookiesProvider#defaults + * @description + * + * Object containing default options to pass when setting cookies. + * + * The object may have following properties: + * + * - **path** - `{string}` - The cookie will be available only for this path and its + * sub-paths. By default, this would be the URL that appears in your base tag. + * - **domain** - `{string}` - The cookie will be available only for this domain and + * its sub-domains. For obvious security reasons the user agent will not accept the + * cookie if the current domain is not a sub domain or equals to the requested domain. + * - **expires** - `{string|Date}` - String of the form "Wdy, DD Mon YYYY HH:MM:SS GMT" + * or a Date object indicating the exact date/time this cookie will expire. + * - **secure** - `{boolean}` - The cookie will be available only in secured connection. + * + * Note: by default the address that appears in your `` tag will be used as path. + * This is important so that cookies will be visible for all routes in case html5mode is enabled + * + **/ + var defaults = this.defaults = {}; + + function calcOptions(options) { + return options ? angular.extend({}, defaults, options) : defaults; + } + + /** + * @ngdoc service + * @name $cookies + * + * @description + * Provides read/write access to browser's cookies. + * + *
+ * Up until Angular 1.3, `$cookies` exposed properties that represented the + * current browser cookie values. In version 1.4, this behavior has changed, and + * `$cookies` now provides a standard api of getters, setters etc. + *
+ * + * Requires the {@link ngCookies `ngCookies`} module to be installed. + * + * @example + * + * ```js + * angular.module('cookiesExample', ['ngCookies']) + * .controller('ExampleController', ['$cookies', function($cookies) { + * // Retrieving a cookie + * var favoriteCookie = $cookies.get('myFavorite'); + * // Setting a cookie + * $cookies.put('myFavorite', 'oatmeal'); + * }]); + * ``` + */ + this.$get = ['$$cookieReader', '$$cookieWriter', function($$cookieReader, $$cookieWriter) { + return { + /** + * @ngdoc method + * @name $cookies#get + * + * @description + * Returns the value of given cookie key + * + * @param {string} key Id to use for lookup. + * @returns {string} Raw cookie value. + */ + get: function(key) { + return $$cookieReader()[key]; + }, + + /** + * @ngdoc method + * @name $cookies#getObject + * + * @description + * Returns the deserialized value of given cookie key + * + * @param {string} key Id to use for lookup. + * @returns {Object} Deserialized cookie value. + */ + getObject: function(key) { + var value = this.get(key); + return value ? angular.fromJson(value) : value; + }, + + /** + * @ngdoc method + * @name $cookies#getAll + * + * @description + * Returns a key value object with all the cookies + * + * @returns {Object} All cookies + */ + getAll: function() { + return $$cookieReader(); + }, + + /** + * @ngdoc method + * @name $cookies#put + * + * @description + * Sets a value for given cookie key + * + * @param {string} key Id for the `value`. + * @param {string} value Raw value to be stored. + * @param {Object=} options Options object. + * See {@link ngCookies.$cookiesProvider#defaults $cookiesProvider.defaults} + */ + put: function(key, value, options) { + $$cookieWriter(key, value, calcOptions(options)); + }, + + /** + * @ngdoc method + * @name $cookies#putObject + * + * @description + * Serializes and sets a value for given cookie key + * + * @param {string} key Id for the `value`. + * @param {Object} value Value to be stored. + * @param {Object=} options Options object. + * See {@link ngCookies.$cookiesProvider#defaults $cookiesProvider.defaults} + */ + putObject: function(key, value, options) { + this.put(key, angular.toJson(value), options); + }, + + /** + * @ngdoc method + * @name $cookies#remove + * + * @description + * Remove given cookie + * + * @param {string} key Id of the key-value pair to delete. + * @param {Object=} options Options object. + * See {@link ngCookies.$cookiesProvider#defaults $cookiesProvider.defaults} + */ + remove: function(key, options) { + $$cookieWriter(key, undefined, calcOptions(options)); + } + }; + }]; + }]); + +angular.module('ngCookies'). +/** + * @ngdoc service + * @name $cookieStore + * @deprecated + * @requires $cookies + * + * @description + * Provides a key-value (string-object) storage, that is backed by session cookies. + * Objects put or retrieved from this storage are automatically serialized or + * deserialized by angular's toJson/fromJson. + * + * Requires the {@link ngCookies `ngCookies`} module to be installed. + * + *
+ * **Note:** The $cookieStore service is **deprecated**. + * Please use the {@link ngCookies.$cookies `$cookies`} service instead. + *
+ * + * @example + * + * ```js + * angular.module('cookieStoreExample', ['ngCookies']) + * .controller('ExampleController', ['$cookieStore', function($cookieStore) { + * // Put cookie + * $cookieStore.put('myFavorite','oatmeal'); + * // Get cookie + * var favoriteCookie = $cookieStore.get('myFavorite'); + * // Removing a cookie + * $cookieStore.remove('myFavorite'); + * }]); + * ``` + */ + factory('$cookieStore', ['$cookies', function($cookies) { + + return { + /** + * @ngdoc method + * @name $cookieStore#get + * + * @description + * Returns the value of given cookie key + * + * @param {string} key Id to use for lookup. + * @returns {Object} Deserialized cookie value, undefined if the cookie does not exist. + */ + get: function(key) { + return $cookies.getObject(key); + }, + + /** + * @ngdoc method + * @name $cookieStore#put + * + * @description + * Sets a value for given cookie key + * + * @param {string} key Id for the `value`. + * @param {Object} value Value to be stored. + */ + put: function(key, value) { + $cookies.putObject(key, value); + }, + + /** + * @ngdoc method + * @name $cookieStore#remove + * + * @description + * Remove given cookie + * + * @param {string} key Id of the key-value pair to delete. + */ + remove: function(key) { + $cookies.remove(key); + } + }; + + }]); + +/** + * @name $$cookieWriter + * @requires $document + * + * @description + * This is a private service for writing cookies + * + * @param {string} name Cookie name + * @param {string=} value Cookie value (if undefined, cookie will be deleted) + * @param {Object=} options Object with options that need to be stored for the cookie. + */ +function $$CookieWriter($document, $log, $browser) { + var cookiePath = $browser.baseHref(); + var rawDocument = $document[0]; + + function buildCookieString(name, value, options) { + var path, expires; + options = options || {}; + expires = options.expires; + path = angular.isDefined(options.path) ? options.path : cookiePath; + if (value === undefined) { + expires = 'Thu, 01 Jan 1970 00:00:00 GMT'; + value = ''; + } + if (angular.isString(expires)) { + expires = new Date(expires); + } + + var str = encodeURIComponent(name) + '=' + encodeURIComponent(value); + str += path ? ';path=' + path : ''; + str += options.domain ? ';domain=' + options.domain : ''; + str += expires ? ';expires=' + expires.toUTCString() : ''; + str += options.secure ? ';secure' : ''; + + // per http://www.ietf.org/rfc/rfc2109.txt browser must allow at minimum: + // - 300 cookies + // - 20 cookies per unique domain + // - 4096 bytes per cookie + var cookieLength = str.length + 1; + if (cookieLength > 4096) { + $log.warn("Cookie '" + name + + "' possibly not set or overflowed because it was too large (" + + cookieLength + " > 4096 bytes)!"); + } + + return str; + } + + return function(name, value, options) { + rawDocument.cookie = buildCookieString(name, value, options); + }; +} + +$$CookieWriter.$inject = ['$document', '$log', '$browser']; + +angular.module('ngCookies').provider('$$cookieWriter', function $$CookieWriterProvider() { + this.$get = $$CookieWriter; +}); + + +})(window, window.angular); diff --git a/node_modules/angular-cookies/angular-cookies.min.js b/node_modules/angular-cookies/angular-cookies.min.js new file mode 100644 index 0000000..181624c --- /dev/null +++ b/node_modules/angular-cookies/angular-cookies.min.js @@ -0,0 +1,9 @@ +/* + AngularJS v1.4.5 + (c) 2010-2015 Google, Inc. http://angularjs.org + License: MIT +*/ +(function(p,g,l){'use strict';function m(b,a,f){var c=f.baseHref(),k=b[0];return function(b,d,e){var f,h;e=e||{};h=e.expires;f=g.isDefined(e.path)?e.path:c;d===l&&(h="Thu, 01 Jan 1970 00:00:00 GMT",d="");g.isString(h)&&(h=new Date(h));d=encodeURIComponent(b)+"="+encodeURIComponent(d);d=d+(f?";path="+f:"")+(e.domain?";domain="+e.domain:"");d+=h?";expires="+h.toUTCString():"";d+=e.secure?";secure":"";e=d.length+1;4096 4096 bytes)!");k.cookie=d}}g.module("ngCookies",["ng"]).provider("$cookies",[function(){var b=this.defaults={};this.$get=["$$cookieReader","$$cookieWriter",function(a,f){return{get:function(c){return a()[c]},getObject:function(c){return(c=this.get(c))?g.fromJson(c):c},getAll:function(){return a()},put:function(c,a,n){f(c,a,n?g.extend({},b,n):b)},putObject:function(c,b,a){this.put(c,g.toJson(b),a)},remove:function(a,k){f(a,l,k?g.extend({},b,k):b)}}}]}]);g.module("ngCookies").factory("$cookieStore", +["$cookies",function(b){return{get:function(a){return b.getObject(a)},put:function(a,f){b.putObject(a,f)},remove:function(a){b.remove(a)}}}]);m.$inject=["$document","$log","$browser"];g.module("ngCookies").provider("$$cookieWriter",function(){this.$get=m})})(window,window.angular); +//# sourceMappingURL=angular-cookies.min.js.map diff --git a/node_modules/angular-cookies/angular-cookies.min.js.map b/node_modules/angular-cookies/angular-cookies.min.js.map new file mode 100644 index 0000000..84e6a57 --- /dev/null +++ b/node_modules/angular-cookies/angular-cookies.min.js.map @@ -0,0 +1,8 @@ +{ +"version":3, +"file":"angular-cookies.min.js", +"lineCount":8, +"mappings":"A;;;;;aAKC,SAAQ,CAACA,CAAD,CAASC,CAAT,CAAkBC,CAAlB,CAA6B,CA0QtCC,QAASA,EAAc,CAACC,CAAD,CAAYC,CAAZ,CAAkBC,CAAlB,CAA4B,CACjD,IAAIC,EAAaD,CAAAE,SAAA,EAAjB,CACIC,EAAcL,CAAA,CAAU,CAAV,CAmClB,OAAO,SAAQ,CAACM,CAAD,CAAOC,CAAP,CAAcC,CAAd,CAAuB,CAjCW,IAC3CC,CAD2C,CACrCC,CACVF,EAAA,CAgCoDA,CAhCpD,EAAqB,EACrBE,EAAA,CAAUF,CAAAE,QACVD,EAAA,CAAOZ,CAAAc,UAAA,CAAkBH,CAAAC,KAAlB,CAAA,CAAkCD,CAAAC,KAAlC,CAAiDN,CACpDI,EAAJ,GAAcT,CAAd,GACEY,CACA,CADU,+BACV,CAAAH,CAAA,CAAQ,EAFV,CAIIV,EAAAe,SAAA,CAAiBF,CAAjB,CAAJ,GACEA,CADF,CACY,IAAIG,IAAJ,CAASH,CAAT,CADZ,CAIII,EAAAA,CAAMC,kBAAA,CAqB6BT,CArB7B,CAANQ,CAAiC,GAAjCA,CAAuCC,kBAAA,CAAmBR,CAAnB,CAE3CO,EAAA,CADAA,CACA,EADOL,CAAA,CAAO,QAAP,CAAkBA,CAAlB,CAAyB,EAChC,GAAOD,CAAAQ,OAAA,CAAiB,UAAjB,CAA8BR,CAAAQ,OAA9B,CAA+C,EAAtD,CACAF,EAAA,EAAOJ,CAAA,CAAU,WAAV,CAAwBA,CAAAO,YAAA,EAAxB,CAAgD,EACvDH,EAAA,EAAON,CAAAU,OAAA,CAAiB,SAAjB,CAA6B,EAMhCC,EAAAA,CAAeL,CAAAM,OAAfD,CAA4B,CACb,KAAnB,CAAIA,CAAJ,EACElB,CAAAoB,KAAA,CAAU,UAAV,CASqCf,CATrC,CACE,6DADF;AAEEa,CAFF,CAEiB,iBAFjB,CASFd,EAAAiB,OAAA,CAJOR,CAG6B,CArCW,CAxPnDjB,CAAA0B,OAAA,CAAe,WAAf,CAA4B,CAAC,IAAD,CAA5B,CAAAC,SAAA,CAOY,UAPZ,CAOwB,CAACC,QAAyB,EAAG,CAuBjD,IAAIC,EAAW,IAAAA,SAAXA,CAA2B,EAiC/B,KAAAC,KAAA,CAAY,CAAC,gBAAD,CAAmB,gBAAnB,CAAqC,QAAQ,CAACC,CAAD,CAAiBC,CAAjB,CAAiC,CACxF,MAAO,CAWLC,IAAKA,QAAQ,CAACC,CAAD,CAAM,CACjB,MAAOH,EAAA,EAAA,CAAiBG,CAAjB,CADU,CAXd,CAyBLC,UAAWA,QAAQ,CAACD,CAAD,CAAM,CAEvB,MAAO,CADHxB,CACG,CADK,IAAAuB,IAAA,CAASC,CAAT,CACL,EAAQlC,CAAAoC,SAAA,CAAiB1B,CAAjB,CAAR,CAAkCA,CAFlB,CAzBpB,CAuCL2B,OAAQA,QAAQ,EAAG,CACjB,MAAON,EAAA,EADU,CAvCd,CAuDLO,IAAKA,QAAQ,CAACJ,CAAD,CAAMxB,CAAN,CAAaC,CAAb,CAAsB,CACjCqB,CAAA,CAAeE,CAAf,CAAoBxB,CAApB,CAAuCC,CAvFpC,CAAUX,CAAAuC,OAAA,CAAe,EAAf,CAAmBV,CAAnB,CAuF0BlB,CAvF1B,CAAV,CAAkDkB,CAuFrD,CADiC,CAvD9B,CAuELW,UAAWA,QAAQ,CAACN,CAAD,CAAMxB,CAAN,CAAaC,CAAb,CAAsB,CACvC,IAAA2B,IAAA,CAASJ,CAAT,CAAclC,CAAAyC,OAAA,CAAe/B,CAAf,CAAd,CAAqCC,CAArC,CADuC,CAvEpC,CAsFL+B,OAAQA,QAAQ,CAACR,CAAD,CAAMvB,CAAN,CAAe,CAC7BqB,CAAA,CAAeE,CAAf,CAAoBjC,CAApB,CAA2CU,CAtHxC,CAAUX,CAAAuC,OAAA,CAAe,EAAf,CAAmBV,CAAnB,CAsH8BlB,CAtH9B,CAAV,CAAkDkB,CAsHrD,CAD6B,CAtF1B,CADiF,CAA9E,CAxDqC,CAA7B,CAPxB,CA6JA7B,EAAA0B,OAAA,CAAe,WAAf,CAAAiB,QAAA,CAiCS,cAjCT;AAiCyB,CAAC,UAAD,CAAa,QAAQ,CAACC,CAAD,CAAW,CAErD,MAAO,CAWLX,IAAKA,QAAQ,CAACC,CAAD,CAAM,CACjB,MAAOU,EAAAT,UAAA,CAAmBD,CAAnB,CADU,CAXd,CAyBLI,IAAKA,QAAQ,CAACJ,CAAD,CAAMxB,CAAN,CAAa,CACxBkC,CAAAJ,UAAA,CAAmBN,CAAnB,CAAwBxB,CAAxB,CADwB,CAzBrB,CAsCLgC,OAAQA,QAAQ,CAACR,CAAD,CAAM,CACpBU,CAAAF,OAAA,CAAgBR,CAAhB,CADoB,CAtCjB,CAF8C,CAAhC,CAjCzB,CAqIAhC,EAAA2C,QAAA,CAAyB,CAAC,WAAD,CAAc,MAAd,CAAsB,UAAtB,CAEzB7C,EAAA0B,OAAA,CAAe,WAAf,CAAAC,SAAA,CAAqC,gBAArC,CAAuDmB,QAA+B,EAAG,CACvF,IAAAhB,KAAA,CAAY5B,CAD2E,CAAzF,CAtTsC,CAArC,CAAD,CA2TGH,MA3TH,CA2TWA,MAAAC,QA3TX;", +"sources":["angular-cookies.js"], +"names":["window","angular","undefined","$$CookieWriter","$document","$log","$browser","cookiePath","baseHref","rawDocument","name","value","options","path","expires","isDefined","isString","Date","str","encodeURIComponent","domain","toUTCString","secure","cookieLength","length","warn","cookie","module","provider","$CookiesProvider","defaults","$get","$$cookieReader","$$cookieWriter","get","key","getObject","fromJson","getAll","put","extend","putObject","toJson","remove","factory","$cookies","$inject","$$CookieWriterProvider"] +} diff --git a/node_modules/angular-cookies/bower.json b/node_modules/angular-cookies/bower.json new file mode 100644 index 0000000..862c389 --- /dev/null +++ b/node_modules/angular-cookies/bower.json @@ -0,0 +1,9 @@ +{ + "name": "angular-cookies", + "version": "1.4.5", + "main": "./angular-cookies.js", + "ignore": [], + "dependencies": { + "angular": "1.4.5" + } +} diff --git a/node_modules/angular-cookies/index.js b/node_modules/angular-cookies/index.js new file mode 100644 index 0000000..6576675 --- /dev/null +++ b/node_modules/angular-cookies/index.js @@ -0,0 +1,2 @@ +require('./angular-cookies'); +module.exports = 'ngCookies'; diff --git a/node_modules/angular-cookies/package.json b/node_modules/angular-cookies/package.json new file mode 100644 index 0000000..ec5c8a0 --- /dev/null +++ b/node_modules/angular-cookies/package.json @@ -0,0 +1,37 @@ +{ + "name": "angular-cookies", + "version": "1.4.5", + "description": "AngularJS module for cookies", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "https://github.com/angular/angular.js.git" + }, + "keywords": [ + "angular", + "framework", + "browser", + "cookies", + "client-side" + ], + "author": { + "name": "Angular Core Team", + "email": "angular-core+npm@google.com" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/angular/angular.js/issues" + }, + "homepage": "http://angularjs.org", + "readme": "# packaged angular-cookies\n\nThis repo is for distribution on `npm` and `bower`. The source for this module is in the\n[main AngularJS repo](https://github.com/angular/angular.js/tree/master/src/ngCookies).\nPlease file issues and pull requests against that repo.\n\n## Install\n\nYou can install this package either with `npm` or with `bower`.\n\n### npm\n\n```shell\nnpm install angular-cookies\n```\n\nThen add `ngCookies` as a dependency for your app:\n\n```javascript\nangular.module('myApp', [require('angular-cookies')]);\n```\n\n### bower\n\n```shell\nbower install angular-cookies\n```\n\nAdd a `\n```\n\nThen add `ngCookies` as a dependency for your app:\n\n```javascript\nangular.module('myApp', ['ngCookies']);\n```\n\n## Documentation\n\nDocumentation is available on the\n[AngularJS docs site](http://docs.angularjs.org/api/ngCookies).\n\n## License\n\nThe MIT License\n\nCopyright (c) 2010-2015 Google, Inc. http://angularjs.org\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n", + "readmeFilename": "README.md", + "_id": "angular-cookies@1.4.5", + "dist": { + "shasum": "bf2642f5a11e30747348e35f1ee9cdcfa80a126e" + }, + "_from": "angular-cookies@", + "_resolved": "https://registry.npmjs.org/angular-cookies/-/angular-cookies-1.4.5.tgz" +} diff --git a/partials/championship-poule-race-drives.html b/partials/championship-poule-race-drives.html new file mode 100644 index 0000000..3aea881 --- /dev/null +++ b/partials/championship-poule-race-drives.html @@ -0,0 +1,67 @@ + + +
+
+
+
+

Ritten

+
+
+ + + + + + + + +
Rit nr.LapsChauffeurActies
{{drive.drivenr}}{{drive.laps}}{{drive.drivername}} + Verwijder +
+
+
+
+ +
+
+
+

Voeg rit toe

+
+
+ + +
+
Kies chauffeur
+ +
+ +
+
Opties en acties
+
+
+ + +
+
+ +
+
+
+ +
+
+
+
+
+
diff --git a/partials/championship-poule-races.html b/partials/championship-poule-races.html new file mode 100644 index 0000000..b2ae4e3 --- /dev/null +++ b/partials/championship-poule-races.html @@ -0,0 +1,67 @@ +
+
+ +
+ +
+
+
+
+

Races

+
+
+ + + + + + + +
TeamRaceidActies
{{race.name}}{{race.idrace}} + Ritten + + Verwijder +
+
+
+
+ +
+
+
+

Voeg race toe

+
+
+ + +
+
Kies team uit poule
+
+ +
+
+ +
+
Opties en acties
+
+ + +
+
+
+
+
+
diff --git a/partials/championship-poule-teams.html b/partials/championship-poule-teams.html new file mode 100644 index 0000000..afb6db6 --- /dev/null +++ b/partials/championship-poule-teams.html @@ -0,0 +1,44 @@ + + +
+ + +
+
+
Deelnemers
Deze teams zijn toegewezen aan de poule
+
+ +
+ +
+
+
+
+ + +
+
+
Beschikbare teams
Deze teams zitten niet in de poule maar zitten wel in hetzelfde kampioenschap.
+
+ +
+ +
+
+
+
+
diff --git a/partials/poules.html b/partials/championship-poules.html similarity index 53% rename from partials/poules.html rename to partials/championship-poules.html index 6b211f9..4f6952a 100644 --- a/partials/poules.html +++ b/partials/championship-poules.html @@ -1,18 +1,36 @@ -
+ + +
+ +
+

Poules

- - + + +
TierPoule
TierPouleActies
{{poule.tier}} {{poule.poule}} + + Bekijk races + + + Bekijk teams + +
+
+

Voeg poule toe

@@ -32,3 +50,4 @@
+
diff --git a/partials/championship-team-drivers.html b/partials/championship-team-drivers.html new file mode 100644 index 0000000..f05335d --- /dev/null +++ b/partials/championship-team-drivers.html @@ -0,0 +1,47 @@ + + + +
+ +
+
+
+

Drivers

+
+
+ + + + + + +
NaamActies
{{driver.name}} + + Verwijder + +
+
+
+
+ +
+
+
+

Voeg chauffeur toe

+
+
+
+ Naam + +
+ + +
+
+
+ +
diff --git a/partials/teams.html b/partials/championship-teams.html similarity index 61% rename from partials/teams.html rename to partials/championship-teams.html index c208da1..b98d40c 100644 --- a/partials/teams.html +++ b/partials/championship-teams.html @@ -1,12 +1,20 @@ + +

Teams

- + +
Naam
NaamActies
{{team.name}} + Bekijk chauffeurs + Verwijder
diff --git a/partials/championships.html b/partials/championships.html index 614fe70..783990d 100644 --- a/partials/championships.html +++ b/partials/championships.html @@ -1,20 +1,23 @@ + +

Kampioenschappen

- - +
SelectedNaam
+ - - + +
NaamActies
- - Bekijk poules - {{championship.name}}{{championship.name}} + Bekijk poules + Bekijk teams + +
diff --git a/server/adddrive.php b/server/adddrive.php new file mode 100644 index 0000000..39d5a6f --- /dev/null +++ b/server/adddrive.php @@ -0,0 +1,32 @@ + diff --git a/server/adddriver.php b/server/adddriver.php new file mode 100644 index 0000000..ede030a --- /dev/null +++ b/server/adddriver.php @@ -0,0 +1,32 @@ + diff --git a/server/addracetopoule.php b/server/addracetopoule.php new file mode 100644 index 0000000..a04e2d1 --- /dev/null +++ b/server/addracetopoule.php @@ -0,0 +1,33 @@ + diff --git a/server/addteam.php b/server/addteam.php index 888ce92..b1d3430 100644 --- a/server/addteam.php +++ b/server/addteam.php @@ -12,27 +12,28 @@ $idchampionship = $post['idchampionship']; $teamname = $post['name']; - $addteam= pg_prepare($dbconn, "addteam", "insert into team (name) values ($1) returning idteam"); - $addteam= pg_execute($dbconn, "addteam", array($teamname)); + $addteam= pg_prepare($dbconn, "addteam", "insert into team (name, idchampionship) values ($1, $2) returning idteam"); + $addteam= pg_execute($dbconn, "addteam", array($teamname, $idchampionship)); if($addpoule===FALSE) { $result['ok'] = false; $result['error'] = 'insert team failed: '.pg_last_error($dbconn); } else { - //inserted team, now the link - $insertedteam = pg_fetch_assoc($addteam); - $insertedidteam = $insertedteam['idteam']; - $addteamlinks= pg_prepare($dbconn, "addteamlink", "insert into team_championship (idteam, idchampionship) values ($1, $2)"); - $addteamlinks= pg_execute($dbconn, "addteamlink", array($insertedidteam, $idchampionship)); - - //check - if($addteamlinks===FALSE) { - $result['ok'] = false; - $result['error'] = "inserted team, couldn't insert the link to championship..."; - } else { - //all went well - $result['ok'] = true; - } + // //inserted team, now the link + // $insertedteam = pg_fetch_assoc($addteam); + // $insertedidteam = $insertedteam['idteam']; + // $addteamlinks= pg_prepare($dbconn, "addteamlink", "insert into team_championship (idteam, idchampionship) values ($1, $2)"); + // $addteamlinks= pg_execute($dbconn, "addteamlink", array($insertedidteam, $idchampionship)); + // + // //check + // if($addteamlinks===FALSE) { + // $result['ok'] = false; + // $result['error'] = "inserted team, couldn't insert the link to championship..."; + // } else { + // //all went well + // $result['ok'] = true; + // } + $result['ok'] = true; } //print message diff --git a/server/addteamtopoule.php b/server/addteamtopoule.php new file mode 100644 index 0000000..f18d3f1 --- /dev/null +++ b/server/addteamtopoule.php @@ -0,0 +1,31 @@ + diff --git a/server/config.php b/server/config.php new file mode 100644 index 0000000..515de2b --- /dev/null +++ b/server/config.php @@ -0,0 +1,26 @@ + diff --git a/server/deletedrive.php b/server/deletedrive.php new file mode 100644 index 0000000..5c19edf --- /dev/null +++ b/server/deletedrive.php @@ -0,0 +1,41 @@ + diff --git a/server/deletedriver.php b/server/deletedriver.php new file mode 100644 index 0000000..ab30191 --- /dev/null +++ b/server/deletedriver.php @@ -0,0 +1,28 @@ + diff --git a/server/deleterace.php b/server/deleterace.php new file mode 100644 index 0000000..1ee1f76 --- /dev/null +++ b/server/deleterace.php @@ -0,0 +1,30 @@ + diff --git a/server/deleteteam.php b/server/deleteteam.php new file mode 100644 index 0000000..316c289 --- /dev/null +++ b/server/deleteteam.php @@ -0,0 +1,28 @@ + diff --git a/server/getdrivers.php b/server/getdrivers.php new file mode 100644 index 0000000..2256e25 --- /dev/null +++ b/server/getdrivers.php @@ -0,0 +1,34 @@ + diff --git a/server/getdrives.php b/server/getdrives.php new file mode 100644 index 0000000..895befa --- /dev/null +++ b/server/getdrives.php @@ -0,0 +1,33 @@ + diff --git a/server/getpoules.php b/server/getpoules.php index 7bcbb90..bf1efe4 100644 --- a/server/getpoules.php +++ b/server/getpoules.php @@ -12,7 +12,7 @@ $idchampionship = $post['idchampionship']; //fetch the championships - $poulefetch = pg_prepare($dbconn, "poulefetch", "select * from poule where idchampionship = $1"); + $poulefetch = pg_prepare($dbconn, "poulefetch", "select * from poule where idchampionship = $1 order by tier, poule"); $poulefetch = pg_execute($dbconn, "poulefetch", array($idchampionship)); //build result object diff --git a/server/getracesinpoule.php b/server/getracesinpoule.php new file mode 100644 index 0000000..5160c62 --- /dev/null +++ b/server/getracesinpoule.php @@ -0,0 +1,35 @@ + diff --git a/server/getraceteam.php b/server/getraceteam.php new file mode 100644 index 0000000..31348bf --- /dev/null +++ b/server/getraceteam.php @@ -0,0 +1,47 @@ + diff --git a/server/getteams.php b/server/getteams.php index f9fc952..dbd08f9 100644 --- a/server/getteams.php +++ b/server/getteams.php @@ -11,23 +11,46 @@ $idchampionship = $post['idchampionship']; - //fetch the championships - $teamfetch = pg_prepare($dbconn, "teamfetch", "select team.* from team inner join team_championship using (idteam) where idchampionship = $1"); - $teamfetch = pg_execute($dbconn, "teamfetch", array($idchampionship)); + if(isset($post['tier']) && isset($post['poule']) && isset($post['available'])) { + //fetch everything not in the poule yet, but available in the championship + $tier = $post['tier']; + $poule = $post['poule']; + $teamfetch = pg_prepare($dbconn, "teamfetch", "select t.* from team t + where t.idchampionship = $1 and + t.idteam not in (select idteam from team_poule where team_poule.idchampionship = t.idchampionship + and team_poule.idteam = t.idteam - //build result object - $teams = array(); - while($row = pg_fetch_assoc($teamfetch)) { - $teams[] = $row; + )"); //and team_poule.tier = $2 and team_poule.poule = $3 + $teamfetch = pg_execute($dbconn, "teamfetch", array($idchampionship)); + } else if(isset($post['tier']) && isset($post['poule'])) { + //fetch everything currently set in the poule + $tier = $post['tier']; + $poule = $post['poule']; + $teamfetch = pg_prepare($dbconn, "teamfetch", "select team.* from team inner join team_poule using (idteam,idchampionship) where idchampionship = $1 and tier = $2 and poule = $3"); + $teamfetch = pg_execute($dbconn, "teamfetch", array($idchampionship, $tier, $poule)); + } else { + //fetch the championships + $teamfetch = pg_prepare($dbconn, "teamfetch", "select team.* from team where idchampionship = $1"); + $teamfetch = pg_execute($dbconn, "teamfetch", array($idchampionship)); } - $result['teams'] = $teams; + if($teamfetch === FALSE) { + $result['ok'] = false; + $result['error'] = pg_last_error($dbconn); + } else { + //build result object + $teams = array(); + while($row = pg_fetch_assoc($teamfetch)) { + $teams[] = $row; + } - //return data - $result['ok'] = true; + $result['teams'] = $teams; + + //return data + $result['ok'] = true; + } //print message $resultjson = json_encode($result); - echo $resultjson; ?> diff --git a/server/removeteamfrompoule.php b/server/removeteamfrompoule.php new file mode 100644 index 0000000..32f3339 --- /dev/null +++ b/server/removeteamfrompoule.php @@ -0,0 +1,31 @@ +