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

<kd-card *ngIf="ingress?.spec?.backend || ingress?.endpoints"
         [initialized]="isInitialized">
  <div title
       i18n>Resource information</div>
  <div content
       *ngIf="isInitialized"
       fxLayout="row wrap">
    <kd-property *ngIf="ingress?.spec?.backend?.service?.Name">
      <div key
           i18n>Service Name</div>
      <div value>{{ingress.spec.backend.service.Name}}</div>
    </kd-property>

    <kd-property *ngIf="ingress?.spec?.backend?.service?.port">
      <div key
           i18n>Service Port</div>
      <div *ngIf="ingress?.spec?.backend?.service?.port?.name"
           value>{{ingress.spec.backend.service.port.name}}</div>
      <div *ngIf="ingress?.spec?.backend?.service?.port?.number"
           value>{{ingress.spec.backend.service.port.number}}</div>
    </kd-property>

    <kd-property *ngIf="ingress?.spec?.backend?.resource?.name">
      <div key
           i18n>{{ingress.spec.backend.resource.kind}}</div>
      <div value>{{ingress.spec.backend.resource.name}}</div>
    </kd-property>

    <kd-property *ngIf="ingress?.endpoints"
                 fxFlex="100">
      <div key
           i18n>Endpoints</div>
      <div value>
        <kd-external-endpoint *ngFor="let endpoint of ingress.endpoints"
                              [endpoints]="[endpoint]"></kd-external-endpoint>
      </div>
    </kd-property>
  </div>
</kd-card>

<kd-ingressruleflat-card-list [ingressSpecRules]="ingress?.spec.rules"
                              [tlsList]="ingress?.spec.tls"
                              [namespace]="ingress?.objectMeta.namespace"
                              [initialized]="isInitialized">
</kd-ingressruleflat-card-list>
