<!--
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-object-meta [initialized]="isInitialized"
                [objectMeta]="persistentVolume?.objectMeta"></kd-object-meta>

<kd-card [initialized]="isInitialized">
  <div title
       i18n>Resource information</div>

  <div content
       *ngIf="isInitialized"
       fxLayout="row wrap">
    <kd-property *ngIf="persistentVolume?.status">
      <div key
           i18n>Status</div>
      <div value>{{persistentVolume.status}}</div>
    </kd-property>

    <kd-property *ngIf="persistentVolume?.claim">
      <div key
           i18n>Claim</div>
      <div value>
        <a [routerLink]="getClaimHref(persistentVolume.claim)"
           queryParamsHandling="preserve">
          {{persistentVolume.claim}}
        </a>
      </div>
    </kd-property>

    <kd-property *ngIf="persistentVolume?.reclaimPolicy">
      <div key
           i18n>Reclaim policy</div>
      <div value>{{persistentVolume.reclaimPolicy}}</div>
    </kd-property>

    <kd-property *ngIf="persistentVolume?.storageClass">
      <div key
           i18n>Storage class</div>
      <div value>
        <div value>{{persistentVolume.storageClass}}</div>
      </div>
    </kd-property>

    <kd-property *ngIf="persistentVolume?.reason">
      <div key
           i18n>Reason</div>
      <div value>{{persistentVolume.reason}}</div>
    </kd-property>

    <kd-property *ngIf="persistentVolume?.message">
      <div key
           i18n>Message</div>
      <div value>{{persistentVolume.message}}</div>
    </kd-property>

    <kd-property *ngIf="persistentVolume?.accessModes"
                 fxFlex="100">
      <div key
           i18n>Access modes</div>
      <div value>
        <kd-chips [map]="persistentVolume.accessModes"
                  [displayAll]="true"></kd-chips>
      </div>
    </kd-property>
  </div>
</kd-card>

<kd-persistent-volume-source [source]="persistentVolume?.persistentVolumeSource"
                             [initialized]="isInitialized"></kd-persistent-volume-source>

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

  <div content>
    <mat-table [dataSource]="getCapacityDataSource()"
               [trackBy]="trackByCapacityItemName">
      <ng-container [matColumnDef]="getCapacityColumns()[0]">
        <mat-header-cell *matHeaderCellDef
                         i18n>Resource name</mat-header-cell>
        <mat-cell *matCellDef="let capacity">
          <ng-container *ngIf="capacity.resourceName">{{capacity.resourceName}}</ng-container>
          <ng-container *ngIf="!capacity.resourceName">-</ng-container>
        </mat-cell>
      </ng-container>

      <ng-container [matColumnDef]="getCapacityColumns()[1]">
        <mat-header-cell *matHeaderCellDef
                         i18n>Quantity</mat-header-cell>
        <mat-cell *matCellDef="let capacity">
          <ng-container *ngIf="capacity.quantity">{{capacity.quantity}}</ng-container>
          <ng-container *ngIf="!capacity.quantity">-</ng-container>
        </mat-cell>
      </ng-container>

      <mat-header-row *matHeaderRowDef="getCapacityColumns()"></mat-header-row>
      <mat-row *matRowDef="let row; columns: getCapacityColumns();"></mat-row>
    </mat-table>
  </div>
</kd-card>
