<div class="col-sm-12">
  <div class="table-responsive">
    <table class="table table-bordered table-hover table-condensed">
      <thead>
        <tr>
          <th></th>
          <th></th>
          <th colspan="4">Periodicidade</th>
          <th colspan="3">Último processamento</th>
          <th></th>
          <th></th>
        </tr>
        <tr>
          <th>Nome</th>
          <th>Estado</th>
          <th>M</th>
          <th>S</th>
          <th>H</th>
          <th>M</th>
          <th>Executou</th>
          <th>Duração</th>
          <th>Situação</th>
          <th></th>
          <th></th>
        </tr>
      </thead>
      <tbody>
        <tr ng-repeat="item in items">
          <td>{{item.name}} <button ng-click="run(item);" ng-disabled="item.runs.length > 0 ? item.runs[0].isRunning : false"
              type="button" class="btn btn-default btn-xs"><span class="fa fa-play"></span></button></td>
          <td>{{item.isActive ? "Ativo" : "Inativo"}} <button ng-click="toggleState(item);" type="button" class="btn btn-default btn-xs"><span class="fa fa-refresh"></span></button></td>
          <td>{{item.criteria.month}}</td>
          <td>{{item.criteria.weekday}}</td>
          <td>{{item.criteria.hour}}</td>
          <td>{{item.criteria.minute}}</td>
          <td class="text-nowrap">{{item.runs.length === 0 ? "Nunca" : formatDatetime(item.runs[0].startTimestamp)}}</td>
          <td class="text-nowrap">{{item.runs.length === 0 ? "-" : calculateTimespan(item.runs[0].startTimestamp, item.runs[0].endTimestamp)}}</td>
          <td>{{item.runs.length === 0 ? "-" : (item.runs[0].isRunning ? "Em execução" : (item.runs[0].success ? "Completou"
            : "Falhou"))}}</td>
          <td><button ng-click="openEdit(item);" type="button" class="btn btn-primary btn-xs"><span class="fa fa-pencil"></span></button></td>
          <td><button ng-click="remove(item);" type="button" class="btn btn-danger btn-xs"><span class="fa fa-trash-o"></span></button></td>
        </tr>
      </tbody>
    </table>
  </div>
</div>