<!--
Copyright 2017 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<kd-card [initialized]="initialized"
         role="table">
  <div title
       i18n>Conditions</div>

  <div description>
    <div class="kd-inline-property"
         *ngIf="conditions?.length">
      <span class="kd-muted-light"
            i18n>Items:&nbsp;</span>
      <span>{{conditions.length}}</span>
    </div>
  </div>

  <div content>
    <mat-table [dataSource]="getDataSource()"
               class="kd-table-no-footer">
      <ng-container [matColumnDef]="getConditionsColumns()[0]">
        <mat-header-cell *matHeaderCellDef
                         i18n>Type</mat-header-cell>
        <mat-cell *matCellDef="let condition">
          <ng-container *ngIf="condition.type">{{condition.type}}</ng-container>
          <ng-container *ngIf="!condition.type">-</ng-container>
        </mat-cell>
      </ng-container>
      <ng-container [matColumnDef]="getConditionsColumns()[1]">
        <mat-header-cell *matHeaderCellDef
                         i18n>Status</mat-header-cell>
        <mat-cell *matCellDef="let condition">
          <ng-container *ngIf="condition.status">{{condition.status}}</ng-container>
          <ng-container *ngIf="!condition.status">-</ng-container>
        </mat-cell>
      </ng-container>
      <ng-container [matColumnDef]="getConditionsColumns()[2]">
        <mat-header-cell *matHeaderCellDef
                         i18n>Last probe time</mat-header-cell>
        <mat-cell *matCellDef="let condition">
          <kd-date [date]="condition.lastProbeTime"
                   relative></kd-date>
        </mat-cell>
      </ng-container>
      <ng-container [matColumnDef]="getConditionsColumns()[3]">
        <mat-header-cell *matHeaderCellDef
                         i18n>Last transition time</mat-header-cell>
        <mat-cell *matCellDef="let condition">
          <kd-date [date]="condition.lastTransitionTime"
                   relative></kd-date>
        </mat-cell>
      </ng-container>
      <ng-container [matColumnDef]="getConditionsColumns()[4]">
        <mat-header-cell *matHeaderCellDef
                         i18n>Reason</mat-header-cell>
        <mat-cell *matCellDef="let condition">
          <ng-container *ngIf="condition.reason">{{condition.reason}}</ng-container>
          <ng-container *ngIf="!condition.reason">-</ng-container>
        </mat-cell>
      </ng-container>
      <ng-container [matColumnDef]="getConditionsColumns()[5]">
        <mat-header-cell *matHeaderCellDef
                         i18n>Message</mat-header-cell>
        <mat-cell *matCellDef="let condition">
          <ng-container *ngIf="condition.message">{{condition.message}}</ng-container>
          <ng-container *ngIf="!condition.message">-</ng-container>
        </mat-cell>
      </ng-container>
      <mat-header-row *matHeaderRowDef="getColumnKeys()"></mat-header-row>
      <mat-row *matRowDef="let row; columns: getColumnKeys();"></mat-row>
    </mat-table>
  </div>
</kd-card>
