<div *ngIf="domains && !domains.length" class="fl-heading-md fl-gray-color" i18n>No domains</div>
<app-fl-backdrop *ngIf="!domains || loading" overlayParent></app-fl-backdrop>
<div *ngIf="domains && domains.length" layoutDirection="column">
  <table mat-table [dataSource]="domains">
    <ng-container matColumnDef="id">
      <th mat-header-cell *matHeaderCellDef i18n>ID</th>
      <td mat-cell *matCellDef="let domain">
        <a [routerLink]="[config.getPanelUrl('domains'), domain.id]">
          {{domain.id}}
        </a>
      </td>
    </ng-container>
    <ng-container matColumnDef="title">
      <th mat-header-cell *matHeaderCellDef i18n>Title</th>
      <td mat-cell *matCellDef="let domain">
        <a [routerLink]="[config.getPanelUrl('domains'), domain.id]">
          <span *ngIf="domain.name && domain.name.length > 20; else shortEnough">
            {{domain.name | slice:0:20}}...
          </span>
          <ng-template #shortEnough>{{domain.name}}</ng-template>
        </a>
      </td>
    </ng-container>
    <ng-container matColumnDef="created_at">
      <th mat-header-cell *matHeaderCellDef class="hide-xs" i18n>Created at</th>
      <td mat-cell *matCellDef="let domain" class="hide-xs">
        <a [routerLink]="[config.getPanelUrl('domains'), domain.id]">
          <app-date-displayer [date]="domain.created_at" withTime></app-date-displayer>
        </a>
      </td>
    </ng-container>
    <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
    <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
  </table>

  <div *ngIf="previousPage || nextPage" class="fl-margin-top">
    <button mat-button (click)="changePage('previous')"
            [disabled]="previousPage === false || loading === true" color="primary" i18n>
      Previous page <ng-container *ngIf="previousPage && loading !== true">({{currentPage - 1}})</ng-container>
    </button>
    <button mat-button (click)="changePage('next')"
            [disabled]="nextPage === false || loading === true" color="primary" i18n>
      Next page <ng-container *ngIf="nextPage && loading !== true">({{currentPage + 1}})</ng-container>
    </button>
  </div>

</div>
<a mat-button color="primary" class="fl-margin-top" *ngIf="data"
   [routerLink]="config.getPanelUrl('domains/register-domain')"
   [queryParams]="{'client':data.clientId}" i18n>
  Register new domain
</a>
