<!--
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>Resource Quotas</div>

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

  <div content
       [hidden]="!quotas?.length">
    <mat-table [dataSource]="getDataSource()"
               class="kd-table-no-footer">
      <ng-container [matColumnDef]="getQuotaColumns()[0]">
        <mat-header-cell *matHeaderCellDef
                         i18n>Name</mat-header-cell>
        <mat-cell *matCellDef="let quota">{{quota.objectMeta.name}}</mat-cell>
      </ng-container>
      <ng-container [matColumnDef]="getQuotaColumns()[1]">
        <mat-header-cell *matHeaderCellDef
                         i18n>Age</mat-header-cell>
        <mat-cell *matCellDef="let quota">
          <kd-date *ngIf="quota.objectMeta.creationTimestamp"
                   [date]="quota.objectMeta.creationTimestamp"
                   relative></kd-date>
          <ng-container *ngIf="!quota.objectMeta.creationTimestamp">-</ng-container>
        </mat-cell>
      </ng-container>
      <ng-container [matColumnDef]="getQuotaColumns()[2]">
        <mat-header-cell *matHeaderCellDef
                         i18n>Status</mat-header-cell>
        <mat-cell *matCellDef="let quota">
          <ng-container *ngIf="quota.statusList">{{quota.statusList | json}}</ng-container>
          <ng-container *ngIf="!quota.statusList">-</ng-container>
        </mat-cell>
      </ng-container>
      <mat-header-row *matHeaderRowDef="getQuotaColumns()"></mat-header-row>
      <mat-row *matRowDef="let row; columns: getQuotaColumns();"></mat-row>
    </mat-table>
  </div>

  <div content
       [hidden]="quotas?.length">
    <kd-list-zero-state></kd-list-zero-state>
  </div>
</kd-card>
