admin: new route to check file on disk

This commit is contained in:
nemunaire 2018-08-19 22:19:49 +02:00 committed by Pierre-Olivier Mercier
parent 5b30788cff
commit 20dfd99ec0
4 changed files with 27 additions and 6 deletions

View file

@ -695,6 +695,7 @@ angular.module("FICApp")
.controller("FilesListController", function($scope, File, $location, $http, $rootScope) {
$scope.files = File.query();
$scope.errfnd = 0;
$scope.fields = ["id", "path", "name", "checksum", "size"];
$scope.clearFiles = function(id) {
@ -704,17 +705,18 @@ angular.module("FICApp")
};
$scope.checksum = function(f) {
$http({
url: "/api/files/" + f.id + "/checksum",
method: "GET"
url: "/api/files/" + f.id + "/check",
method: "POST"
}).then(function(response) {
if (response.data)
$rootScope.newBox('danger', response.data);
f.err = true;
}, function(response) {
$scope.inSync = false;
$rootScope.newBox('danger', 'An error occurs when checking files:', response.data);
$scope.errfnd += 1;
f.err = response.data.errmsg;
})
};
$scope.checksumAll = function() {
$scope.errfnd = 0;
angular.forEach($scope.files, function(file) {
$scope.checksum(file);
});