<div class="jumbotron text-light bg-dark py-3">
  <h1 class="display-4">Interface d'administration du challenge</h1>
  <div class="row">
    <div class="col">
      <p ng-controller="VersionController">
	Version de l'API : {{ v.version }}
      </p>
      <p ng-controller="TimestampController">
	Latence frontal : <span ng-class="{'text-success': t.diffFB <= 1000000000, 'text-warning': t.diffFB > 1000000000, 'text-danger': t.diffFB > 1500000000}"><ng-pluralize count="t.diffFB / 1000000000" when="{'one': '{}&nbsp;seconde', 'other': '{}&nbsp;secondes'}"></ng-pluralize></span><br>
	Dernière synchronisation du frontal : {{ t.frontend | date:"mediumTime" }}
      </p>
      <ul class="pagination" ng-controller="SubmissionsStatsController">
        <li class="page-item" title="Nombre de soumissions la dernière minute"><a class="page-link">{{ submissionsstats.nbsubminute }}</a></li>
        <li class="page-item" title="Taux de soumission ces dernières 5 minutes ; total : {{ submissionsstats.nbsub5minute }}"><a class="page-link">{{ submissionsstats.nbsub5minute / 5 | number:2 }}</a></li>
        <li class="page-item" title="Taux de soumission ces dernières 15 minutes ; total : {{ submissionsstats.nbsubquarter }}"><a class="page-link">{{ submissionsstats.nbsubquarter / 15 | number:2 }}</a></li>
        <li class="page-item" title="Taux de soumission cette dernière heure ; total : {{ submissionsstats.nbsubhour }}"><a class="page-link">{{ submissionsstats.nbsubhour / 60 | number:2 }}</a></li>
        <li class="page-item" title="Taux de soumission ce dernier jour ; total : {{ submissionsstats.nbsubday }}"><a class="page-link">{{ submissionsstats.nbsubday / 1440 | number:2 }}</a></li>
      </ul>
      <ul class="pagination" ng-controller="ValidationsStatsController">
        <li class="page-item" title="Nombre de validations la dernière minute"><a class="page-link text-success">{{ validationsstats.nbsubminute }}</a></li>
        <li class="page-item" title="Taux de validation ces dernières 5 minutes ; total : {{ validationsstats.nbsub5minute }}"><a class="page-link text-success">{{ validationsstats.nbsub5minute / 5 | number:2 }}</a></li>
        <li class="page-item" title="Taux de validation ces dernières 15 minutes ; total : {{ validationsstats.nbsubquarter }}"><a class="page-link text-success">{{ validationsstats.nbsubquarter / 15 | number:2 }}</a></li>
        <li class="page-item" title="Taux de validation cette dernière heure ; total : {{ validationsstats.nbsubhour }}"><a class="page-link text-success">{{ validationsstats.nbsubhour / 60 | number:2 }}</a></li>
        <li class="page-item" title="Taux de validation ce dernier jour ; total : {{ validationsstats.nbsubday }}"><a class="page-link text-success">{{ validationsstats.nbsubday / 1440 | number:2 }}</a></li>
      </ul>
    </div>

    <div class="col">
      Problèmes dans les fichiers :
      <ul ng-controller="HealthController">
	<li ng-if="!health.length">Rien de problématique pour l'instant</li>
	<li ng-repeat="heal in health">
	  <a ng-href="teams/{{ heal.id_team }}" ng-if="heal.id_team" class="text-warning">/{{ heal.path.split("/")[1] }}</a><a target="_blank" ng-href="submissions{{ heal.path }}" ng-if="heal.id_team">/{{ heal.path.split("/")[2] }}</a>
	  <a ng-href="submissions{{ heal.path }}" ng-if="!heal.id_team">{{ heal.path }}</a>
	  : {{ heal.error }}
          <button type="button" class="btn btn-sm btn-link" ng-click="drop_submission(heal.path)">
            <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
          </button>
	</li>
      </ul>
    </div>
  </div>
</div>

