<page-header title="'Image details'" breadcrumbs="[{label:'Images', link:'docker.images'}, image.Id]"> </page-header>

<div class="row" ng-if="image.RepoTags.length > 0">
  <div class="col-lg-12 col-md-12 col-xs-12">
    <rd-widget>
      <rd-widget-header icon="tag" title-text="Image tags"></rd-widget-header>
      <rd-widget-body>
        <form class="form-horizontal">
          <div class="form-group">
            <div class="row">
              <div class="pull-left" ng-repeat="tag in image.RepoTags" style="display: table">
                <div class="input-group col-md-1 !pl-3.5 !pr-3.5">
                  <span class="input-group-addon" style="border-right: 1px solid var(--border-input-group-addon-color); border-radius: 4px" data-cy="image-tag-{{ tag }}">{{
                    tag
                  }}</span>
                  <span class="input-group-btn" style="padding: 0px 5px">
                    <span style="margin: 0px 5px" authorization="DockerImagePush">
                      <a data-toggle="tooltip" class="btn btn-primary interactive" title="Push to registry" ng-click="pushTag(tag)">
                        <pr-icon icon="'upload'" class="text-white"></pr-icon>
                      </a>
                    </span>

                    <span class="mx-1 my-0" authorization="DockerImageCreate">
                      <a data-toggle="tooltip" class="btn btn-primary interactive" title="Pull from registry" ng-click="pullTag(tag)">
                        <pr-icon icon="'download'" class="text-white"></pr-icon>
                      </a>
                    </span>

                    <span class="mx-1 my-0" authorization="DockerImageDelete">
                      <a data-toggle="tooltip" class="btn btn-primary interactive" title="Remove tag" ng-click="removeTag(tag)">
                        <pr-icon icon="'trash-2'" class="text-white"></pr-icon>
                      </a>
                    </span>
                  </span>
                </div>
              </div>
            </div>
          </div>
          <div class="form-group">
            <div class="col-sm-12">
              <span class="small text-muted" authorization="DockerImageDelete">
                Note: you can click on the upload icon <pr-icon icon="'upload'"></pr-icon> to push an image or on the download icon <pr-icon icon="'download'"></pr-icon> to pull an
                image or on the trash icon <pr-icon icon="'trash-2'"></pr-icon> to delete a tag.
              </span>
            </div>
            <div class="col-sm-12">
              <span id="downloadResourceHint" class="createResource ml-0" style="display: none">
                Download in progress...
                <pr-icon icon="'loader-2'" class-name="'animate-spin-slow ml-0.5'"></pr-icon>
              </span>
              <span id="uploadResourceHint" class="createResource ml-0.5" style="display: none">
                Upload in progress...
                <pr-icon icon="'loader-2'" class-name="'animate-spin-slow ml-0.5'"></pr-icon>
              </span>
            </div>
          </div>
        </form>
      </rd-widget-body>
    </rd-widget>
  </div>
</div>

<div class="row" authorization="DockerImageCreate">
  <div class="col-lg-12 col-md-12 col-xs-12">
    <rd-widget>
      <rd-widget-header icon="tag" title-text="Tag the image"></rd-widget-header>
      <rd-widget-body>
        <form class="form-horizontal">
          <!-- image-and-registry -->
          <por-image-registry
            model="formValues.RegistryModel"
            label-class="col-sm-1"
            input-class="col-sm-11"
            endpoint="endpoint"
            is-admin="isAdmin"
            set-validity="setPullImageValidity"
            check-rate-limits="true"
          ></por-image-registry>
          <!-- !image-and-registry -->
          <!-- tag-note -->
          <div class="form-group">
            <div class="col-sm-12">
              <span class="small text-muted">Note: if you don't specify the tag in the image name, <span class="label label-default">latest</span> will be used.</span>
            </div>
          </div>
          <!-- !tag-note -->
          <div class="form-group">
            <div class="col-sm-12">
              <button type="button" class="btn btn-primary btn-sm !ml-0" ng-disabled="!formValues.RegistryModel.Image" ng-click="tagImage()">Tag</button>
            </div>
          </div>
        </form>
      </rd-widget-body>
    </rd-widget>
  </div>
</div>

