<div *ngIf="object" class="fl-content" layoutDirection="column">
  <ng-container *ngIf="listenerList && listenerList.objects.length > 0; else noListeners">
    <table mat-table [dataSource]="listenerList.objects" class="full-width fl-margin-bottom">
      <ng-container matColumnDef="name">
        <th mat-header-cell *matHeaderCellDef i18n>Name</th>
        <td mat-cell *matCellDef="let listener">
          <a class="active-link"
             [routerLink]="[config.getPanelUrl('openstack/load-balancers'), object.id, 'listeners', listener.id]"
             [queryParamsHandling]="'merge'">
            {{listener.name | nullValue}}
          </a>
        </td>
      </ng-container>
      <ng-container matColumnDef="protocol">
        <th mat-header-cell *matHeaderCellDef class="hide-xs" i18n>Protocol</th>
        <td mat-cell *matCellDef="let listener" class="hide-xs">
          {{listener.protocol}}
        </td>
      </ng-container>
      <ng-container matColumnDef="protocol_port">
        <th mat-header-cell *matHeaderCellDef i18n>Port</th>
        <td mat-cell *matCellDef="let listener">
          {{listener.protocol_port}}
        </td>
      </ng-container>
      <ng-container matColumnDef="operating_status">
        <th mat-header-cell *matHeaderCellDef i18n>Operating status</th>
        <td mat-cell *matCellDef="let listener">
          {{listener.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 listener" class="hide-xs">
          {{listener.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 listener" class="hide-xs">
          {{listener.admin_state_up | yesNo}}
        </td>
      </ng-container>
      <ng-container matColumnDef="(actions)">
        <th mat-header-cell *matHeaderCellDef i18n></th>
        <td mat-cell *matCellDef="let listener" i18n>
          <app-object-actions [objectActions]="listenerActions[listener.id]" [maxVisibleActions]="2">
          </app-object-actions>
        </td>
      </ng-container>
      <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
      <tr mat-row *matRowDef="let listener; columns: displayedColumns;"></tr>
    </table>
  </ng-container>
  <ng-template #noListeners>
    <p *ngIf="listenerList" class="fl-detail fl-margin-bottom" layoutAlign="center center" i18n>No listeners.</p>
    <p *ngIf="!listenerList && !cannotRetrieve" class="fl-detail fl-margin-bottom" layoutAlign="center center"
       i18n>Loading listeners ...</p>
    <p *ngIf="!listenerList && cannotRetrieve" class="fl-detail fl-margin-bottom fl-red-color"
       layoutAlign="center center" i18n>Unable to retrieve listeners, please contact support.</p>
  </ng-template>
  <div layoutDirection="row" layoutAlign="center center">
    <a mat-fab [disabled]="cannotRetrieve" fl-tooltip="Create listener" i18n-fl-tooltip
       [routerLink]="[config.getPanelUrl('openstack/load-balancers', object.id), 'listeners', 'create']"
       [queryParamsHandling]="'merge'">
      <mat-icon>add</mat-icon>
    </a>
  </div>
</div>
