<h2>
  Fichiers
  <small class="text-muted" ng-if="errfnd > 0"><span class="glyphicon glyphicon-exclamation-sign"></span> <ng-pluralize count="errfnd" when="{'one': '{} erreur trouvée', 'other': '{} erreurs trouvées'}"></ng-pluralize></small>
  <small class="text-muted" ng-if="errzip > 0"><span class="glyphicon glyphicon-exclamation-sign"></span> <ng-pluralize count="errzip" when="{'one': '{} décompression problématique', 'other': '{} décompressions problématiques'}"></ng-pluralize></small>
  <button type="button" ng-click="checksumAll()" class="float-right btn btn-sm" ng-class="{'btn-secondary': errfnd === null, 'btn-success': errfnd === 0, 'btn-danger': errfnd > 0}"><span class="glyphicon glyphicon-flash" aria-hidden="true"></span> Vérifier les fichiers</button>
  <button type="button" ng-click="gunzipFiles()" class="float-right btn btn-sm mx-1"  ng-class="{'btn-secondary': errzip === null, 'btn-success': errzip === 0, 'btn-danger': errzip > 0}" title="Décompresse tous les fichiers compressés afin d'afficher la bonne taille au moment du téléchargement"><span class="glyphicon glyphicon-compressed" aria-hidden="true"></span> Gunzip</button>
</h2>

<p><input type="search" class="form-control" placeholder="Search" ng-model="query" autofocus></p>
<table class="table table-hover table-bordered table-striped table-sm">
  <thead class="thead-dark">
    <tr>
      <th></th>
      <th ng-repeat="field in fields">
	{{ field }}
      </th>
      <th>checksum</th>
    </tr>
  </thead>
  <tbody>
    <tr ng-repeat="file in files | filter: query" ng-class="{'bg-danger': file.err !== undefined && file.err !== true}" ng-click="show(file)">
      <td>
        <button type="button" class="btn btn-sm btn-light" ng-click="$event.stopPropagation();checksum(file)" ng-disabled="file.checkWIP">
          <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>
          <div class="spinner-border spinner-border-sm" role="status" ng-if="file.gunzipWIP"></div>
        </button>
      </td>
      <td ng-repeat="field in fields">
	{{ file[field] }}
	<span ng-if="field == 'id' && file.err !== undefined && file.err !== true" title="{{ file.err }}" class="glyphicon glyphicon-exclamation-sign"></span>
      </td>
      <td>
	{{ file.checksum | bto16 }}
	<div ng-if="file.checksum_shown">{{ file.checksum_shown | bto16 }}</div>
      </td>
    </tr>
  </tbody>
</table>
