<!--
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-graph-metrics [metrics]="pod?.metrics"></kd-graph-metrics>

<kd-object-meta [initialized]="isInitialized"
                [objectMeta]="pod?.objectMeta"></kd-object-meta>

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

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

    <div class="kd-inline-property"
         *ngIf="pod?.podIP">
      <span class="kd-muted-light"
            i18n>IP:&nbsp;</span>
      <span>{{pod.podIP}}</span>
    </div>
  </div>

  <div content
       *ngIf="isInitialized"
       fxLayout="row wrap">
    <kd-property *ngIf="pod?.nodeName">
      <div key
           i18n>Node
      </div>
      <a value
         [routerLink]="getNodeHref(pod.nodeName)"
         queryParamsHandling="preserve">{{pod.nodeName}}</a>
    </kd-property>

    <kd-property *ngIf="pod?.podPhase">
      <div key
           i18n>Status
      </div>
      <div value>{{pod?.podPhase}}</div>
    </kd-property>

    <kd-property *ngIf="pod?.podIP">
      <div key
           i18n>IP
      </div>
      <div value>{{pod.podIP}}</div>
    </kd-property>

    <kd-property *ngIf="pod?.qosClass">
      <div key
           i18n>QoS Class
      </div>
      <div value>{{pod.qosClass}}</div>
    </kd-property>

    <kd-property *ngIf="pod?.restartCount !== undefined">
      <div key
           i18n>Restarts
      </div>
      <div value>{{pod.restartCount}}</div>
    </kd-property>

    <kd-property *ngIf="pod?.serviceAccountName">
      <div key
           i18n>Service Account
      </div>
      <div value>
        <a [routerLink]="getObjectHref('serviceaccount', pod.serviceAccountName)"
           queryParamsHandling="preserve">{{pod.serviceAccountName}}</a>
      </div>
    </kd-property>

    <kd-property *ngIf="pod?.imagePullSecrets"
                 fxFlex="100">
      <div key
           i18n>Image Pull Secrets
      </div>
      <div value
           *ngFor="let imagePullSecret of pod?.imagePullSecrets">
        <a [routerLink]="getObjectHref('secret', imagePullSecret.name)"
           queryParamsHandling="preserve">{{imagePullSecret.name}}</a>
      </div>
    </kd-property>

    <div *ngIf="hasSecurityContext()"
         fxFlex="100"
         fxLayout="column">
      <div fxFlex
           class="kd-muted section-header"
           i18n>Security Context
      </div>

      <kd-security-context [securityContext]="pod?.securityContext"
                           [initialized]="true">
      </kd-security-context>
    </div>
  </div>
</kd-card>

<kd-condition-list [conditions]="pod?.conditions"
                   [initialized]="isInitialized"></kd-condition-list>

<kd-creator-card *ngIf="pod?.controller?.typeMeta?.kind"
                 [creator]="pod?.controller"
                 [initialized]="isInitialized"></kd-creator-card>

<kd-persistent-volume-claim-list *ngIf="pod?.persistentVolumeClaimList"
                                 [endpoint]="pvcListEndpoint"></kd-persistent-volume-claim-list>

<kd-event-list [endpoint]="eventListEndpoint"></kd-event-list>

<div *ngIf="pod?.containers?.length"
     class="kd-card-group-header kd-muted"
     i18n>Containers
</div>
<kd-container-card *ngFor="let container of pod?.containers;trackBy:getContainerName"
                   [container]="container"
                   [namespace]="pod.objectMeta.namespace"
                   [initialized]="isInitialized"></kd-container-card>

<div *ngIf="pod?.initContainers?.length"
     class="kd-card-group-header kd-muted"
     i18n>Init containers
</div>
<kd-container-card *ngFor="let container of pod?.initContainers;trackBy:getContainerName"
                   [container]="container"
                   [namespace]="pod.objectMeta.namespace"
                   [initialized]="isInitialized"></kd-container-card>
