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
|
@ -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"];
|
||||
|
|
Reference in a new issue