<div class="admin-sub-header">
  <div i18n class="form-sub-title">Users list</div>

  <a class="add-button" routerLink="/admin/users/create">
    <span class="icon icon-add"></span>
    <ng-container i18n>Create user</ng-container>
  </a>
</div>

<p-table
  [value]="users" [lazy]="true" [paginator]="true" [totalRecords]="totalRecords" [rows]="rowsPerPage"
  [sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)"
>
  <ng-template pTemplate="header">
    <tr>
      <th i18n pSortableColumn="username">Username <p-sortIcon field="username"></p-sortIcon></th>
      <th i18n>Email</th>
      <th i18n>Video quota</th>
      <th i18n>Role</th>
      <th i18n pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th>
      <th></th>
    </tr>
  </ng-template>

  <ng-template pTemplate="body" let-user>
    <tr>
      <td>{{ user.username }}</td>
      <td>{{ user.email }}</td>
      <td>{{ user.videoQuota }}</td>
      <td>{{ user.roleLabel }}</td>
      <td>{{ user.createdAt }}</td>
      <td class="action-cell">
        <my-edit-button [routerLink]="getRouterUserEditLink(user)"></my-edit-button>
        <my-delete-button (click)="removeUser(user)"></my-delete-button>
      </td>
    </tr>
  </ng-template>
</p-table>
