admin: fix and generalize team stats
This commit is contained in:
parent
0eb15a9a9c
commit
8d6397d1ac
2 changed files with 12 additions and 10 deletions
|
@ -35,7 +35,7 @@ angular.module("FICApp", ["ngRoute", "ngResource", "ngSanitize"])
|
|||
})
|
||||
.when("/teams/:teamId/stats", {
|
||||
controller: "TeamController",
|
||||
templateUrl: "views/team.html"
|
||||
templateUrl: "views/team-stats.html"
|
||||
})
|
||||
.when("/teams/new", {
|
||||
controller: "TeamNewController",
|
||||
|
@ -605,10 +605,10 @@ angular.module("FICApp")
|
|||
.controller("PresenceController", function($scope, TeamPresence, $routeParams) {
|
||||
$scope.presence = TeamPresence.query({ teamId: $routeParams.teamId });
|
||||
$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 = {};
|
||||
function updTime() {
|
||||
$timeout.cancel($scope.cbm);
|
||||
|
@ -643,6 +643,7 @@ angular.module("FICApp")
|
|||
$scope.time.hours = Math.floor(remain / 3600);
|
||||
$scope.time.minutes = Math.floor((remain % 3600) / 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; });
|
||||
}
|
||||
|
||||
function presenceCal(location, data) {
|
||||
function presenceCal(scope, location, data) {
|
||||
var width = d3.select(location).node().getBoundingClientRect().width,
|
||||
height = 80,
|
||||
cellSize = 17; // cell size
|
||||
|
@ -808,7 +809,7 @@ function presenceCal(location, data) {
|
|||
.range(d3.range(8).map(function(d) { return "q" + d + "-8"; }));
|
||||
|
||||
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")
|
||||
.attr("width", width)
|
||||
.attr("height", height)
|
||||
|
@ -819,14 +820,15 @@ function presenceCal(location, data) {
|
|||
svg.append("text")
|
||||
.attr("transform", "translate(-6," + cellSize * 2.6 + ")rotate(-90)")
|
||||
.style("text-anchor", "middle")
|
||||
.text(function(d) { return d + "-02"; });
|
||||
.text(function(d) { return d.getDate() + "-" + (d.getMonth() + 1); });
|
||||
|
||||
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")
|
||||
.attr("width", 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();
|
||||
dv = d.getTime();
|
||||
return prev + ((dv <= cur && cur < dv+15*60000)?1:0);
|
||||
|
|
Reference in a new issue