dashboard: update display only when all calculation done
This commit is contained in:
parent
5500712d60
commit
12c74ebbb3
|
@ -109,22 +109,26 @@ angular.module("AdLinApp")
|
||||||
.controller("StudentProgressionController", function($scope, $interval, $http, Student, StudentProgression) {
|
.controller("StudentProgressionController", function($scope, $interval, $http, Student, StudentProgression) {
|
||||||
$scope.tuto_progress = tuto_progress;
|
$scope.tuto_progress = tuto_progress;
|
||||||
var refreshStd = function() {
|
var refreshStd = function() {
|
||||||
$scope.student = Student.get({studentId: $scope.onestudent})
|
var student = Student.get({studentId: $scope.onestudent})
|
||||||
$scope.img = $scope.onestudent == "nemunaire" ? "mercie_d" : $scope.onestudent
|
student.$promise.then(function(stdnt) {
|
||||||
$scope.mychallenges = StudentProgression.get({studentId: $scope.onestudent})
|
$scope.student = stdnt
|
||||||
$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) {
|
$http.get("/api/students/" + $scope.student.id + "/ips").then(function(response) {
|
||||||
$scope.ips = response.data;
|
$scope.ips = response.data;
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
var mychallenges = StudentProgression.get({studentId: $scope.onestudent})
|
||||||
|
mychallenges.$promise.then(function(mychals) {
|
||||||
|
angular.forEach(mychals, function(ch, chid) {
|
||||||
|
if (ch.time) {
|
||||||
|
mychals[chid].time = new Date(ch.time);
|
||||||
|
mychals[chid].recent = (Date.now() - mychals[chid].time)/1000;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$scope.mychallenges = mychals
|
||||||
|
})
|
||||||
|
|
||||||
|
$scope.img = $scope.onestudent == "nemunaire" ? "mercie_d" : $scope.onestudent
|
||||||
}
|
}
|
||||||
$scope.$watch("onestudent", function(onestudent) {
|
$scope.$watch("onestudent", function(onestudent) {
|
||||||
refreshStd();
|
refreshStd();
|
||||||
|
|
Reference in New Issue
Block a user