dashboard: ping + stats
This commit is contained in:
parent
f50638048f
commit
23c286ea3e
2 changed files with 50 additions and 4 deletions
|
@ -13,6 +13,7 @@ var tuto_progress = [
|
|||
100: { title: "HTTP", label: "HTTP"},
|
||||
101: { title: "HTTPS", label: "HTTPS"},
|
||||
102: { title: "DNS", label: "DNS"},
|
||||
103: { title: "Matrix", label: "Matrix"},
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -43,9 +44,13 @@ angular.module("AdLinApp")
|
|||
})
|
||||
.controller("PingController", function($scope, $interval, $http) {
|
||||
$scope.PING = false;
|
||||
$scope.PING_time = '';
|
||||
var refreshPing = function() {
|
||||
$http.get("/api/students/" + $scope.student.id + "/ping").then(function(response) {
|
||||
$scope.PING = response.data
|
||||
$scope.PING_time = new Date(response.data);
|
||||
$scope.PINGw = new Date(Date.now() - 864000000) < $scope.PING_time;
|
||||
$scope.PINGi = new Date(Date.now() - 900000) < $scope.PING_time;
|
||||
$scope.PING = new Date(Date.now() - 90000) < $scope.PING_time;
|
||||
});
|
||||
}
|
||||
refreshPing();
|
||||
|
@ -61,6 +66,35 @@ angular.module("AdLinApp")
|
|||
refreshSSH();
|
||||
$interval(refreshSSH, 15500);
|
||||
})
|
||||
.controller("ProgressStatsController", function($scope, $interval, $http) {
|
||||
$scope.tuto_progress = tuto_progress;
|
||||
$scope.stats = {};
|
||||
var refreshChal = function() {
|
||||
var recent = new Date(Date.now() - 120000);
|
||||
var tmpstats = {total:0};
|
||||
angular.forEach(tuto_progress, function(tuto) {
|
||||
angular.forEach(tuto, function(ch, chid) {
|
||||
tmpstats[chid] = {"success":0, "warning":0};
|
||||
});
|
||||
});
|
||||
$http.get("/api/progress/").then(function(response) {
|
||||
angular.forEach(response.data, function(challenges, login) {
|
||||
tmpstats.total++;
|
||||
angular.forEach(challenges, function(ch, chid) {
|
||||
tmpstats[chid].warning++;
|
||||
if (ch.time) {
|
||||
challenges[chid].time = new Date(ch.time);
|
||||
if (recent < challenges[chid].time)
|
||||
tmpstats[chid].success++;
|
||||
}
|
||||
});
|
||||
});
|
||||
$scope.stats = tmpstats;
|
||||
});
|
||||
}
|
||||
refreshChal();
|
||||
$interval(refreshChal, 14750);
|
||||
})
|
||||
.controller("ProgressionController", function($scope, $interval, $http) {
|
||||
$scope.tuto_progress = tuto_progress;
|
||||
$scope.mychallenges = {};
|
||||
|
|
Reference in a new issue