<!--
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">
  <div description><span class="kd-muted-light"
          i18n>Image:&nbsp;</span>{{container.image}}</div>
  <div title>{{container.name}}</div>
  <div content
       fxFlex
       fxLayout="row wrap">
    <kd-property fxFlex="100">
      <div key
           i18n>Image</div>
      <div value>{{container.image}}</div>
    </kd-property>

    <div *ngFor="let env of container?.env;trackBy:getEnvVarID"
         fxFlex="20">
      <ng-container *ngIf="!isSecret(env) && !isConfigMap(env)">
        <kd-property>
          <div key
               fxLayout>
            {{env.name}}
            <mat-icon matTooltip="Environment variable"
                      i18n-matTooltip
                      class="kd-env-variable-icon">public</mat-icon>
          </div>
          <div value>{{env.value}}</div>
        </kd-property>
      </ng-container>

      <ng-container *ngIf="isSecret(env)">
        <kd-hidden-property>
          <div key
               fxLayout>
            <a [routerLink]="getEnvSecretHref(env.valueFrom.secretKeyRef)"
               queryParamsHandling="preserve"
               (click)="$event.stopPropagation()">
              {{env.name}}
            </a>
            <mat-icon matTooltip="Environment variable"
                      i18n-matTooltip
                      class="kd-env-variable-icon">public</mat-icon>
          </div>
          <div whenVisible
               class="kd-code-block">{{formatSecretValue(env.value)}}</div>
          <div whenHidden
               i18n>{{formatSecretValue(env.value).length}} bytes</div>
        </kd-hidden-property>
      </ng-container>

      <ng-container *ngIf="isConfigMap(env)">
        <kd-hidden-property>
          <div key
               fxLayout>
            <a [routerLink]="getEnvConfigMapHref(env.valueFrom.configMapKeyRef)"
               queryParamsHandling="preserve"
               (click)="$event.stopPropagation()">
              {{env.name}}
            </a>
            <mat-icon matTooltip="Environment variable"
                      i18n-matTooltip
                      class="kd-env-variable-icon">public</mat-icon>
          </div>
          <div whenVisible
               class="kd-code-block">{{env.value}}</div>
          <div whenHidden
               i18n>{{env.value.length}} bytes</div>
        </kd-hidden-property>
      </ng-container>
    </div>

    <kd-property *ngIf="container?.commands?.length"
                 fxFlex="100">
      <div key
           i18n>Commands</div>
      <div value>
        <div class="kd-code-block kd-no-whitespace">
          <div *ngFor="let command of container.commands"
               class="kd-code-block-font">{{command}}</div>
        </div>
      </div>
    </kd-property>

    <kd-property *ngIf="container?.args?.length"
                 fxFlex="100">
      <div key
           i18n>Arguments</div>
      <div value>
        <div class="kd-code-block kd-no-whitespace">
          <div *ngFor="let arg of container.args"
               class="kd-code-block-font">{{arg}}</div>
        </div>
      </div>
    </kd-property>
  </div>
</kd-card>
