<div *ngIf="object" class="fl-content" layoutDirection="column">
  <ng-container *ngIf="policyList && policyList.objects.length > 0; else noPolicies">
    <table mat-table [dataSource]="policyList.objects" class="full-width fl-margin-bottom">
      <ng-container matColumnDef="name">
        <th mat-header-cell *matHeaderCellDef i18n>Name</th>
        <td mat-cell *matCellDef="let policy" class="policy-name">
          <a class="active-link"
             [routerLink]="[config.getPanelUrl('openstack/load-balancers'), loadBalancerId, 'listeners', object.id, 'policy', policy.id]"
             [queryParamsHandling]="'merge'">
            {{policy.name | nullValue:'none'}}
          </a>
        </td>
      </ng-container>
      <ng-container matColumnDef="position">
        <th mat-header-cell *matHeaderCellDef i18n>Position</th>
        <td mat-cell *matCellDef="let policy">
          {{policy.position}}
        </td>
      </ng-container>
      <ng-container matColumnDef="action">
        <th mat-header-cell *matHeaderCellDef class="hide-xs" i18n>Action</th>
        <td mat-cell *matCellDef="let policy" class="hide-xs">
          {{policy.action}}
        </td>
      </ng-container>
      <ng-container matColumnDef="operating_status">
        <th mat-header-cell *matHeaderCellDef class="hide-xs" i18n>Operating status</th>
        <td mat-cell *matCellDef="let policy" class="hide-xs">
          {{policy.operating_status}}
        </td>
      </ng-container>
      <ng-container matColumnDef="provisioning_status">
        <th mat-header-cell *matHeaderCellDef class="hide-xs" i18n>Provisioning status</th>
        <td mat-cell *matCellDef="let policy" class="hide-xs">
          {{policy.provisioning_status}}
        </td>
      </ng-container>
      <ng-container matColumnDef="admin_state_up">
        <th mat-header-cell *matHeaderCellDef class="hide-xs" i18n>Admin state up</th>
        <td mat-cell *matCellDef="let policy" class="hide-xs">
          {{policy.admin_state_up | yesNo }}
        </td>
      </ng-container>
      <ng-container matColumnDef="(actions)">
        <th mat-header-cell *matHeaderCellDef i18n></th>
        <td mat-cell *matCellDef="let policy">
          <app-object-actions [objectActions]="policyActions[policy.id]" [maxVisibleActions]="2">
          </app-object-actions>
        </td>
      </ng-container>
      <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
      <tr mat-row *matRowDef="let policy; columns: displayedColumns;"></tr>
    </table>
  </ng-container>
  <ng-template #noPolicies>
    <p *ngIf="policyList" class="fl-detail fl-margin-bottom" layoutAlign="center center" i18n>No policies.</p>
    <p *ngIf="!policyList" class="fl-detail fl-margin-bottom" layoutAlign="center center" i18n>Loading policies
      ...</p>
  </ng-template>
  <div layoutDirection="row" layoutAlign="center center">
    <a mat-fab fl-tooltip="Create L7 policy" i18n-fl-tooltip
       [routerLink]="[config.getPanelUrl('openstack/load-balancers', loadBalancerId), 'listeners', object.id, 'policy-create']"
       [queryParamsHandling]="'merge'">
      <mat-icon>add</mat-icon>
    </a>
  </div>
</div>
