can now toggle publishresults in race
This commit is contained in:
parent
0a91f03c4c
commit
8eb58be172
@ -143,6 +143,8 @@ angular.module('bananaraceApp.controllers').controller('PouleCtrl', ['$scope', '
|
||||
console.log(data);
|
||||
if(data['ok']==true) {
|
||||
$scope.racesInPoule = data.races;
|
||||
console.log('got races: ');
|
||||
console.log(data.races);
|
||||
} else {
|
||||
console.log('getRacesInPoule call returned but wasnt ok: '+data['error']);
|
||||
}
|
||||
@ -159,6 +161,10 @@ angular.module('bananaraceApp.controllers').controller('PouleCtrl', ['$scope', '
|
||||
MainService.toggleActiveRace(race.idrace, tier, poule, idchampionship);
|
||||
};
|
||||
|
||||
$scope.togglePublishResults = function(race) {
|
||||
MainService.togglePublishResults(race);
|
||||
};
|
||||
|
||||
$scope.getActiveRace = function() {
|
||||
return MainService.getActiveRace();
|
||||
};
|
||||
|
||||
119
js/services.js
119
js/services.js
@ -4,33 +4,33 @@
|
||||
|
||||
var appServices = angular.module('bananaraceApp.services', []);
|
||||
|
||||
appServices.service('ChampionshipService', function($http) {
|
||||
this.getChampionships = function() {
|
||||
appServices.service('ChampionshipService', function ($http) {
|
||||
this.getChampionships = function () {
|
||||
console.log('service.getChampionships called');
|
||||
return $http.post('server/getchampionships.php', {});
|
||||
};
|
||||
|
||||
this.deleteChampionship = function(championship) {
|
||||
this.deleteChampionship = function (championship) {
|
||||
return $http.post('server/deletechampionship.php', {
|
||||
idchampionship: championship.idchampionship
|
||||
});
|
||||
};
|
||||
|
||||
this.addChampionship = function(newchampionship) {
|
||||
this.addChampionship = function (newchampionship) {
|
||||
return $http.post('server/addchampionship.php', {
|
||||
name: newchampionship.name
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
appServices.service('PouleService', function($http) {
|
||||
this.getPoules = function(idchampionship) {
|
||||
appServices.service('PouleService', function ($http) {
|
||||
this.getPoules = function (idchampionship) {
|
||||
return $http.post('server/getpoules.php', {
|
||||
idchampionship: idchampionship
|
||||
});
|
||||
};
|
||||
|
||||
this.addPoule = function(newpoule, idchampionship) {
|
||||
this.addPoule = function (newpoule, idchampionship) {
|
||||
return $http.post('server/addpoule.php', {
|
||||
tier: newpoule.tier,
|
||||
poule: newpoule.poule,
|
||||
@ -38,7 +38,7 @@ appServices.service('PouleService', function($http) {
|
||||
});
|
||||
};
|
||||
|
||||
this.deletePoule = function(tier, poule, idchampionship) {
|
||||
this.deletePoule = function (tier, poule, idchampionship) {
|
||||
return $http.post('server/deletepoule.php', {
|
||||
tier: tier,
|
||||
poule: poule,
|
||||
@ -46,7 +46,7 @@ appServices.service('PouleService', function($http) {
|
||||
});
|
||||
};
|
||||
|
||||
this.addTeam = function(team, idchampionship, tier, poule) {
|
||||
this.addTeam = function (team, idchampionship, tier, poule) {
|
||||
return $http.post('server/addteamtopoule.php', {
|
||||
idteam: team.idteam,
|
||||
tier: tier,
|
||||
@ -55,7 +55,7 @@ appServices.service('PouleService', function($http) {
|
||||
});
|
||||
};
|
||||
|
||||
this.removeTeam = function(team, idchampionship, tier, poule) {
|
||||
this.removeTeam = function (team, idchampionship, tier, poule) {
|
||||
return $http.post('server/removeteamfrompoule.php', {
|
||||
idteam: team.idteam,
|
||||
tier: tier,
|
||||
@ -64,7 +64,7 @@ appServices.service('PouleService', function($http) {
|
||||
});
|
||||
};
|
||||
|
||||
this.getRacesInPoule = function(idchampionship, tier, poule) {
|
||||
this.getRacesInPoule = function (idchampionship, tier, poule) {
|
||||
return $http.post('server/getracesinpoule.php', {
|
||||
tier: tier,
|
||||
poule: poule,
|
||||
@ -72,7 +72,7 @@ appServices.service('PouleService', function($http) {
|
||||
});
|
||||
};
|
||||
|
||||
this.addRace = function(idchampionship, tier, poule, idteam) {
|
||||
this.addRace = function (idchampionship, tier, poule, idteam) {
|
||||
return $http.post('server/addracetopoule.php', {
|
||||
tier: tier,
|
||||
poule: poule,
|
||||
@ -81,7 +81,7 @@ appServices.service('PouleService', function($http) {
|
||||
});
|
||||
};
|
||||
|
||||
this.deleteRace = function(idchampionship, tier, poule, idrace) {
|
||||
this.deleteRace = function (idchampionship, tier, poule, idrace) {
|
||||
return $http.post('server/deleterace.php', {
|
||||
tier: tier,
|
||||
poule: poule,
|
||||
@ -92,14 +92,14 @@ appServices.service('PouleService', function($http) {
|
||||
});
|
||||
|
||||
|
||||
appServices.service('TeamService', function($http) {
|
||||
this.getTeams = function(idchampionship) {
|
||||
appServices.service('TeamService', function ($http) {
|
||||
this.getTeams = function (idchampionship) {
|
||||
return $http.post('server/getteams.php', {
|
||||
idchampionship: idchampionship
|
||||
});
|
||||
};
|
||||
|
||||
this.getTeamsInPoule = function(idchampionship, tier, poule) {
|
||||
this.getTeamsInPoule = function (idchampionship, tier, poule) {
|
||||
return $http.post('server/getteams.php', {
|
||||
idchampionship: idchampionship,
|
||||
tier: tier,
|
||||
@ -107,7 +107,7 @@ appServices.service('TeamService', function($http) {
|
||||
});
|
||||
};
|
||||
|
||||
this.deleteTeam = function(team, idchampionship) {
|
||||
this.deleteTeam = function (team, idchampionship) {
|
||||
return $http.post('server/deleteteam.php', {
|
||||
idteam: team.idteam,
|
||||
idchampionship: idchampionship
|
||||
@ -117,7 +117,7 @@ appServices.service('TeamService', function($http) {
|
||||
/**
|
||||
* Filters: teams that are from the given championship and haven't been used in another poule...
|
||||
*/
|
||||
this.getTeamsAvailableForPoule = function(idchampionship, tier, poule) {
|
||||
this.getTeamsAvailableForPoule = function (idchampionship, tier, poule) {
|
||||
return $http.post('server/getteams.php', {
|
||||
idchampionship: idchampionship,
|
||||
tier: tier,
|
||||
@ -126,7 +126,7 @@ appServices.service('TeamService', function($http) {
|
||||
});
|
||||
};
|
||||
|
||||
this.addTeam = function(newteam, idchampionship) {
|
||||
this.addTeam = function (newteam, idchampionship) {
|
||||
console.log('adding team');
|
||||
return $http.post('server/addteam.php', {
|
||||
name: newteam.name,
|
||||
@ -136,21 +136,21 @@ appServices.service('TeamService', function($http) {
|
||||
});
|
||||
|
||||
|
||||
appServices.service('RaceService', function($http) {
|
||||
this.getDrives = function(idrace) {
|
||||
appServices.service('RaceService', function ($http) {
|
||||
this.getDrives = function (idrace) {
|
||||
return $http.post('server/getdrives.php', {
|
||||
idrace: idrace
|
||||
});
|
||||
};
|
||||
|
||||
this.getTeam = function(idrace) {
|
||||
this.getTeam = function (idrace) {
|
||||
return $http.post('server/getraceteam.php', {
|
||||
idrace: idrace
|
||||
});
|
||||
};
|
||||
|
||||
this.addDrive = function(race, driver, laps) {
|
||||
console.log('raceservice.adddrive got called: '+race+' '+driver.iddriver+' '+laps);
|
||||
this.addDrive = function (race, driver, laps) {
|
||||
console.log('raceservice.adddrive got called: ' + race + ' ' + driver.iddriver + ' ' + laps);
|
||||
return $http.post('server/adddrive.php', {
|
||||
idrace: race,
|
||||
iddriver: driver.iddriver,
|
||||
@ -158,21 +158,21 @@ appServices.service('RaceService', function($http) {
|
||||
});
|
||||
};
|
||||
|
||||
this.deleteDrive = function(drivenr, idrace) {
|
||||
this.deleteDrive = function (drivenr, idrace) {
|
||||
return $http.post('server/deletedrive.php', {
|
||||
drivenr: drivenr,
|
||||
idrace: idrace
|
||||
});
|
||||
};
|
||||
|
||||
this.addMeasurementNow = function(idrace) {
|
||||
this.addMeasurementNow = function (idrace) {
|
||||
return $http.post('server/addmeasurement.php', {
|
||||
type: 'now',
|
||||
idrace: idrace
|
||||
});
|
||||
};
|
||||
|
||||
this.addMeasurementRelative = function(idrace, timestamp) {
|
||||
this.addMeasurementRelative = function (idrace, timestamp) {
|
||||
return $http.post('server/addmeasurement.php', {
|
||||
type: 'relative',
|
||||
idrace: idrace,
|
||||
@ -180,20 +180,20 @@ appServices.service('RaceService', function($http) {
|
||||
});
|
||||
};
|
||||
|
||||
this.getMeasurements = function(idrace) {
|
||||
this.getMeasurements = function (idrace) {
|
||||
return $http.post('server/getmeasurements.php', {
|
||||
idrace: idrace
|
||||
});
|
||||
};
|
||||
|
||||
this.updateMeasurement = function(measurement) {
|
||||
this.updateMeasurement = function (measurement) {
|
||||
return $http.post('server/updatemeasurement.php', {
|
||||
idmeasurement: measurement.idmeasurement,
|
||||
valid: measurement.valid
|
||||
});
|
||||
};
|
||||
|
||||
this.deleteMeasurement = function(measurement) {
|
||||
this.deleteMeasurement = function (measurement) {
|
||||
console.log('deleting measurement');
|
||||
console.log(measurement);
|
||||
return $http.post('server/deletemeasurement.php', {
|
||||
@ -203,15 +203,15 @@ appServices.service('RaceService', function($http) {
|
||||
});
|
||||
|
||||
|
||||
appServices.service('DriverService', function($http) {
|
||||
this.getDrivers = function(idchampionship, idteam) {
|
||||
appServices.service('DriverService', function ($http) {
|
||||
this.getDrivers = function (idchampionship, idteam) {
|
||||
return $http.post('server/getdrivers.php', {
|
||||
idchampionship: idchampionship,
|
||||
idteam: idteam
|
||||
});
|
||||
};
|
||||
|
||||
this.addDriver = function(newdriver, idchampionship, idteam) {
|
||||
this.addDriver = function (newdriver, idchampionship, idteam) {
|
||||
console.log('adding driver');
|
||||
return $http.post('server/adddriver.php', {
|
||||
idchampionship: idchampionship,
|
||||
@ -220,7 +220,7 @@ appServices.service('DriverService', function($http) {
|
||||
});
|
||||
};
|
||||
|
||||
this.deleteDriver = function(driver) {
|
||||
this.deleteDriver = function (driver) {
|
||||
console.log('removing driver');
|
||||
return $http.post('server/deletedriver.php', {
|
||||
iddriver: driver.iddriver
|
||||
@ -228,8 +228,8 @@ appServices.service('DriverService', function($http) {
|
||||
};
|
||||
});
|
||||
|
||||
appServices.service('DriveService', function($http) {
|
||||
this.getComments = function(idrace, drivenr) {
|
||||
appServices.service('DriveService', function ($http) {
|
||||
this.getComments = function (idrace, drivenr) {
|
||||
console.log('getting comments for: ' + idrace + ' ' + drivenr);
|
||||
return $http.post('server/getcomments.php', {
|
||||
idrace: idrace,
|
||||
@ -237,7 +237,7 @@ appServices.service('DriveService', function($http) {
|
||||
});
|
||||
};
|
||||
|
||||
this.addComment = function(idrace, drivenr, comment, penaltyseconds) {
|
||||
this.addComment = function (idrace, drivenr, comment, penaltyseconds) {
|
||||
return $http.post('server/addcomment.php', {
|
||||
idrace: idrace,
|
||||
drivenr: drivenr,
|
||||
@ -246,13 +246,13 @@ appServices.service('DriveService', function($http) {
|
||||
});
|
||||
};
|
||||
|
||||
this.deleteComment = function(idcomment) {
|
||||
this.deleteComment = function (idcomment) {
|
||||
return $http.post('server/deletecomment.php', {
|
||||
idcomment: idcomment
|
||||
});
|
||||
};
|
||||
|
||||
this.deleteDriver = function(driver) {
|
||||
this.deleteDriver = function (driver) {
|
||||
console.log('removing driver');
|
||||
return $http.post('server/deletedriver.php', {
|
||||
iddriver: driver.iddriver
|
||||
@ -261,17 +261,17 @@ appServices.service('DriveService', function($http) {
|
||||
});
|
||||
|
||||
|
||||
appServices.service('OverviewService', function($http) {
|
||||
this.getData = function(idchampionship) {
|
||||
appServices.service('OverviewService', function ($http) {
|
||||
this.getData = function (idchampionship) {
|
||||
return $http.post('server/getoverviewofchampionship.php', {
|
||||
idchampionship: idchampionship
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
appServices.service('ViewerService', function($http) {
|
||||
appServices.service('ViewerService', function ($http) {
|
||||
|
||||
this.getTeamsForPoule = function(idchampionship, tier, poule) {
|
||||
this.getTeamsForPoule = function (idchampionship, tier, poule) {
|
||||
return $http.post('server/getteamsforpoule.php', {
|
||||
tier: tier,
|
||||
poule: poule,
|
||||
@ -280,15 +280,14 @@ appServices.service('ViewerService', function($http) {
|
||||
};
|
||||
});
|
||||
|
||||
appServices.service('MainService', function($http, $cookies) {
|
||||
appServices.service('MainService', function ($http, $cookies) {
|
||||
|
||||
var activerace = null;
|
||||
|
||||
this.refreshConfig = function() {
|
||||
this.refreshConfig = function () {
|
||||
$http.post('server/config.php', {
|
||||
action: 'getConfig'
|
||||
}).
|
||||
success(function(data, status, headers, config) {
|
||||
}).success(function (data, status, headers, config) {
|
||||
// console.log('refreshConfig successful...');
|
||||
//refresh activerace
|
||||
if (data.activeidrace != null) {
|
||||
@ -304,13 +303,12 @@ appServices.service('MainService', function($http, $cookies) {
|
||||
activerace = null;
|
||||
}
|
||||
// console.log(activerace);
|
||||
}).
|
||||
error(function(data, status, headers, config) {
|
||||
}).error(function (data, status, headers, config) {
|
||||
console.log('getConfig failed...');
|
||||
});
|
||||
};
|
||||
|
||||
this.setActiveRace = function(idrace, tier, poule, idchampionship) {
|
||||
this.setActiveRace = function (idrace, tier, poule, idchampionship) {
|
||||
if (idrace == null) {
|
||||
activerace = null;
|
||||
} else {
|
||||
@ -324,17 +322,16 @@ appServices.service('MainService', function($http, $cookies) {
|
||||
$http.post('server/config.php', {
|
||||
action: 'setActiveIdRace',
|
||||
idrace: idrace
|
||||
}).
|
||||
success(function(data, status, headers, config) {
|
||||
}).success(function (data, status, headers, config) {
|
||||
//do something?
|
||||
});
|
||||
};
|
||||
|
||||
this.getActiveRace = function() {
|
||||
this.getActiveRace = function () {
|
||||
return activerace;
|
||||
};
|
||||
|
||||
this.toggleActiveRace = function(idrace, tier, poule, idchampionship) {
|
||||
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) {
|
||||
@ -346,6 +343,20 @@ appServices.service('MainService', function($http, $cookies) {
|
||||
}
|
||||
};
|
||||
|
||||
this.togglePublishResults = function (race) {
|
||||
console.log('toggling publish results ' + race.idrace);
|
||||
$http.post('server/config.php', {
|
||||
action: 'togglePublishResults',
|
||||
idrace: race.idrace
|
||||
}).success(function (data, status, headers, config) {
|
||||
if (race.publishresults === 'f') {
|
||||
race.publishresults = 't';
|
||||
} else if (race.publishresults === 't') {
|
||||
race.publishresults = 'f';
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//load the current config
|
||||
this.refreshConfig();
|
||||
});
|
||||
|
||||
@ -1,74 +1,102 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="#/championships/">Kampioenschappen</a></li>
|
||||
<li><a href="#/championship/{{currentChampionship}}/poules">Poules voor {{currentChampionship}}</a></li>
|
||||
<li class="active">Races in poule/tier {{currentPoule}}/{{currentTier}}</li>
|
||||
</ol>
|
||||
</div></div>
|
||||
<div class="col-md-12">
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="#/championships/">Kampioenschappen</a></li>
|
||||
<li><a href="#/championship/{{currentChampionship}}/poules">Poules voor {{currentChampionship}}</a></li>
|
||||
<li class="active">Races in poule/tier {{currentPoule}}/{{currentTier}}</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Races</h3>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Races</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<table class="table table-condensed table-striped">
|
||||
<tr>
|
||||
<th>Team</th>
|
||||
<th>Raceid</th>
|
||||
<th>Totaaltijd</th>
|
||||
<th>Ritten</th>
|
||||
<th>Acties</th>
|
||||
</tr>
|
||||
<tr ng-repeat="race in racesInPoule">
|
||||
<td>{{race.name}}</td>
|
||||
<td>{{race.idrace}}</td>
|
||||
<td>{{race.totaltime | secondsToString}}</td>
|
||||
<td>{{race.lapagg}}</td>
|
||||
<td>
|
||||
<a class="btn btn-info btn-sm"
|
||||
href="#/championship/{{currentChampionship}}/poule/{{currentTier}}/{{currentPoule}}/race/{{race.idrace}}/measurements">
|
||||
Tijden <span class="badge">{{race.measurementcount}}</span>
|
||||
</a>
|
||||
<a class="btn btn-info btn-sm"
|
||||
href="#/championship/{{currentChampionship}}/poule/{{currentTier}}/{{currentPoule}}/race/{{race.idrace}}/drives">
|
||||
Ritten <span class="badge">{{race.drivecount}}</span>
|
||||
</a>
|
||||
<button type="button" class="btn btn-default btn-sm"
|
||||
ng-class="{'btn-success' : getActiveRace().idrace == race.idrace, 'btn-warning' : getActiveRace().idrace != race.idrace}"
|
||||
ng-click="toggleActiveRace(race)"
|
||||
title="Zet deze race actief om metingen te registreren">
|
||||
<span
|
||||
class="glyphicon"
|
||||
ng-class="{'glyphicon-play' : getActiveRace().idrace == race.idrace, 'glyphicon-pause' : getActiveRace().idrace != race.idrace}">
|
||||
</span>
|
||||
</button>
|
||||
<button type="button" class="btn btn-default btn-sm"
|
||||
ng-class="{'btn-success' : race.publishresults === 't', 'btn-warning' : race.publishresults === 'f'}"
|
||||
ng-click="togglePublishResults(race)"
|
||||
title="Maak de resultaten publiek voor de deelnemers">
|
||||
<span
|
||||
class="glyphicon"
|
||||
ng-class="{'glyphicon-eye-open' : race.publishresults === 't', 'glyphicon-eye-close' : race.publishresults === 'f'}">
|
||||
</span>
|
||||
</button>
|
||||
<a class="btn btn-danger btn-sm" href="" ng-click="deleteRace(race)"><span
|
||||
class="glyphicon glyphicon-remove" aria-hidden="true"></span></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<table class="table table-condensed table-striped">
|
||||
<tr><th>Team</th><th>Raceid</th><th>Totaaltijd</th><th>Ritten</th><th>Acties</th></tr>
|
||||
<tr ng-repeat="race in racesInPoule">
|
||||
<td>{{race.name}}</td>
|
||||
<td>{{race.idrace}}</td>
|
||||
<td>{{race.totaltime | secondsToString}}</td>
|
||||
<td>{{race.lapagg}}</td>
|
||||
<td>
|
||||
<a class="btn btn-info btn-sm" href="#/championship/{{currentChampionship}}/poule/{{currentTier}}/{{currentPoule}}/race/{{race.idrace}}/measurements">
|
||||
Tijden <span class="badge">{{race.measurementcount}}</span>
|
||||
</a>
|
||||
<a class="btn btn-info btn-sm" href="#/championship/{{currentChampionship}}/poule/{{currentTier}}/{{currentPoule}}/race/{{race.idrace}}/drives">
|
||||
Ritten <span class="badge">{{race.drivecount}}</span>
|
||||
</a>
|
||||
<button type="button" class="btn btn-default btn-sm"
|
||||
ng-class="{'btn-success' : getActiveRace().idrace == race.idrace, 'btn-warning' : getActiveRace().idrace != race.idrace}"
|
||||
ng-click="toggleActiveRace(race)" title="Zet deze race actief om metingen te registreren">
|
||||
<span
|
||||
class="glyphicon"
|
||||
ng-class="{'glyphicon-play' : getActiveRace().idrace == race.idrace, 'glyphicon-pause' : getActiveRace().idrace != race.idrace}"
|
||||
</span>
|
||||
</button>
|
||||
<a class="btn btn-danger btn-sm" href="" ng-click="deleteRace(race)"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Voeg race toe</h3>
|
||||
<div class="col-md-4">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Voeg race toe</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Met een team uit de poule...</div>
|
||||
<div class="panel-body">
|
||||
<div class="list-group">
|
||||
<a href="" class="list-group-item list-group-item-sm" ng-repeat="team in teamsInPoule"
|
||||
ng-click="setSelectedTeam(team)"
|
||||
ng-class="{active: selectedTeam==team}">{{team.name}}</a>
|
||||
</div>
|
||||
<button type="button" class="btn btn-success" ng-click="addRace(newrace);"
|
||||
ng-disabled="selectedTeam == null"
|
||||
title="Maak een nieuwe race aan voor het geselecteerde team.">Maak nieuwe race
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Met alle teams...</div>
|
||||
<div class="panel-body">
|
||||
<button type="button" class="btn btn-success" ng-disabled="teamsInPoule.length == 0"
|
||||
ng-click="addRaceForAllteams();"
|
||||
title="Maak nieuwe races aan voor alle bovenstaande teams.">Maak race voor elk team
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- end row -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Met een team uit de poule...</div>
|
||||
<div class="panel-body">
|
||||
<div class="list-group">
|
||||
<a href="" class="list-group-item list-group-item-sm" ng-repeat="team in teamsInPoule" ng-click="setSelectedTeam(team)" ng-class="{active: selectedTeam==team}">{{team.name}}</a>
|
||||
</div>
|
||||
<button type="button" class="btn btn-success" ng-click="addRace(newrace);" ng-disabled="selectedTeam == null" title="Maak een nieuwe race aan voor het geselecteerde team.">Maak nieuwe race</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Met alle teams...</div>
|
||||
<div class="panel-body">
|
||||
<button type="button" class="btn btn-success" ng-disabled="teamsInPoule.length == 0" ng-click="addRaceForAllteams();" title="Maak nieuwe races aan voor alle bovenstaande teams.">Maak race voor elk team</button>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- end row -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,26 +1,30 @@
|
||||
<?php
|
||||
include_once("db.php");
|
||||
include_once("db.php");
|
||||
|
||||
//make result object
|
||||
$result = array();
|
||||
$result['ok'] = false;
|
||||
//make result object
|
||||
$result = array();
|
||||
$result['ok'] = false;
|
||||
|
||||
//get post data
|
||||
$postdata = file_get_contents("php://input");
|
||||
$post = json_decode($postdata, true);
|
||||
//get post data
|
||||
$postdata = file_get_contents("php://input");
|
||||
$post = json_decode($postdata, true);
|
||||
|
||||
$action = $post['action'];
|
||||
$action = $post['action'];
|
||||
|
||||
if($action == 'setActiveIdRace') {
|
||||
$idrace = $post['idrace'];
|
||||
$setactiverace= pg_prepare($dbconn, "setactiverace", "update config set activerace = $1");
|
||||
$setactiverace= pg_execute($dbconn, "setactiverace", array($idrace));
|
||||
} else if($action == 'getConfig') {
|
||||
$getconfig= pg_prepare($dbconn, "getconfig", "select activerace activeidrace, tier, poule, idchampionship from config inner join race on activerace = idrace");
|
||||
$getconfig= pg_execute($dbconn, "getconfig", array());
|
||||
$result = pg_fetch_assoc($getconfig);
|
||||
//print message
|
||||
$resultjson = json_encode($result);
|
||||
echo $resultjson;
|
||||
}
|
||||
if ($action == 'setActiveIdRace') {
|
||||
$idrace = $post['idrace'];
|
||||
$setactiverace = pg_prepare($dbconn, "setactiverace", "update config set activerace = $1");
|
||||
$setactiverace = pg_execute($dbconn, "setactiverace", array($idrace));
|
||||
} else if ($action == 'togglePublishResults') {
|
||||
$idrace = $post['idrace'];
|
||||
$togglepublishresults = pg_prepare($dbconn, "togglepublishresults", "update race set publishresults = not publishresults where idrace = $1");
|
||||
$togglepublishresults = pg_execute($dbconn, "togglepublishresults", array($idrace));
|
||||
} else if ($action == 'getConfig') {
|
||||
$getconfig = pg_prepare($dbconn, "getconfig", "select activerace activeidrace, tier, poule, idchampionship from config inner join race on activerace = idrace");
|
||||
$getconfig = pg_execute($dbconn, "getconfig", array());
|
||||
$result = pg_fetch_assoc($getconfig);
|
||||
//print message
|
||||
$resultjson = json_encode($result);
|
||||
echo $resultjson;
|
||||
}
|
||||
?>
|
||||
|
||||
@ -14,12 +14,12 @@
|
||||
$poule = $post['poule'];
|
||||
|
||||
//fetch the championships
|
||||
$racefetch = pg_prepare($dbconn, "racefetch", "select team.*, race.idrace, (select string_agg(laps||'', ',') lapagg
|
||||
$racefetch = pg_prepare($dbconn, "racefetch", "select team.*, race.publishresults, race.idrace, (select string_agg(laps||'', ',') lapagg
|
||||
from drive where drive.idrace = race.idrace),
|
||||
(select extract(epoch from max(case when sensortime is null then timestamp else sensortime end)-min(case when sensortime is null then timestamp else sensortime end)) from measurement where valid and idrace = race.idrace) as totaltime,
|
||||
(select count(*) from measurement where idrace = race.idrace) measurementcount,
|
||||
(select count(*) from drive where idrace = race.idrace) drivecount from team inner join race using (idteam, idchampionship)
|
||||
where idchampionship = $1 and tier = $2 and poule = $3");
|
||||
where idchampionship = $1 and tier = $2 and poule = $3 order by race.idrace");
|
||||
$racefetch = pg_execute($dbconn, "racefetch", array($idchampionship, $tier, $poule));
|
||||
|
||||
//build result object
|
||||
|
||||
Loading…
Reference in New Issue
Block a user