admin: fix and generalize team stats

This commit is contained in:
nemunaire 2017-04-02 11:38:40 +02:00 committed by Pierre-Olivier Mercier
parent dea178b7ba
commit 963c6ff4f2
2 changed files with 12 additions and 10 deletions

View File

@ -35,7 +35,7 @@ angular.module("FICApp", ["ngRoute", "ngResource", "ngSanitize"])
}) })
.when("/teams/:teamId/stats", { .when("/teams/:teamId/stats", {
controller: "TeamController", controller: "TeamController",
templateUrl: "views/team.html" templateUrl: "views/team-stats.html"
}) })
.when("/teams/new", { .when("/teams/new", {
controller: "TeamNewController", controller: "TeamNewController",
@ -605,10 +605,10 @@ angular.module("FICApp")
.controller("PresenceController", function($scope, TeamPresence, $routeParams) { .controller("PresenceController", function($scope, TeamPresence, $routeParams) {
$scope.presence = TeamPresence.query({ teamId: $routeParams.teamId }); $scope.presence = TeamPresence.query({ teamId: $routeParams.teamId });
$scope.presence.$promise.then(function(res) { $scope.presence.$promise.then(function(res) {
presenceCal("#presenceCal", res); presenceCal($scope, "#presenceCal", res);
}); });
}) })
.controller("CountdownController", function($scope, $http, $timeout) { .controller("CountdownController", function($scope, $rootScope, $http, $timeout) {
$scope.time = {}; $scope.time = {};
function updTime() { function updTime() {
$timeout.cancel($scope.cbm); $timeout.cancel($scope.cbm);
@ -643,6 +643,7 @@ angular.module("FICApp")
$scope.time.hours = Math.floor(remain / 3600); $scope.time.hours = Math.floor(remain / 3600);
$scope.time.minutes = Math.floor((remain % 3600) / 60); $scope.time.minutes = Math.floor((remain % 3600) / 60);
$scope.time.seconds = Math.floor(remain % 60); $scope.time.seconds = Math.floor(remain % 60);
$rootScope.time = $scope.time;
} }
} }
@ -795,7 +796,7 @@ function solvedByThemesPie(location, data) {
.text(function(d) { return d.data.tip + ": " + d.data.tries; }); .text(function(d) { return d.data.tip + ": " + d.data.tries; });
} }
function presenceCal(location, data) { function presenceCal(scope, location, data) {
var width = d3.select(location).node().getBoundingClientRect().width, var width = d3.select(location).node().getBoundingClientRect().width,
height = 80, height = 80,
cellSize = 17; // cell size cellSize = 17; // cell size
@ -808,7 +809,7 @@ function presenceCal(location, data) {
.range(d3.range(8).map(function(d) { return "q" + d + "-8"; })); .range(d3.range(8).map(function(d) { return "q" + d + "-8"; }));
var svg = d3.select(location).selectAll("svg") var svg = d3.select(location).selectAll("svg")
.data(d3.range(26, 29)) .data(d3.range(scope.time.start, scope.time.start + (scope.time.start % 86400000 + scope.time.duration), 86400000).map(function(t) { return new Date(t); }))
.enter().append("svg") .enter().append("svg")
.attr("width", width) .attr("width", width)
.attr("height", height) .attr("height", height)
@ -819,14 +820,15 @@ function presenceCal(location, data) {
svg.append("text") svg.append("text")
.attr("transform", "translate(-6," + cellSize * 2.6 + ")rotate(-90)") .attr("transform", "translate(-6," + cellSize * 2.6 + ")rotate(-90)")
.style("text-anchor", "middle") .style("text-anchor", "middle")
.text(function(d) { return d + "-02"; }); .text(function(d) { return d.getDate() + "-" + (d.getMonth() + 1); });
var rect = svg.selectAll(".quarter") var rect = svg.selectAll(".quarter")
.data(function(d) { return d3.time.minutes(new Date(2016, 1, d, 0), new Date(2016, 1, d, 24), 15); }) .data(function(d) { return d3.time.minutes(new Date(d.getFullYear(), d.getMonth(), d.getDate(), 0), new Date(d.getFullYear(), d.getMonth(), d.getDate(), 23), 15); })
.enter().append("rect") .enter().append("rect")
.attr("width", cellSize) .attr("width", cellSize)
.attr("height", cellSize) .attr("height", cellSize)
.attr("class", function(d) { return color(data.reduce(function(prev, cur){ .attr("transform", function(d) { return "translate(" + (d.getHours() * cellSize) + "," + (d.getMinutes() / 15 * cellSize) + ")"; })
.attr("class", function(d) { if (d >= scope.time.start && d < scope.time.start + scope.time.duration) return color(data.reduce(function(prev, cur){
cur = new Date(cur).getTime(); cur = new Date(cur).getTime();
dv = d.getTime(); dv = d.getTime();
return prev + ((dv <= cur && cur < dv+15*60000)?1:0); return prev + ((dv <= cur && cur < dv+15*60000)?1:0);

View File

@ -9,7 +9,7 @@
.RdYlGn .q7-8{fill:rgb(70,80,80)} .RdYlGn .q7-8{fill:rgb(70,80,80)}
</style> </style>
<h1>{{ team.name }}<span ng-show="team.name != team.initialName"> ({{ team.initialName}})</span> <small><span ng-repeat="member in members"><span ng-show="$last && !$first"> et </span><span ng-show="$middle">, </span>{{ member.firstname | capitalize }} <em ng-show="member.nickname">{{ member.nickname }}</em> {{ member.lastname | capitalize }}</span></small></h1> <h1>{{ team.name }}<span ng-if="team.name != team.initialName"> ({{ team.initialName}})</span> <small><span ng-repeat="member in members"><span ng-if="$last && !$first"> et </span><span ng-if="$middle">, </span>{{ member.firstname | capitalize }} <em ng-if="member.nickname">{{ member.nickname }}</em> {{ member.lastname | capitalize }}</span></small></h1>
<div ng-controller="TeamExercicesController"> <div ng-controller="TeamExercicesController">
@ -32,7 +32,7 @@
<dt>{{ theme.name }}</dt> <dt>{{ theme.name }}</dt>
<dd> <dd>
<ul class="list-unstyled"> <ul class="list-unstyled">
<li ng-repeat="(eid,exercice) in theme.exercices" ng-show="my.exercices[eid] && my.exercices[eid].solved"><a href="https://fic.srs.epita.fr/{{ my.exercices[eid].theme_id }}/{{ eid }}" target="_blank"><abbr title="{{ my.exercices[eid].statement }}">{{ exercice.title }}</abbr></a> (<abbr title="{{ my.exercices[eid].solved_time | date:'mediumDate' }} à {{ my.exercices[eid].solved_time | date:'mediumTime' }}">{{ my.exercices[eid].solved_number }}<sup>e</sup></abbr>)</li> <li ng-repeat="(eid,exercice) in theme.exercices" ng-if="my.exercices[eid] && my.exercices[eid].solved_rank"><a href="/{{ my.exercices[eid].theme_id }}/{{ eid }}" target="_blank"><abbr title="{{ my.exercices[eid].statement }}">{{ exercice.title }}</abbr></a> (<abbr title="{{ my.exercices[eid].solved_time | date:'mediumDate' }} à {{ my.exercices[eid].solved_time | date:'mediumTime' }}">{{ my.exercices[eid].solved_rank }}<sup>e</sup></abbr>)</li>
</ul> </ul>
</dd> </dd>
</div> </div>