admin: Improve file readability

This commit is contained in:
nemunaire 2024-03-17 16:03:40 +01:00
parent a0cd651dae
commit d323bf9ee9
3 changed files with 26 additions and 3 deletions

View File

@ -1352,7 +1352,7 @@ angular.module("FICApp")
$scope.files = File.query(); $scope.files = File.query();
$scope.errfnd = null; $scope.errfnd = null;
$scope.errzip = null; $scope.errzip = null;
$scope.fields = ["id", "path", "name", "checksum", "size"]; $scope.fields = ["id", "path", "name", "size"];
$scope.clearFiles = function(id) { $scope.clearFiles = function(id) {
File.delete(function() { File.delete(function() {
@ -1376,12 +1376,15 @@ angular.module("FICApp")
}) })
}; };
$scope.checksum = function(f) { $scope.checksum = function(f) {
f.checkWIP = true;
$http({ $http({
url: "api/files/" + f.id + "/check", url: "api/files/" + f.id + "/check",
method: "POST" method: "POST"
}).then(function(response) { }).then(function(response) {
f.checkWIP = false;
f.err = true; f.err = true;
}, function(response) { }, function(response) {
f.checkWIP = false;
$scope.inSync = false; $scope.inSync = false;
$scope.errfnd += 1; $scope.errfnd += 1;
f.err = response.data.errmsg; f.err = response.data.errmsg;

View File

@ -200,6 +200,18 @@ angular.module("FICApp")
else else
return ""; return "";
} }
})
.filter("bto16", function() {
return function(input) {
const raw = atob(input);
let result = '';
for (let i = 0; i < raw.length; i++) {
const hex = raw.charCodeAt(i).toString(16);
result += (hex.length === 2 ? hex : '0' + hex);
}
return result;
}
}); });
angular.module("FICApp") angular.module("FICApp")

View File

@ -14,13 +14,17 @@
<th ng-repeat="field in fields"> <th ng-repeat="field in fields">
{{ field }} {{ field }}
</th> </th>
<th>checksum</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr ng-repeat="file in files | filter: query" ng-class="{'bg-danger': file.err !== undefined && file.err !== true}" ng-click="show(file)"> <tr ng-repeat="file in files | filter: query" ng-class="{'bg-danger': file.err !== undefined && file.err !== true}" ng-click="show(file)">
<td> <td>
<button type="button" class="btn btn-sm btn-light" ng-click="$event.stopPropagation();checksum(file)"><span class="glyphicon glyphicon-flash" aria-hidden="true"></span></button> <button type="button" class="btn btn-sm btn-light" ng-click="$event.stopPropagation();checksum(file)" ng-disabled="file.checkWIP">
<button type="button" class="btn btn-sm btn-light" ng-click="$event.stopPropagation();gunzipFile(file)" ng-disabled="file.gunzipWIP"> <span class="glyphicon glyphicon-flash" aria-hidden="true" ng-if="!file.checkWIP"></span>
<div class="spinner-border spinner-border-sm" role="status" ng-if="file.checkWIP"></div>
</button>
<button type="button" class="btn btn-sm btn-light" ng-click="$event.stopPropagation();gunzipFile(file)" ng-disabled="file.gunzipWIP" ng-if="file.checksum_shown">
<span class="glyphicon glyphicon-compressed" aria-hidden="true" ng-if="!file.gunzipWIP"></span> <span class="glyphicon glyphicon-compressed" aria-hidden="true" ng-if="!file.gunzipWIP"></span>
<div class="spinner-border spinner-border-sm" role="status" ng-if="file.gunzipWIP"></div> <div class="spinner-border spinner-border-sm" role="status" ng-if="file.gunzipWIP"></div>
</button> </button>
@ -29,6 +33,10 @@
{{ file[field] }} {{ file[field] }}
<span ng-if="field == 'id' && file.err !== undefined && file.err !== true" title="{{ file.err }}" class="glyphicon glyphicon-exclamation-sign"></span> <span ng-if="field == 'id' && file.err !== undefined && file.err !== true" title="{{ file.err }}" class="glyphicon glyphicon-exclamation-sign"></span>
</td> </td>
<td>
{{ file.checksum | bto16 }}
<div ng-if="file.checksum_shown">{{ file.checksum_shown | bto16 }}</div>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>