<div class="row">
  <h1 translate lib="web">entities</h1>
  <p class="col-md-5 lead"></p>
  <div class="form-group col-sm-3 form-horizontal">
    <label class="sr-only">Filter</label>
    <div class="input-group unframed-addons">
      <div class="input-group-addon"><i class="fas fa-search"></i></div>
      <input ng-model="ctrl.searchstring" ng-change="ctrl.Search()" class="form-control input-md"
        ng-model-options="{debounce: 400}" />
    </div>
  </div>
</div>

<div class="row">
  <div class="col-md-6">
    <div className="btn-group-justified">
      <div class="btn-group" role="group">
        <select ng-model="ctrl.collection" ng-options="item.name as item.name for item in ctrl.collections"
          ng-change="ctrl.SelectCollection()">
        </select>
        <!-- <a href ng-click="ctrl.DropCollection()" class="btn btn-secondary" translate lib="web"
          ng-show="ctrl.WebSocketClientService.user.username=='az'"" ng-disabled=" ctrl.loading==true">Drop</a>
        <a href ng-click="ctrl.DeleteMany()" class="btn btn-secondary" translate lib="web"
          ng-show="ctrl.WebSocketClientService.user.username=='az'"" ng-disabled=" ctrl.loading==true">empty</a> -->
      </div>

    </div>
  </div>
  <div class=" col-md-6 text-right">
    <!-- <a ng-href="#/Entity/{{ctrl.collection}}" class="btn btn-info" translate lib="web">addentity</a> -->
    <a ng-href="#/Deleted/{{ctrl.collection}}" class="btn btn-info"><i class="fas fa-undo"></i></a>
    <a ng-href="#/Duplicates/{{ctrl.collection}}" class="btn btn-info"><i class="fas fa-clone"></i></a>
    <a ng-href="#/Entity/{{ctrl.collection}}" class="btn btn-info"><i class="az-add-lg"></i></a>
  </div>
</div>

<div ng-show="ctrl.errormessage != ''"" class=" alert alert-danger" role="alert">{{ctrl.errormessage}}</div>

<table id=" table1" class="table table-striped table-hover table-sm" when-scrolled="ctrl.more()" style="width: 100%;">
  <thead class="thead-dark">
    <tr>
      <th scope="col" ng-click="ctrl.ToggleOrder('name')"><b translate lib="web">name</b></th>
      <th scope="col" ng-click="ctrl.ToggleOrder('_type')"><b translate lib="web">type</b></th>
      <th scope="col" ng-click="ctrl.ToggleOrder('_createdby')"><b translate lib="web">createdby</b></th>
      <th scope="col" ng-click="ctrl.ToggleOrder('_created')"><b translate lib="web">created</b></th>
      <th scope="col" ng-click="ctrl.ToggleOrder('_modified')"><b translate lib="web">updated</b></th>
      <th></th>
      <th></th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <tr ng-repeat="model in ctrl.models">
      <td>{{model.name}}</td>
      <td><span translate lib="web">{{model.type || model._type}}</span></td>
      <td>{{model._createdby}}</td>
      <td>
        <timesince ng-model="model._created" />
      </td>
      <td>
        <timesince ng-model="model._modified" />
      </td>
      <td class="btn-cell">
        <a ng-href="#/History/{{ctrl.collection}}/{{model._id}}" class="table-btn">Hist</a>
      </td>
      <td class="btn-cell">
        <a ng-href="#/Entity/{{ctrl.collection}}/{{model._id}}" class="table-btn"><i class="az-edit"></i></a>
      </td>
      <td class="btn-cell">
        <a href ng-click="ctrl.DeleteOne(model)" ng-disabled="ctrl.loading==true" class="table-btn"><i
            class="az-trash"></i></a>
      </td>
    </tr>
  </tbody>
</table>