token-validator: update dashboard: include visualization for individual student
This commit is contained in:
parent
9f909b9cba
commit
85ad80a671
5 changed files with 130 additions and 39 deletions
|
@ -36,7 +36,7 @@ angular.module("AdLinApp", ["ngResource", "ngSanitize"])
|
|||
return $resource("/api/progress")
|
||||
})
|
||||
.factory("StudentProgression", function($resource) {
|
||||
return $resource("/api/dashboard.json")
|
||||
return $resource("/api/students/:studentId/progress", { studentId: '@id' })
|
||||
})
|
||||
.factory("Challenge", function($resource) {
|
||||
return $resource("/challenge/:challengeId", { challengeId: '@id' })
|
||||
|
@ -46,11 +46,18 @@ angular.module("AdLinApp")
|
|||
.run(function($rootScope, $location) {
|
||||
if (window.location.pathname.split("/").length >= 3) {
|
||||
$rootScope.tutoid = parseInt(window.location.pathname.split("/")[2], 10);
|
||||
if (isNaN($rootScope.tutoid)) {
|
||||
$rootScope.onestudent = window.location.pathname.split("/")[2];
|
||||
}
|
||||
}
|
||||
if (!$rootScope.tutoid || isNaN($rootScope.tutoid)) {
|
||||
$rootScope.tutoid = 1;
|
||||
}
|
||||
$rootScope.tutoid--;
|
||||
$rootScope.show_dropdown = false;
|
||||
$rootScope.toogleDropdown = function() {
|
||||
$rootScope.show_dropdown = !$rootScope.show_dropdown;
|
||||
}
|
||||
})
|
||||
.controller("StudentsController", function($scope, $interval, Student) {
|
||||
$scope.students = Student.query();
|
||||
|
@ -103,19 +110,48 @@ angular.module("AdLinApp")
|
|||
refreshStd();
|
||||
$interval(refreshStd, 9750);
|
||||
})
|
||||
.controller("StudentProgressionController", function($scope, $interval, $http, Student, StudentProgression) {
|
||||
$scope.tuto_progress = tuto_progress;
|
||||
var refreshStd = function() {
|
||||
$scope.student = Student.get({studentId: $scope.onestudent})
|
||||
$scope.img = $scope.onestudent == "nemunaire" ? "mercie_d" : $scope.onestudent
|
||||
$scope.mychallenges = StudentProgression.get({studentId: $scope.onestudent})
|
||||
$scope.mychallenges.$promise.then(function(mychallenges) {
|
||||
angular.forEach(mychallenges, function(ch, chid) {
|
||||
if (ch.time) {
|
||||
mychallenges[chid].time = new Date(ch.time);
|
||||
mychallenges[chid].recent = (Date.now() - mychallenges[chid].time)/1000;
|
||||
}
|
||||
});
|
||||
})
|
||||
$scope.student.$promise.then(function(student) {
|
||||
$http.get("/api/students/" + $scope.student.id + "/ips").then(function(response) {
|
||||
$scope.ips = response.data;
|
||||
});
|
||||
})
|
||||
}
|
||||
$scope.$watch("onestudent", function(onestudent) {
|
||||
refreshStd();
|
||||
$interval(refreshStd, 15000);
|
||||
})
|
||||
})
|
||||
.controller("PingController", function($scope, $interval, $http) {
|
||||
$scope.PING = false;
|
||||
$scope.PING_time = '';
|
||||
$scope.PING_ok = false;
|
||||
var refreshPing = function() {
|
||||
var refreshPing = function() {
|
||||
$http.get("/api/students/" + $scope.student.id + "/ping").then(function(response) {
|
||||
$scope.PING_ok = response.data.State;
|
||||
$scope.PING_time = new Date(response.data.Date);
|
||||
$scope.PING = (Date.now() - $scope.PING_time)/1000;
|
||||
});
|
||||
}
|
||||
refreshPing();
|
||||
$interval(refreshPing, 15000);
|
||||
$scope.$watch("student", function(student) {
|
||||
student.$promise.then(function(std) {
|
||||
refreshPing();
|
||||
$interval(refreshPing, 15000);
|
||||
})
|
||||
})
|
||||
})
|
||||
.controller("SSHController", function($scope, $interval, $http) {
|
||||
$scope.SSH = false;
|
||||
|
|
Reference in a new issue