dashboard: improve: scale, flex, ...
This commit is contained in:
parent
7865373ffc
commit
7bac1ead6b
2 changed files with 104 additions and 81 deletions
|
@ -1,13 +1,14 @@
|
|||
var tuto_progress = [
|
||||
{
|
||||
1: { title: "Is alive?", label: "T1"},
|
||||
2: { title: "DMZ reached", label: "T2"},
|
||||
3: { title: "HTTPS on + time", label: "T3"},
|
||||
4: { title: "DNS ok", label: "T4"},
|
||||
5: { title: "On Internet", label: "T5"},
|
||||
6: { title: "Bonus ICMP", label: "B1"},
|
||||
7: { title: "Bonus disk", label: "B2"},
|
||||
8: { title: "Uploaded SSH key", label: "SSH"},
|
||||
1: { title: "Is alive?", label: "t1"},
|
||||
2: { title: "DMZ reached", label: "t2"},
|
||||
3: { title: "HTTPS on + time", label: "t3"},
|
||||
4: { title: "DNS ok", label: "t4"},
|
||||
5: { title: "On Internet", label: "t5"},
|
||||
6: { title: "Bonus caché", label: "B?"},
|
||||
7: { title: "Bonus ICMP", label: "B1"},
|
||||
8: { title: "Bonus disk", label: "B2"},
|
||||
9: { title: "Uploaded SSH key", label: "C"},
|
||||
},
|
||||
{
|
||||
100: { title: "HTTP", label: "HTTP"},
|
||||
|
@ -27,13 +28,16 @@ angular.module("AdLinApp", ["ngResource", "ngSanitize"])
|
|||
.factory("Progression", function($resource) {
|
||||
return $resource("/api/progress")
|
||||
})
|
||||
.factory("StudentProgression", function($resource) {
|
||||
return $resource("/api/dashboard.json")
|
||||
})
|
||||
.factory("Challenge", function($resource) {
|
||||
return $resource("/challenge/:challengeId", { challengeId: '@id' })
|
||||
});
|
||||
|
||||
angular.module("AdLinApp")
|
||||
.run(function($rootScope, $location) {
|
||||
$rootScope.tutoid = 1;
|
||||
$rootScope.tutoid = 0;
|
||||
})
|
||||
.controller("StudentsController", function($scope, $interval, Student) {
|
||||
$scope.students = Student.query();
|
||||
|
@ -42,12 +46,58 @@ angular.module("AdLinApp")
|
|||
}
|
||||
$interval(refreshStd, 1600000);
|
||||
})
|
||||
.controller("StudentsProgressionController", function($scope, $interval, Progression) {
|
||||
$scope.tuto_progress = tuto_progress;
|
||||
$scope.stats = {};
|
||||
$scope.students = {};
|
||||
|
||||
var refreshStd = function() {
|
||||
var students = Progression.get();
|
||||
|
||||
students.$promise.then(function(response) {
|
||||
var recent = new Date(Date.now() - 120000);
|
||||
var tmpstats = {total:0};
|
||||
|
||||
angular.forEach(tuto_progress, function(tuto) {
|
||||
angular.forEach(tuto, function(ch, chid) {
|
||||
tmpstats[chid] = {"success":0, "warning":0};
|
||||
});
|
||||
});
|
||||
|
||||
angular.forEach(response, function(challenges, login) {
|
||||
if (login[0] == "$") return;
|
||||
tmpstats.total++;
|
||||
angular.forEach(challenges, function(ch, chid) {
|
||||
if (ch.time) {
|
||||
challenges[chid].time = new Date(ch.time);
|
||||
challenges[chid].recent = (Date.now() - ch.time)/1000;
|
||||
if (recent < challenges[chid].time)
|
||||
tmpstats[chid].success++;
|
||||
}
|
||||
if (tmpstats[chid] !== undefined)
|
||||
tmpstats[chid].warning++;
|
||||
});
|
||||
if (login == "nemunaire")
|
||||
challenges["img"] = "mercie_d"
|
||||
else
|
||||
challenges["img"] = login
|
||||
$scope.students[login] = challenges;
|
||||
});
|
||||
$scope.stats = tmpstats;
|
||||
|
||||
})
|
||||
}
|
||||
refreshStd();
|
||||
$interval(refreshStd, 9750);
|
||||
})
|
||||
.controller("PingController", function($scope, $interval, $http) {
|
||||
$scope.PING = false;
|
||||
$scope.PING_time = '';
|
||||
$scope.PING_ok = false;
|
||||
var refreshPing = function() {
|
||||
$http.get("/api/students/" + $scope.student.id + "/ping").then(function(response) {
|
||||
$scope.PING_time = new Date(response.data);
|
||||
$scope.PING_ok = response.data.State;
|
||||
$scope.PING_time = new Date(response.data.Date);
|
||||
$scope.PING = (Date.now() - $scope.PING_time)/1000;
|
||||
});
|
||||
}
|
||||
|
@ -64,35 +114,6 @@ angular.module("AdLinApp")
|
|||
refreshSSH();
|
||||
$interval(refreshSSH, 15500);
|
||||
})
|
||||
.controller("ProgressStatsController", function($scope, $interval, $http) {
|
||||
$scope.tuto_progress = tuto_progress;
|
||||
$scope.stats = {};
|
||||
var refreshChal = function() {
|
||||
var recent = new Date(Date.now() - 120000);
|
||||
var tmpstats = {total:0};
|
||||
angular.forEach(tuto_progress, function(tuto) {
|
||||
angular.forEach(tuto, function(ch, chid) {
|
||||
tmpstats[chid] = {"success":0, "warning":0};
|
||||
});
|
||||
});
|
||||
$http.get("/api/progress/").then(function(response) {
|
||||
angular.forEach(response.data, function(challenges, login) {
|
||||
tmpstats.total++;
|
||||
angular.forEach(challenges, function(ch, chid) {
|
||||
tmpstats[chid].warning++;
|
||||
if (ch.time) {
|
||||
challenges[chid].time = new Date(ch.time);
|
||||
if (recent < challenges[chid].time)
|
||||
tmpstats[chid].success++;
|
||||
}
|
||||
});
|
||||
});
|
||||
$scope.stats = tmpstats;
|
||||
});
|
||||
}
|
||||
refreshChal();
|
||||
$interval(refreshChal, 14750);
|
||||
})
|
||||
.controller("ProgressionController", function($scope, $interval, $http) {
|
||||
$scope.tuto_progress = tuto_progress;
|
||||
$scope.mychallenges = {};
|
||||
|
|
Reference in a new issue