<div *ngIf="dataSourceTable != null else loading" class="table-container">
  <button mat-raised-button color="accent" (click)="openDialogToAdd()">Add a drop zone</button>

  <table mat-table [dataSource]="dataSourceTable">
    <ng-container matColumnDef="isfavorite">
      <th mat-header-cell *matHeaderCellDef></th>
      <td mat-cell *matCellDef="let element" style="text-align: center;">
        <img src="../../assets/img/favorite.png" alt="favorite DZ" *ngIf="element.isFavorite === true"
          (click)="removeToFavorite(element)">
        <img src="../../assets/img/not-favorite.png" alt="favorite DZ" *ngIf="element.isFavorite === false"
          (click)="setToFavorite(element)">
      </td>
    </ng-container>

    <ng-container matColumnDef="id">
      <th mat-header-cell *matHeaderCellDef>ID</th>
      <td mat-cell *matCellDef="let element">{{element.id}}</td>
    </ng-container>

    <ng-container matColumnDef="name">
      <th mat-header-cell *matHeaderCellDef>Name</th>
      <td mat-cell *matCellDef="let element">
        <span class="spanWithBreakWord" [innerHTML]="element.name"></span>
        <a href='http://{{element.website}}'>ici</a>
      </td>
    </ng-container>

    <ng-container matColumnDef="latitude">
      <th mat-header-cell *matHeaderCellDef>Latitude</th>
      <td mat-cell *matCellDef="let element">{{element.latitude}}</td>
    </ng-container>
    <ng-container matColumnDef="longitude">
      <th mat-header-cell *matHeaderCellDef>Longitude</th>
      <td mat-cell *matCellDef="let element">{{element.longitude}}</td>
    </ng-container>

    <ng-container matColumnDef="address">
      <th mat-header-cell *matHeaderCellDef>Address</th>
      <td mat-cell *matCellDef="let element">
        <span class="spanWithBreakWord" [innerHTML]="element.address"></span>
      </td>
    </ng-container>
    <ng-container matColumnDef="email">
      <th mat-header-cell *matHeaderCellDef>E-mail</th>
      <td mat-cell *matCellDef="let element">{{element.email}}</td>
    </ng-container>
    <ng-container matColumnDef="type">
      <th mat-header-cell *matHeaderCellDef>Type</th>
      <td mat-cell *matCellDef="let element">{{element.type}}</td>
    </ng-container>

    <tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
    <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
  </table>
</div>
<mat-paginator [length]="resultsLength" [pageSize]="20"></mat-paginator>

<ng-template #loading>
  <mat-progress-spinner [mode]="'indeterminate'"></mat-progress-spinner>
</ng-template>
