<page-header model="ctrl.navModel"></page-header>

<div class="page-container page-body">
	<div class="page-action-bar">
    <label class="gf-form gf-form--grow gf-form--has-input-icon">
      <input type="text" class="gf-form-input max-width-20" placeholder="Find Team by name" tabindex="1" ng-model="ctrl.query" ng-model-options="{ debounce: 500 }" spellcheck='false' ng-change="ctrl.get()" />
      <i class="gf-form-input-icon fa fa-search"></i>
    </label>
    <div class="page-action-bar__spacer"></div>

    <a class="btn btn-success" href="org/teams/new">
      <i class="fa fa-plus"></i>
			Add Team
    </a>
  </div>

  <div class="admin-list-table">
    <table class="filter-table filter-table--hover form-inline" ng-show="ctrl.teams.length > 0">
      <thead>
        <tr>
          <th></th>
          <th>Name</th>
          <th>Email</th>
          <th>Members</th>
          <th style="width: 1%"></th>
        </tr>
      </thead>
      <tbody>
        <tr ng-repeat="team in ctrl.teams">
          <td class="width-4 text-center link-td">
            <a href="org/teams/edit/{{team.id}}">
              <img class="filter-table__avatar" ng-src="{{team.avatarUrl}}"></img>
            </a>
          </td>
          <td class="link-td">
            <a href="org/teams/edit/{{team.id}}">{{team.name}}</a>
          </td>
          <td class="link-td">
              <a href="org/teams/edit/{{team.id}}">{{team.email}}</a>
            </td>
          <td class="link-td">
            <a href="org/teams/edit/{{team.id}}">{{team.memberCount}}</a>
          </td>
          <td class="text-right">
            <a ng-click="ctrl.deleteTeam(team)" class="btn btn-danger btn-small">
              <i class="fa fa-remove"></i>
            </a>
          </td>
        </tr>
      </tbody>
    </table>
  </div>

  <div class="admin-list-paging" ng-if="ctrl.showPaging">
    <ol>
      <li ng-repeat="page in ctrl.pages">
        <button
          class="btn btn-small"
          ng-class="{'btn-secondary': page.current, 'btn-inverse': !page.current}"
          ng-click="ctrl.navigateToPage(page)">{{page.page}}</button>
      </li>
    </ol>
  </div>

  <em class="muted" ng-hide="ctrl.teams.length > 0">
    No Teams found.
  </em>
</div>
