<nav class="navbar navbar-default navbar-fixed-top">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="/#/"><i class="fa fa-calendar-check-o"></i> BetterMe</a>
    </div>

    <div class="collapse navbar-collapse navbar-right" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li><a href="#/profile">Profile <span class="sr-only">(current)</span></a></li>
        <li><a href="#/calendar">Calendar</a></li>
        <li><a href="#/regimen">Regimens</a></li>
        <li><a href="#/invite">Invites</a></li>
        <li><a href="#/regimen/find">Find Regimens</a></li>
        <li class="active"><a href="#/admin">Admin</a></li>
        <li><a href="" ng-click="model.logout()">Logout</a></li>
      </ul>
    </div>
  </div>
</nav>

<h1>Admin</h1>

<ul class="list-group col-md-6">
  <input ng-model="model.userSearchTerm"
         class="form-control"
         placeholder="Search By User's Email"
         ng-change="model.updateDisplayedUsers()">
  <table ng-if="model.displayedUsers.length" class="table table-hover">
    <thead>
    <tr>
      <th></th>
      <th>Email</th>
      <th>First</th>
      <th>Last</th>
      <th>Admin</th>
    </tr>
    </thead>
    <tbody>
    <tr ng-repeat="user in model.displayedUsers" ng-click="model.redirectToUserDetails(user._id)">
      <td ng-click="model.deleteUser(user._id)"><i class="fa fa-trash" aria-hidden="true"></i></td>
      <td>{{user.email}}</td>
      <td>{{user.firstName}}</td>
      <td>{{user.lastName}}</td>
      <td>{{user.admin}}</td>
    </tr>
    </tbody>
  </table>
</ul>

<ul class="list-group col-md-6">
  <input ng-model="model.regimenSearchTerm"
         class="form-control"
         placeholder="Search By Regimen or Coach"
         ng-change="model.updateDisplayedRegimens()">
  <table ng-if="model.displayedRegimens.length" class="table table-hover">
    <thead>
    <tr>
      <th></th>
      <th>Title</th>
      <th>Coach</th>
      <th>Start</th>
      <th>End</th>
    </tr>
    </thead>
    <tbody>
    <tr ng-repeat="regimen in model.displayedRegimens" ng-click="model.redirectToRegimenDetails(regimen._id)">
      <td ng-click="model.deleteRegimen(regimen._id)"><i class="fa fa-trash" aria-hidden="true"></i></td>
      <td>{{regimen.title}}</td>
      <td>{{regimen._coach.email}}</td>
      <td>{{model.displayDate(regimen.start)}}</td>
      <td>{{model.displayDate(regimen.end)}}</td>
    </tr>
    </tbody>
  </table>
</ul>
