From 12c74ebbb37d9588aa9f2771c8e27d21b02e1068 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Sun, 21 Mar 2021 20:46:12 +0100 Subject: [PATCH] dashboard: update display only when all calculation done --- token-validator/htdocs/js/adlin-dashboard.js | 28 +++++++++++--------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/token-validator/htdocs/js/adlin-dashboard.js b/token-validator/htdocs/js/adlin-dashboard.js index 8737bd9..cf2d6ee 100644 --- a/token-validator/htdocs/js/adlin-dashboard.js +++ b/token-validator/htdocs/js/adlin-dashboard.js @@ -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();