<div class="row mb-3">
 <div class="col-sm-7 col-md-8 col-lg-9">
  <div class="card" ng-controller="ExercicesStatsController">
    <div class="card-header">
      <h4 class="mb-0">Progression</h4>
    </div>
    <div style="overflow: auto;">
     <table class="table table-hover table-striped table-sm mb-0">
      <thead>
	<tr>
	  <th class="frotated"></th>
	  <th class="rotated" ng-repeat="(tid,th) in themes" ng-if="tid != 0"><div><a ng-href="themes/{{ th.id }}">{{ th.name }}</a></div></th>
	</tr>
      </thead>
      <tbody class="table-bordered">
	<tr ng-repeat="lvl in [1,2,3,4,5]">
	  <th class="text-center"><nobr>Challenge {{ lvl }}</nobr></th>
	  <td ng-repeat="(tid,theme) in themes" ng-if="tid != 0" class="text-center text-bold">
	    <a ng-href="exercices/{{ exercices[theme.exercices[lvl-1].id].id_exercice }}" ng-if="exercices[theme.exercices[lvl-1].id].team_tries || lvl == 1" ng-class="{'text-primary': exercices[theme.exercices[lvl-1].id].solved_count == 0, 'text-success': exercices[theme.exercices[lvl-1].id].solved_count >= 1, 'text-bold': exercices[theme.exercices[lvl-1].id].solved_count >= 1, 'text-warning': exercices[theme.exercices[lvl-1].id].solved_count == 0 && exercices[theme.exercices[lvl-1].id].team_tries}">
	      <span ng-if="exercices[theme.exercices[lvl-1].id].solved_count">{{ exercices[theme.exercices[lvl-1].id].solved_count }}</span>
	      <span ng-if="!exercices[theme.exercices[lvl-1].id].solved_count">{{ exercices[theme.exercices[lvl-1].id].team_tries }}</span>
	    </a>
	  </td>
	</tr>
      </tbody>
     </table>
    </div>
    <div style="overflow: auto; margin-top: 10px; padding-top: 10px; border-top: solid 2px lightgrey" ng-if="themes['0']">
     <table class="table table-hover table-striped table-sm mb-0">
      <thead>
	<tr>
	  <th class="text-center">Exercices</th>
	  <th class="text-center" ng-repeat="i in [0,1,2,3,4,5,6,7,8,9]">{{ i+1 }}</th>
	</tr>
      </thead>
      <tbody class="table-bordered">
	<tr ng-repeat="j in lenExoArray">
	  <th class="text-center">{{ j+1 }}</th>
	  <td ng-repeat="i in [0,1,2,3,4,5,6,7,8,9]" class="text-center text-bold">
	    <a ng-href="exercices/{{ exercices[themes[0].exercices[j*10+i].id].id_exercice }}" ng-if="!exercices[themes[0].exercices[j*10+i].id].locked" ng-class="{'text-primary': exercices[themes[0].exercices[j*10+i].id].solved_count == 0, 'text-success': exercices[themes[0].exercices[j*10+i].id].solved_count >= 1, 'text-bold': exercices[themes[0].exercices[j*10+i].id].solved_count >= 1, 'text-warning': exercices[themes[0].exercices[j*10+i].id].solved_count == 0 && exercices[themes[0].exercices[j*10+i].id].team_tries}">
	      <span ng-if="exercices[themes[0].exercices[j*10+i].id].solved_count">{{ exercices[themes[0].exercices[j*10+i].id].solved_count }}</span>
	      <span ng-if="!exercices[themes[0].exercices[j*10+i].id].solved_count">{{ exercices[themes[0].exercices[j*10+i].id].team_tries }}</span>
	    </a>
	  </td>
	</tr>
      </tbody>
     </table>
    </div>
  </div>
 </div>
 <div class="col-sm-5 col-md-4 col-lg-3">
  <div class="card">
    <div class="card-header">
      <h4 class="mb-0">Classement</h4>
    </div>
    <table class="table table-hover table-striped table-sm mb-0" ng-controller="TeamsJSONController">
      <tbody>
	<tr ng-repeat="team in rank | orderBy:'rank'" ng-if="team.rank">
	  <td>{{ team.rank }}</td>
	  <td><a ng-href="teams/{{ team.id }}">{{ team.name }}</td>
	  <td>{{ team.score | number:0 }}</td>
	</tr>
      </tbody>
    </table>
  </div>
 </div>
</div>
