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);
|
console.log(data);
|
||||||
if(data['ok']==true) {
|
if(data['ok']==true) {
|
||||||
$scope.racesInPoule = data.races;
|
$scope.racesInPoule = data.races;
|
||||||
|
console.log('got races: ');
|
||||||
|
console.log(data.races);
|
||||||
} else {
|
} else {
|
||||||
console.log('getRacesInPoule call returned but wasnt ok: '+data['error']);
|
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);
|
MainService.toggleActiveRace(race.idrace, tier, poule, idchampionship);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.togglePublishResults = function(race) {
|
||||||
|
MainService.togglePublishResults(race);
|
||||||
|
};
|
||||||
|
|
||||||
$scope.getActiveRace = function() {
|
$scope.getActiveRace = function() {
|
||||||
return MainService.getActiveRace();
|
return MainService.getActiveRace();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -287,8 +287,7 @@ appServices.service('MainService', function($http, $cookies) {
|
|||||||
this.refreshConfig = function () {
|
this.refreshConfig = function () {
|
||||||
$http.post('server/config.php', {
|
$http.post('server/config.php', {
|
||||||
action: 'getConfig'
|
action: 'getConfig'
|
||||||
}).
|
}).success(function (data, status, headers, config) {
|
||||||
success(function(data, status, headers, config) {
|
|
||||||
// console.log('refreshConfig successful...');
|
// console.log('refreshConfig successful...');
|
||||||
//refresh activerace
|
//refresh activerace
|
||||||
if (data.activeidrace != null) {
|
if (data.activeidrace != null) {
|
||||||
@ -304,8 +303,7 @@ appServices.service('MainService', function($http, $cookies) {
|
|||||||
activerace = null;
|
activerace = null;
|
||||||
}
|
}
|
||||||
// console.log(activerace);
|
// console.log(activerace);
|
||||||
}).
|
}).error(function (data, status, headers, config) {
|
||||||
error(function(data, status, headers, config) {
|
|
||||||
console.log('getConfig failed...');
|
console.log('getConfig failed...');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -324,8 +322,7 @@ appServices.service('MainService', function($http, $cookies) {
|
|||||||
$http.post('server/config.php', {
|
$http.post('server/config.php', {
|
||||||
action: 'setActiveIdRace',
|
action: 'setActiveIdRace',
|
||||||
idrace: idrace
|
idrace: idrace
|
||||||
}).
|
}).success(function (data, status, headers, config) {
|
||||||
success(function(data, status, headers, config) {
|
|
||||||
//do something?
|
//do something?
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -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
|
//load the current config
|
||||||
this.refreshConfig();
|
this.refreshConfig();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -5,7 +5,8 @@
|
|||||||
<li><a href="#/championship/{{currentChampionship}}/poules">Poules voor {{currentChampionship}}</a></li>
|
<li><a href="#/championship/{{currentChampionship}}/poules">Poules voor {{currentChampionship}}</a></li>
|
||||||
<li class="active">Races in poule/tier {{currentPoule}}/{{currentTier}}</li>
|
<li class="active">Races in poule/tier {{currentPoule}}/{{currentTier}}</li>
|
||||||
</ol>
|
</ol>
|
||||||
</div></div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
@ -15,28 +16,47 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<table class="table table-condensed table-striped">
|
<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>
|
||||||
|
<th>Team</th>
|
||||||
|
<th>Raceid</th>
|
||||||
|
<th>Totaaltijd</th>
|
||||||
|
<th>Ritten</th>
|
||||||
|
<th>Acties</th>
|
||||||
|
</tr>
|
||||||
<tr ng-repeat="race in racesInPoule">
|
<tr ng-repeat="race in racesInPoule">
|
||||||
<td>{{race.name}}</td>
|
<td>{{race.name}}</td>
|
||||||
<td>{{race.idrace}}</td>
|
<td>{{race.idrace}}</td>
|
||||||
<td>{{race.totaltime | secondsToString}}</td>
|
<td>{{race.totaltime | secondsToString}}</td>
|
||||||
<td>{{race.lapagg}}</td>
|
<td>{{race.lapagg}}</td>
|
||||||
<td>
|
<td>
|
||||||
<a class="btn btn-info btn-sm" href="#/championship/{{currentChampionship}}/poule/{{currentTier}}/{{currentPoule}}/race/{{race.idrace}}/measurements">
|
<a class="btn btn-info btn-sm"
|
||||||
|
href="#/championship/{{currentChampionship}}/poule/{{currentTier}}/{{currentPoule}}/race/{{race.idrace}}/measurements">
|
||||||
Tijden <span class="badge">{{race.measurementcount}}</span>
|
Tijden <span class="badge">{{race.measurementcount}}</span>
|
||||||
</a>
|
</a>
|
||||||
<a class="btn btn-info btn-sm" href="#/championship/{{currentChampionship}}/poule/{{currentTier}}/{{currentPoule}}/race/{{race.idrace}}/drives">
|
<a class="btn btn-info btn-sm"
|
||||||
|
href="#/championship/{{currentChampionship}}/poule/{{currentTier}}/{{currentPoule}}/race/{{race.idrace}}/drives">
|
||||||
Ritten <span class="badge">{{race.drivecount}}</span>
|
Ritten <span class="badge">{{race.drivecount}}</span>
|
||||||
</a>
|
</a>
|
||||||
<button type="button" class="btn btn-default btn-sm"
|
<button type="button" class="btn btn-default btn-sm"
|
||||||
ng-class="{'btn-success' : getActiveRace().idrace == race.idrace, 'btn-warning' : getActiveRace().idrace != race.idrace}"
|
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">
|
ng-click="toggleActiveRace(race)"
|
||||||
|
title="Zet deze race actief om metingen te registreren">
|
||||||
<span
|
<span
|
||||||
class="glyphicon"
|
class="glyphicon"
|
||||||
ng-class="{'glyphicon-play' : getActiveRace().idrace == race.idrace, 'glyphicon-pause' : getActiveRace().idrace != race.idrace}"
|
ng-class="{'glyphicon-play' : getActiveRace().idrace == race.idrace, 'glyphicon-pause' : getActiveRace().idrace != race.idrace}">
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<a class="btn btn-danger btn-sm" href="" ng-click="deleteRace(race)"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a>
|
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@ -56,16 +76,24 @@
|
|||||||
<div class="panel-heading">Met een team uit de poule...</div>
|
<div class="panel-heading">Met een team uit de poule...</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="list-group">
|
<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>
|
<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>
|
</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>
|
<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>
|
</div>
|
||||||
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">Met alle teams...</div>
|
<div class="panel-heading">Met alle teams...</div>
|
||||||
<div class="panel-body">
|
<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>
|
<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>
|
</div>
|
||||||
</div><!-- end row -->
|
</div><!-- end row -->
|
||||||
|
|||||||
@ -15,6 +15,10 @@
|
|||||||
$idrace = $post['idrace'];
|
$idrace = $post['idrace'];
|
||||||
$setactiverace = pg_prepare($dbconn, "setactiverace", "update config set activerace = $1");
|
$setactiverace = pg_prepare($dbconn, "setactiverace", "update config set activerace = $1");
|
||||||
$setactiverace = pg_execute($dbconn, "setactiverace", array($idrace));
|
$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') {
|
} 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_prepare($dbconn, "getconfig", "select activerace activeidrace, tier, poule, idchampionship from config inner join race on activerace = idrace");
|
||||||
$getconfig = pg_execute($dbconn, "getconfig", array());
|
$getconfig = pg_execute($dbconn, "getconfig", array());
|
||||||
|
|||||||
@ -14,12 +14,12 @@
|
|||||||
$poule = $post['poule'];
|
$poule = $post['poule'];
|
||||||
|
|
||||||
//fetch the championships
|
//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),
|
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 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 measurement where idrace = race.idrace) measurementcount,
|
||||||
(select count(*) from drive where idrace = race.idrace) drivecount from team inner join race using (idteam, idchampionship)
|
(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));
|
$racefetch = pg_execute($dbconn, "racefetch", array($idchampionship, $tier, $poule));
|
||||||
|
|
||||||
//build result object
|
//build result object
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user