admin: complet API and interface with files checking page
This commit is contained in:
parent
184714aeeb
commit
9a1a64c41c
9 changed files with 166 additions and 19 deletions
|
|
@ -31,6 +31,7 @@
|
|||
<li class="nav-item"><a class="nav-link" href="/teams">Équipes</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/themes">Thèmes</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/exercices">Exercices</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/files">Fichiers</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/public/0">Public</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/events">Événements</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/settings">Paramètres</a></li>
|
||||
|
|
|
|||
|
|
@ -49,6 +49,10 @@ angular.module("FICApp", ["ngRoute", "ngResource", "ngSanitize"])
|
|||
controller: "PublicController",
|
||||
templateUrl: "views/public.html"
|
||||
})
|
||||
.when("/files", {
|
||||
controller: "FilesListController",
|
||||
templateUrl: "views/file-list.html"
|
||||
})
|
||||
.when("/events", {
|
||||
controller: "EventsListController",
|
||||
templateUrl: "views/event-list.html"
|
||||
|
|
@ -72,6 +76,9 @@ angular.module("FICApp")
|
|||
'update': {method: 'PUT'},
|
||||
})
|
||||
})
|
||||
.factory("File", function($resource) {
|
||||
return $resource("/api/files/:fileId", { fileId: '@id' })
|
||||
})
|
||||
.factory("ROSettings", function($resource) {
|
||||
return $resource("/api/settings-ro.json")
|
||||
})
|
||||
|
|
@ -525,6 +532,37 @@ angular.module("FICApp")
|
|||
};
|
||||
})
|
||||
|
||||
.controller("FilesListController", function($scope, File, $location, $http, $rootScope) {
|
||||
$scope.files = File.query();
|
||||
$scope.fields = ["id", "path", "name", "checksum", "size"];
|
||||
|
||||
$scope.clearFiles = function(id) {
|
||||
File.delete(function() {
|
||||
$scope.files = [];
|
||||
});
|
||||
};
|
||||
$scope.checksum = function(f) {
|
||||
$http({
|
||||
url: "/api/files/" + f.id + "/checksum",
|
||||
method: "GET"
|
||||
}).then(function(response) {
|
||||
if (response.data)
|
||||
$rootScope.newBox('danger', response.data);
|
||||
}, function(response) {
|
||||
$scope.inSync = false;
|
||||
$rootScope.newBox('danger', 'An error occurs when checking files:', response.data);
|
||||
})
|
||||
};
|
||||
$scope.checksumAll = function() {
|
||||
angular.forEach($scope.files, function(file) {
|
||||
$scope.checksum(file);
|
||||
});
|
||||
};
|
||||
$scope.show = function(f) {
|
||||
$location.url("/exercices/" + f.idExercice);
|
||||
};
|
||||
})
|
||||
|
||||
.controller("EventsListController", function($scope, Event, $location) {
|
||||
$scope.events = Event.query();
|
||||
$scope.fields = ["id", "kind", "txt", "time"];
|
||||
|
|
|
|||
22
admin/static/views/file-list.html
Normal file
22
admin/static/views/file-list.html
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<h2>
|
||||
Fichiers
|
||||
<button ng-click="checksumAll()" class="float-right btn btn-sm btn-secondary mr-sm-2"><span class="glyphicon glyphicon-flash" aria-hidden="true"></span> Vérifier les fichiers</button>
|
||||
</h2>
|
||||
|
||||
<p><input type="search" class="form-control" placeholder="Search" ng-model="query"></p>
|
||||
<table class="table table-hover table-bordered table-striped table-sm">
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<th ng-repeat="field in fields">
|
||||
{{ field }}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="file in files | filter: query" ng-click="show(file)">
|
||||
<td ng-repeat="field in fields">
|
||||
{{ file[field] }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
Reference in a new issue