<nb-card class="pentest-table">
  <table [nbTreeGrid]="dataSource">
    <tr nbTreeGridHeaderRow *nbTreeGridHeaderRowDef="columns"></tr>
    <tr nbTreeGridRow *nbTreeGridRowDef="let pentest; columns: columns"
        class="pentest-cell"
        routerLink="pentest"
        fragment="{{pentest.data['refNumber']}}"
        (click)="selectPentest(pentest.data)"
        [skipLocationChange]="true">
    </tr>
    <!-- Test ID -->
    <ng-container [nbTreeGridColumnDef]="columns[0]">
      <th nbTreeGridHeaderCell *nbTreeGridHeaderCellDef>
        {{ 'pentest.testId' | translate }}
      </th>
      <td nbTreeGridCell *nbTreeGridCellDef="let pentest">
        <!-- Opens sub categories if row needs to be extendend -->
        <nb-tree-grid-row-toggle
          [expanded]="pentest.expanded"
          *ngIf="pentest.data?.childEntries?.length > 0">
        </nb-tree-grid-row-toggle>
        <!---->
        {{pentest.data['refNumber'] || '-'}}
      </td>
    </ng-container>
    <!-- Title -->
    <ng-container [nbTreeGridColumnDef]="columns[1]">
      <th nbTreeGridHeaderCell *nbTreeGridHeaderCellDef>
        {{ 'pentest.title' | translate }}
      </th>
      <td nbTreeGridCell *nbTreeGridCellDef="let pentest">
        {{ getTitle(pentest.data['refNumber']) | translate }}
      </td>
    </ng-container>
    <!-- Status -->
    <ng-container [nbTreeGridColumnDef]="columns[2]">
      <th nbTreeGridHeaderCell *nbTreeGridHeaderCellDef>
        {{ 'pentest.status' | translate }}
      </th>
      <td nbTreeGridCell *nbTreeGridCellDef="let pentest">
        <app-status-tag [currentStatus]="pentest.data['status']"></app-status-tag>
      </td>
    </ng-container>
    <!-- Findings -->
    <ng-container [nbTreeGridColumnDef]="columns[3]">
      <th nbTreeGridHeaderCell *nbTreeGridHeaderCellDef>
        {{ 'pentest.findings' | translate }}
      </th>
      <td nbTreeGridCell *nbTreeGridCellDef="let pentest">
        <app-findig-widget [numberOfFindigs]="pentest.data['findings']"></app-findig-widget>
        <!--ToDo: Add comments {{pentest.data['comments'] || '-'}}-->
      </td>
    </ng-container>
  </table>
</nb-card>

<!--ToDo: Add loading spinner after routing fix to avoid circular dependency issues
 <app-loading-spinner [isLoading$]="isLoading()" *ngIf="isLoading() | async"></app-loading-spinner>-->
