dashboard: ping + stats
This commit is contained in:
parent
f50638048f
commit
23c286ea3e
@ -37,13 +37,25 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div ng-controller="StudentsController" ng-cloak>
|
<div ng-controller="StudentsController" ng-cloak>
|
||||||
|
<div class="card float-left mt-1 student" ng-controller="ProgressStatsController">
|
||||||
|
<div class="card-img-top" style="background-image: url('https://srs.epita.fr/assets/images/logo-srs.png')"></div>
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">
|
||||||
|
<span class="login" title="SRS" ng-cloak>ADLIN TP {{tutoid+1}}</span>
|
||||||
|
</h5>
|
||||||
|
<div>
|
||||||
|
<span class="badge ml-1" ng-repeat="(ch,t) in tuto_progress[tutoid]" ng-class="{'badge-success': stats[ch].success > 0, 'badge-warning': stats[ch].success == 0 && stats[ch].warning > 0, 'badge-danger': !stats[ch] || (stats[ch].success == 0 && stats[ch].warning == 0)}" title="{{ t.title }}: {{ stats[ch].success }} - {{ stats[ch].warning }}/{{ stats.total }}" ng-cloak>{{ stats[ch].warning * 100 / stats.total | number:0 }} %</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="card float-left mt-1 student" ng-repeat="student in students">
|
<div class="card float-left mt-1 student" ng-repeat="student in students">
|
||||||
<div class="card-img-top" style="background-image: url('https://photos.cri.epita.fr/thumb/{{ student.login | lowercase }}')" ng-if="student.login != 'nemunaire'"></div>
|
<div class="card-img-top" style="background-image: url('https://photos.cri.epita.fr/thumb/{{ student.login | lowercase }}')" ng-if="student.login != 'nemunaire'"></div>
|
||||||
<div class="card-img-top" style="background-image: url('https://photos.cri.epita.fr/thumb/mercie_d')" ng-if="student.login == 'nemunaire'"></div>
|
<div class="card-img-top" style="background-image: url('https://photos.cri.epita.fr/thumb/mercie_d')" ng-if="student.login == 'nemunaire'" ng-cloak></div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h5 class="card-title" ng-controller="PingController">
|
<h5 class="card-title" ng-controller="PingController">
|
||||||
<span class="login" title="{{ student.login }}">{{ student.login }}</span>
|
<span class="login" title="{{ student.login }}">{{ student.login }}</span>
|
||||||
<span class="badge float-right" ng-class="{'badge-success': PING, 'badge-danger': !PING}">
|
<span class="badge float-right" ng-class="{'badge-success': PING, 'badge-danger': !PING && !PINGi && PINGw, 'badge-warning': !PING && PINGi, 'badge-dark': !PING && !PINGi && !PINGw}" title="{{ PING_time }}">
|
||||||
💻
|
💻
|
||||||
</span>
|
</span>
|
||||||
</h5>
|
</h5>
|
||||||
|
@ -13,6 +13,7 @@ var tuto_progress = [
|
|||||||
100: { title: "HTTP", label: "HTTP"},
|
100: { title: "HTTP", label: "HTTP"},
|
||||||
101: { title: "HTTPS", label: "HTTPS"},
|
101: { title: "HTTPS", label: "HTTPS"},
|
||||||
102: { title: "DNS", label: "DNS"},
|
102: { title: "DNS", label: "DNS"},
|
||||||
|
103: { title: "Matrix", label: "Matrix"},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -43,9 +44,13 @@ angular.module("AdLinApp")
|
|||||||
})
|
})
|
||||||
.controller("PingController", function($scope, $interval, $http) {
|
.controller("PingController", function($scope, $interval, $http) {
|
||||||
$scope.PING = false;
|
$scope.PING = false;
|
||||||
|
$scope.PING_time = '';
|
||||||
var refreshPing = function() {
|
var refreshPing = function() {
|
||||||
$http.get("/api/students/" + $scope.student.id + "/ping").then(function(response) {
|
$http.get("/api/students/" + $scope.student.id + "/ping").then(function(response) {
|
||||||
$scope.PING = response.data
|
$scope.PING_time = new Date(response.data);
|
||||||
|
$scope.PINGw = new Date(Date.now() - 864000000) < $scope.PING_time;
|
||||||
|
$scope.PINGi = new Date(Date.now() - 900000) < $scope.PING_time;
|
||||||
|
$scope.PING = new Date(Date.now() - 90000) < $scope.PING_time;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
refreshPing();
|
refreshPing();
|
||||||
@ -61,6 +66,35 @@ angular.module("AdLinApp")
|
|||||||
refreshSSH();
|
refreshSSH();
|
||||||
$interval(refreshSSH, 15500);
|
$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) {
|
.controller("ProgressionController", function($scope, $interval, $http) {
|
||||||
$scope.tuto_progress = tuto_progress;
|
$scope.tuto_progress = tuto_progress;
|
||||||
$scope.mychallenges = {};
|
$scope.mychallenges = {};
|
||||||
|
Reference in New Issue
Block a user