dashboard: update display only when all calculation done

This commit is contained in:
nemunaire 2021-03-21 20:46:12 +01:00
parent 5500712d60
commit 12c74ebbb3

View File

@ -109,22 +109,26 @@ angular.module("AdLinApp")
.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) {
var student = Student.get({studentId: $scope.onestudent})
student.$promise.then(function(stdnt) {
$scope.student = stdnt
$http.get("/api/students/" + $scope.student.id + "/ips").then(function(response) {
$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) {
refreshStd();