<!--
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]="deployment?.objectMeta"></kd-object-meta>

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

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

    <div class="kd-inline-property"
         *ngIf="deployment?.minReadySeconds !== null">
      <span class="kd-muted-light"
            i18n>Min ready seconds:&nbsp;</span>
      <span>{{deployment.minReadySeconds}}</span>
    </div>

    <div class="kd-inline-property"
         *ngIf="deployment?.revisionHistoryLimit !== null">
      <span class="kd-muted-light"
            i18n>Revision history limit:&nbsp;</span>
      <span>{{deployment.revisionHistoryLimit}}</span>
    </div>
  </div>

  <div content
       *ngIf="isInitialized"
       fxLayout="row wrap">
    <kd-property *ngIf="deployment?.strategy">
      <div key
           i18n>Strategy</div>
      <div value>{{deployment.strategy}}</div>
    </kd-property>

    <kd-property *ngIf="deployment?.minReadySeconds !== null">
      <div key
           i18n>Min ready seconds</div>
      <div value>{{deployment.minReadySeconds}}</div>
    </kd-property>

    <kd-property *ngIf="deployment?.revisionHistoryLimit !== null">
      <div key
           i18n>Revision history limit</div>
      <div value>{{deployment.revisionHistoryLimit}}</div>
    </kd-property>

    <kd-property *ngIf="deployment?.selector"
                 fxFlex="100">
      <div key
           i18n>Selector</div>
      <div value>
        <kd-chips [map]="deployment.selector"
                  [displayAll]="true"></kd-chips>
      </div>
    </kd-property>
  </div>
</kd-card>

<kd-card [initialized]="isInitialized">
  <div title
       i18n>Rolling update strategy</div>

  <div description>
    <div class="kd-inline-property"
         *ngIf="deployment?.rollingUpdateStrategy?.maxSurge > 0">
      <span class="kd-muted-light"
            i18n>Max surge:&nbsp;</span>
      <span>{{deployment.rollingUpdateStrategy.maxSurge}}</span>
    </div>

    <div class="kd-inline-property"
         *ngIf="deployment?.rollingUpdateStrategy?.maxUnavailable > 0">
      <span class="kd-muted-light"
            i18n>Max unavailable:&nbsp;</span>
      <span>{{deployment.rollingUpdateStrategy.maxUnavailable}}</span>
    </div>
  </div>

  <div content
       *ngIf="isInitialized"
       fxLayout="row wrap">
    <kd-property *ngIf="deployment?.rollingUpdateStrategy?.maxSurge !== null">
      <div key
           i18n>Max surge</div>
      <div value>{{deployment.rollingUpdateStrategy.maxSurge}}</div>
    </kd-property>

    <kd-property *ngIf="deployment?.rollingUpdateStrategy?.maxUnavailable !== null">
      <div key
           i18n>Max unavailable</div>
      <div value>{{deployment.rollingUpdateStrategy.maxUnavailable}}</div>
    </kd-property>
  </div>
</kd-card>

<kd-card [initialized]="isInitialized">
  <div title
       i18n>Pods status</div>

  <div description>
    <div class="kd-inline-property"
         *ngIf="deployment?.statusInfo?.updated > 0">
      <span class="kd-muted-light"
            i18n>Updated:&nbsp;</span>
      <span>{{deployment.statusInfo.updated}}</span>
    </div>

    <div class="kd-inline-property"
         *ngIf="deployment?.statusInfo?.replicas > 0">
      <span class="kd-muted-light"
            i18n>Total:&nbsp;</span>
      <span>{{deployment.statusInfo.replicas}}</span>
    </div>

    <div class="kd-inline-property"
         *ngIf="deployment?.statusInfo?.available > 0">
      <span class="kd-muted-light"
            i18n>Available:&nbsp;</span>
      <span>{{deployment.statusInfo.available}}</span>
    </div>

    <div class="kd-inline-property"
         *ngIf="deployment?.statusInfo?.unavailable > 0">
      <span class="kd-muted-light"
            i18n>Unavailable:&nbsp;</span>
      <span>{{deployment.statusInfo.unavailable}}</span>
    </div>
  </div>

  <div content
       *ngIf="isInitialized"
       fxLayout="row wrap">
    <kd-property *ngIf="deployment?.statusInfo?.updated > 0">
      <div key
           i18n>Updated</div>
      <div value>{{deployment.statusInfo.updated}}</div>
    </kd-property>

    <kd-property *ngIf="deployment?.statusInfo?.replicas > 0">
      <div key
           i18n>Total</div>
      <div value>{{deployment.statusInfo.replicas}}</div>
    </kd-property>

    <kd-property *ngIf="deployment?.statusInfo?.available > 0">
      <div key
           i18n>Available</div>
      <div value>{{deployment.statusInfo.available}}</div>
    </kd-property>

    <kd-property *ngIf="deployment?.statusInfo?.unavailable > 0">
      <div key
           i18n>Unavailable</div>
      <div value>{{deployment.statusInfo.unavailable}}</div>
    </kd-property>
  </div>
