dashboard: can now change the sidebar

This commit is contained in:
nemunaire 2019-01-19 08:01:29 +01:00
commit a4e0a90adf
7 changed files with 410 additions and 57 deletions

View file

@ -1,5 +1,5 @@
angular.module("FICApp", ["ngSanitize", "ngAnimate"])
.controller("EventsController", function($scope, $http, $interval) {
.controller("EventsController", function($scope, $rootScope, $http, $interval) {
$scope.events = [];
var refreshEvents = function() {
// Update times
@ -14,12 +14,27 @@ angular.module("FICApp", ["ngSanitize", "ngAnimate"])
return;
$scope.lasteventsetag = response.headers()["last-modified"];
var lastExercice = undefined;
$scope.events = response.data;
$scope.events.forEach(function(event) {
if (!lastExercice && $scope.themes) {
var res = event.txt.match(/<strong>(\d+)<sup>e<\/sup><\/strong> défi ([^&]+)/);
if (res) {
for (var tid in $scope.themes) {
if ($scope.themes[tid].name == res[2]) {
lastExercice = Object.keys($scope.themes[tid].exercices)[parseInt(res[1])-1];
break;
}
}
}
}
event.time = Date.parse(event.time);
event.since = now - event.time;
event.kind = ["border-" + event.kind, "alert-" + event.kind];
});
$rootScope.lastExercice = lastExercice;
});
}
refreshEvents()
@ -61,7 +76,7 @@ angular.module("FICApp", ["ngSanitize", "ngAnimate"])
return;
$scope.lastpublicetag = response.headers()["last-modified"];
$scope.scene = response.data;
$scope.display = response.data;
});
}
refreshScene();