dashboard: extract progress and visual changes

This commit is contained in:
nemunaire 2021-03-05 15:10:16 +01:00
commit f47eb68505
3 changed files with 45 additions and 39 deletions

View file

@ -1,32 +1,3 @@
var tuto_progress = [
{
1: { title: "Is alive?", label: "👋"},
2: { title: "DMZ reached", label: "📚"},
3: { title: "HTTPS on + time", label: "⏲"},
4: { title: "DNS ok", label: "🍰"},
5: { title: "On Internet", label: "🌎"},
6: { title: "Bonus caché", label: "b"},
7: { title: "Bonus ICMP", label: "🏓"},
8: { title: "Bonus disk", label: "💽"},
9: { title: "Bonus email", label: "📧"},
10: { title: "Wg tunnel", label: "🚇"},
11: { title: "Uploaded SSH key", label: "💊"},
},
{
100: { title: "HTTP", label: "HTTP"},
101: { title: "HTTPS", label: "HTTPS"},
102: { title: "DNS", label: "DNS"},
103: { title: "Matrix", label: "Matrix"},
},
{
200: { title: "HTTP", label: "HTTP"},
201: { title: "HTTPS", label: "HTTPS"},
202: { title: "DNS", label: "DNS"},
203: { title: "Matrix", label: "Matrix"},
},
];
angular.module("AdLinApp", ["ngResource", "ngSanitize"])
.factory("Student", function($resource) {
return $resource("/api/students/:studentId", { studentId: '@id' }, {
@ -65,7 +36,8 @@ angular.module("AdLinApp")
var refreshStd = function() {
$scope.students = Student.query();
}
$interval(refreshStd, 1600000);
var myinterval = $interval(refreshStd, 1600000);
$scope.$on('$destroy', function () { $interval.cancel(myinterval); });
})
.controller("StudentsProgressionController", function($scope, $interval, Progression) {
$scope.tuto_progress = tuto_progress;
@ -109,7 +81,8 @@ angular.module("AdLinApp")
})
}
refreshStd();
$interval(refreshStd, 9750);
var myinterval = $interval(refreshStd, 9750);
$scope.$on('$destroy', function () { $interval.cancel(myinterval); });
})
.controller("StudentProgressionController", function($scope, $interval, $http, Student, StudentProgression) {
$scope.tuto_progress = tuto_progress;
@ -133,7 +106,8 @@ angular.module("AdLinApp")
}
$scope.$watch("onestudent", function(onestudent) {
refreshStd();
$interval(refreshStd, 15000);
var myinterval = $interval(refreshStd, 15000);
$scope.$on('$destroy', function () { $interval.cancel(myinterval); });
})
})
.controller("PingController", function($scope, $interval, $http) {
@ -150,7 +124,8 @@ angular.module("AdLinApp")
$scope.$watch("student", function(student) {
student.$promise.then(function(std) {
refreshPing();
$interval(refreshPing, 15000);
var myinterval = $interval(refreshPing, 15000);
$scope.$on('$destroy', function () { $interval.cancel(myinterval); });
})
})
})
@ -162,7 +137,8 @@ angular.module("AdLinApp")
});
}
refreshSSH();
$interval(refreshSSH, 15500);
var myinterval = $interval(refreshSSH, 15500);
$scope.$on('$destroy', function () { $interval.cancel(myinterval); });
})
.controller("ProgressionController", function($scope, $interval, $http) {
$scope.tuto_progress = tuto_progress;
@ -179,5 +155,6 @@ angular.module("AdLinApp")
});
}
refreshChal();
$interval(refreshChal, 15750);
var myinterval = $interval(refreshChal, 15750);
$scope.$on('$destroy', function () { $interval.cancel(myinterval); });
})