</kd-card>

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

<kd-card *ngIf="newReplicaSet"
         [initialized]="isInitialized">
  <div title
       i18n>New Replica Set</div>

  <div description>
    <div class="kd-inline-property"
         *ngIf="newReplicaSet?.objectMeta.name">
      <span class="kd-muted-light"
            i18n>Name:&nbsp;</span>
      <span>{{newReplicaSet.objectMeta.name}}</span>
    </div>

    <div class="kd-inline-property"
         *ngIf="newReplicaSet?.objectMeta.namespace">
      <span class="kd-muted-light"
            i18n>Namespace:&nbsp;</span>
      <span>{{newReplicaSet.objectMeta.namespace}}</span>
    </div>

    <div class="kd-inline-property"
         *ngIf="newReplicaSet?.objectMeta.creationTimestamp">
      <span class="kd-muted-light"
            i18n>Age:&nbsp;</span>
      <kd-date [date]="newReplicaSet.objectMeta.creationTimestamp"
               relative></kd-date>
    </div>

    <div class="kd-inline-property"
         *ngIf="newReplicaSet?.podInfo">
      <span class="kd-muted-light"
            i18n>Pods:&nbsp;</span>
      <span>{{newReplicaSet.podInfo.running}} / {{newReplicaSet.podInfo.desired}}</span>
    </div>
  </div>

  <div content
       *ngIf="isInitialized"
       fxLayout="row wrap">
    <kd-property *ngIf="newReplicaSet?.objectMeta.name">
      <div key
           i18n>Name</div>
      <a value
         [routerLink]="getNewReplicaSetHref()"
         queryParamsHandling="preserve">{{newReplicaSet.objectMeta.name}}</a>
    </kd-property>

    <kd-property *ngIf="newReplicaSet?.objectMeta.namespace">
      <div key
           i18n>Namespace</div>
      <div value>{{newReplicaSet.objectMeta.namespace}}</div>
    </kd-property>

    <kd-property *ngIf="newReplicaSet?.objectMeta.creationTimestamp">
      <div key
           i18n>Age
      </div>
      <div value>
        <kd-date [date]="newReplicaSet.objectMeta.creationTimestamp"
                 relative></kd-date>
      </div>
    </kd-property>

    <kd-property *ngIf="newReplicaSet?.podInfo">
      <div key
           i18n>Pods</div>
      <div value>{{newReplicaSet.podInfo.running}} / {{newReplicaSet.podInfo.desired}}</div>
    </kd-property>

    <kd-property *ngIf="newReplicaSet?.objectMeta?.labels"
                 fxFlex="100">
      <div key
           i18n>Labels</div>
      <div value>
        <kd-chips [map]="newReplicaSet.objectMeta.labels"
                  [displayAll]="true"></kd-chips>
      </div>
    </kd-property>

    <kd-property *ngIf="newReplicaSet?.containerImages">
      <div key
           i18n>Images</div>
      <div value>
        <kd-chips [map]="newReplicaSet.containerImages"
                  [displayAll]="true"></kd-chips>
      </div>
    </kd-property>

    <kd-property *ngIf="newReplicaSet?.initContainerImages">
      <div key
           i18n>Init images</div>
      <div value>
        <kd-chips [map]="newReplicaSet.initContainerImages"
                  [displayAll]="true"></kd-chips>
      </div>
    </kd-property>
  </div>
</kd-card>

<kd-replica-set-list [endpoint]="oldReplicaSetsEndpoint"
                     i18n-title
                     title="Old Replica Sets"></kd-replica-set-list>

<kd-horizontal-pod-autoscaler-list [endpoint]="horizontalPodAutoscalerEndpoint"
                                   i18n-title
                                   title="Horizontal Pod Autoscaler"></kd-horizontal-pod-autoscaler-list>

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