<div class="row">
  <div class="col-lg-12 col-md-12 col-xs-12">
    <rd-widget>
      <rd-widget-header icon="list" title-text="Image details"></rd-widget-header>
      <rd-widget-body classes="no-padding">
        <table class="table">
          <tbody>
            <tr>
              <td class="min-w-[80px]">ID</td>
              <td>
                {{ image.Id }}
                <button authorization="DockerImageDelete" class="btn btn-xs btn-danger" ng-click="removeImage(image.Id)">
                  <pr-icon icon="'trash-2'"></pr-icon> Delete this image
                </button>
                <button
                  authorization="DockerImageGet"
                  class="btn btn-xs btn-primary"
                  ng-click="exportImage(image)"
                  button-spinner="$ctrl.exportInProgress"
                  ng-disabled="state.exportInProgress"
                >
                  <pr-icon icon="'download'"></pr-icon>
                  <span ng-hide="state.exportInProgress">Export this image</span>
                  <span ng-show="state.exportInProgress">Export in progress...</span>
                </button>
              </td>
            </tr>
            <tr ng-if="image.Parent">
              <td>Parent</td>
              <td
                ><a ui-sref="docker.images.image({id: image.Parent})">{{ image.Parent }}</a></td
              >
            </tr>
            <tr>
              <td>Size</td>
              <td>{{ image.Size | humansize }}</td>
            </tr>
            <tr>
              <td>Created</td>
              <td>{{ image.Created | getisodate }}</td>
            </tr>
            <tr>
              <td>Build</td>
              <td>Docker {{ image.DockerVersion }} on {{ image.Os }}, {{ image.Architecture }}</td>
            </tr>
            <tr ng-if="!(image.Labels | emptyobject)">
              <td>Labels</td>
              <td>
                <table class="table-bordered table-condensed table">
                  <tr ng-repeat="(k, v) in image.Labels">
                    <td class="min-w-[80px]">{{ k }}</td>
                    <td>{{ v }}</td>
                  </tr>
                </table>
              </td>
            </tr>
            <tr ng-if="image.Author">
              <td>Author</td>
              <td>{{ image.Author }}</td>
            </tr>
          </tbody>
        </table>
      </rd-widget-body>
    </rd-widget>
  </div>
</div>

<dockerfile-details ng-if="image" image="image"></dockerfile-details>

<div class="row" ng-if="history.length > 0">
  <div class="col-lg-12 col-md-12 col-xs-12">
    <rd-widget>
      <rd-widget-header icon="list" title-text="Image layers"></rd-widget-header>
      <rd-widget-body classes="no-padding">
        <table id="image-layers" class="table">
          <thead>
            <th class="whitespace-nowrap">
              <table-column-header
                col-title="'Order'"
                can-sort="true"
                is-sorted="$ctrl.state.orderBy === 'Order'"
                is-sorted-desc="$ctrl.state.orderBy === 'Order' && $ctrl.state.reverseOrder"
                ng-click="$ctrl.changeOrderBy('Order')"
              ></table-column-header>
            </th>
            <th>
              <table-column-header
                col-title="'Size'"
                can-sort="true"
                is-sorted="$ctrl.state.orderBy === 'Size'"
                is-sorted-desc="$ctrl.state.orderBy === 'Size' && $ctrl.state.reverseOrder"
                ng-click="$ctrl.changeOrderBy('Size')"
              ></table-column-header>
            </th>
            <th>
              <table-column-header
                col-title="'Layer'"
                can-sort="true"
                is-sorted="$ctrl.state.orderBy === 'Layer'"
                is-sorted-desc="$ctrl.state.orderBy === 'Layer' && $ctrl.state.reverseOrder"
                ng-click="$ctrl.changeOrderBy('Layer')"
              ></table-column-header>
            </th>
          </thead>
          <tbody>
            <tr ng-repeat="layer in history | orderBy:sortType:sortReverse">
              <td class="whitespace-nowrap">
                {{ layer.Order }}
              </td>
              <td class="whitespace-nowrap">
                {{ layer.Size | humansize }}
              </td>
              <td class="expand">
                <div ng-if="layer.CreatedBy.length > 130">
                  <span id="layer-command-{{ $index }}-full" style="display: none">
                    {{ layer.CreatedBy | imagelayercommand }}
                  </span>
                  <span id="layer-command-{{ $index }}-short">
                    {{ layer.CreatedBy | imagelayercommand | truncate: 130 }}
                    <span ng-if="layer.CreatedBy.length > 130" class="ml-1">
                      <a id="layer-command-expander{{ $index }}" class="btn" ng-click="toggleLayerCommand($index)">
                        <pr-icon icon="'plus'" mode="'alt'"></pr-icon>
                      </a>
                    </span>
                  </span>
                </div>
                <div ng-if="layer.CreatedBy.length <= 130">
                  <span id="layer-command-{{ $index }}-full">
                    {{ layer.CreatedBy | imagelayercommand }}
                  </span>
                </div>
              </td>
            </tr>
          </tbody>
        </table>
      </rd-widget-body>
    </rd-widget>
  </div>
</div>
