dashboard: refactor
This commit is contained in:
parent
e17d467ee3
commit
ddd8da6395
@ -32,7 +32,7 @@
|
|||||||
</style>
|
</style>
|
||||||
<base href="/">
|
<base href="/">
|
||||||
</head>
|
</head>
|
||||||
<body ng-controller="ChallengesController">
|
<body>
|
||||||
<div ng-controller="StudentsController" ng-cloak>
|
<div ng-controller="StudentsController" ng-cloak>
|
||||||
<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 }}')"></div>
|
<div class="card-img-top" style="background-image: url('https://photos.cri.epita.fr/thumb/{{ student.login | lowercase }}')"></div>
|
||||||
@ -46,17 +46,10 @@
|
|||||||
Unreachable
|
Unreachable
|
||||||
</span>
|
</span>
|
||||||
</h5>
|
</h5>
|
||||||
<div ng-controller="ProgressionController">
|
<div ng-controller="ProgressionController">
|
||||||
<span class="badge ml-1" ng-repeat="ch in chids" ng-class="{'badge-success': mychallenges[ch+1], 'badge-danger': !mychallenges[ch+1]}">
|
<span class="badge ml-1" ng-repeat="(ch,t) in tuto_progress[1]" ng-class="{'badge-success': mychallenges[ch], 'badge-danger': !mychallenges[ch]}">
|
||||||
<span ng-if="ch == 0" title="Is alive">T1</span>
|
<span title="{{ t.title }}" ng-bind="t.label"></span>
|
||||||
<span ng-if="ch == 1" title="DMZ reached">T2</span>
|
|
||||||
<span ng-if="ch == 2" title="HTTPS on + time">T3</span>
|
|
||||||
<span ng-if="ch == 3" title="DNS ok">T4</span>
|
|
||||||
<span ng-if="ch == 4" title="On Internet">T5</span>
|
|
||||||
<span ng-if="ch == 5" title="Bonus ICMP">B1</span>
|
|
||||||
<span ng-if="ch == 6" title="Bonus disk">B2</span>
|
|
||||||
</span>
|
</span>
|
||||||
<span class="badge" ng-controller="SSHController" ng-class="{'badge-success': SSH, 'badge-danger': !SSH}">SSH</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
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"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
100: { title: "HTTP", label: "HTTP"},
|
||||||
|
101: { title: "HTTPS", label: "HTTPS"},
|
||||||
|
102: { title: "DNS", label: "DNS"},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
angular.module("AdLinApp", ["ngResource", "ngSanitize"])
|
angular.module("AdLinApp", ["ngResource", "ngSanitize"])
|
||||||
.factory("Student", function($resource) {
|
.factory("Student", function($resource) {
|
||||||
return $resource("/api/students/:studentId", { studentId: '@id' }, {
|
return $resource("/api/students/:studentId", { studentId: '@id' }, {
|
||||||
@ -19,9 +38,6 @@ angular.module("AdLinApp")
|
|||||||
}
|
}
|
||||||
$interval(refreshStd, 1600000);
|
$interval(refreshStd, 1600000);
|
||||||
})
|
})
|
||||||
.controller("ChallengesController", function($scope, Challenge) {
|
|
||||||
$scope.chids = Challenge.query();
|
|
||||||
})
|
|
||||||
.controller("PingController", function($scope, $interval, $http) {
|
.controller("PingController", function($scope, $interval, $http) {
|
||||||
$scope.PING = false;
|
$scope.PING = false;
|
||||||
var refreshPing = function() {
|
var refreshPing = function() {
|
||||||
@ -43,6 +59,7 @@ angular.module("AdLinApp")
|
|||||||
$interval(refreshSSH, 15500);
|
$interval(refreshSSH, 15500);
|
||||||
})
|
})
|
||||||
.controller("ProgressionController", function($scope, $interval, $http) {
|
.controller("ProgressionController", function($scope, $interval, $http) {
|
||||||
|
$scope.tuto_progress = tuto_progress;
|
||||||
$scope.mychallenges = {};
|
$scope.mychallenges = {};
|
||||||
var refreshChal = function() {
|
var refreshChal = function() {
|
||||||
$http.get("/api/students/" + $scope.student.id + "/progress").then(function(response) {
|
$http.get("/api/students/" + $scope.student.id + "/progress").then(function(response) {
|
||||||
|
Reference in New Issue
Block a user