<span page-title>{{ 'New Repository' | translate }}</span>

<header data-block="sub-header">
  <h2 translate>New Repository</h2>
</header>

<div bst-alerts error-messages="errorMessages" success-messages="successMessages"></div>

<div data-block="content">
  <form name="repositoryForm" class="col-sm-5" novalidate role="form">
    <div>
      <h4 translate> General Information </h4>
      <div bst-form-group label="{{ 'Name' | translate }}">
        <input id="name"
               name="name"
               ng-model="repository.name"
               type="text"
               autofocus
               required/>
      </div>

      <div bst-form-group label="{{ 'Label' | translate }}">
        <input id="label"
               name="label"
               ng-model="repository.label"
               type="text"
               required/>
      </div>
      <div bst-form-group label="{{ 'Type' | translate }}">
        <select required
                id="content_type"
                name="content_type"
                ng-model="repository.content_type"
                ng-options="type.name as type.name for type in repositoryTypes">
        </select>
      </div>
    </div>
    <div ng-show="repository.content_type !== undefined">
      <h4 translate> Sync Information </h4>
      <div bst-form-group label="{{ 'URL' | translate }}">
        <input id="url"
               name="url"
               ng-model="repository.url"
               type="text"
               ng-required="repository.content_type === 'docker'"/>
        <h6 ng-show="repository.content_type === 'docker'" translate>
          URL of the registry you want to sync. Example: https://registry-1.docker.io/
        </h6>

      </div>

      <div bst-form-group label="{{ 'Upstream Repository Name' | translate }}"  ng-show="repository.content_type === 'docker'">
        <input id="docker_upstream_name"
               name="docker_upstream_name"
               ng-model="repository.docker_upstream_name"
               type="text"
               ng-required="repository.content_type === 'docker'"/>
        <h6 translate>
          Name of the upstream repository you want to sync. Example: 'busybox' or 'fedora/ssh'.
        </h6>

      </div>

      <div bst-form-group label="{{ 'Verify SSL' | translate }}">
        <input id="verify_ssl_on_sync"
               name="verify_ssl_on_sync"
               ng-model="repository.verify_ssl_on_sync"
               type="checkbox"/>
        <h6 translate>
          Selecting this option will result in Katello verifying that the upstream url's SSL certificates are signed by a trusted CA. Unselect if you do not want this verification.
        </h6>
      </div>

      <div bst-form-group label="{{ 'Upstream Username' | translate }}" >
        <input id="upstream_username"
               name="upstream_username"
               ng-model="repository.upstream_username"
               type="text"/>
        <h6 translate>
          Username of the upstream repository user for authentication. Leave empty if repository does not require authentication.
        </h6>
      </div>

      <div bst-form-group label="{{ 'Upstream Password' | translate }}" >
        <input id="upstream_password"
               name="upstream_password"
               ng-model="repository.upstream_password"
               type="password"/>
        <h6 translate>
          Password of the upstream repository user for authentication. Leave empty if repository does not require authentication.
        </h6>
      </div>


      <div bst-form-group label="{{ 'Download Policy' | translate }}" ng-show="repository.content_type === 'yum'">
        <select id="download_policy"
                name="download_policy"
                ng-model="repository.download_policy"
                ng-options="id as name for (id, name) in downloadPolicies">
        </select>
      </div>

      <div bst-form-group label="{{ 'Mirror On Sync' | translate }}" ng-show="repository.content_type === 'yum'">
        <input id="mirror_on_sync"
               name="mirror_on_sync"
               ng-model="repository.mirror_on_sync"
               type="checkbox"/>
        <h6 translate>
          Selecting this option will result in contents that are no longer part of the upstream repository being removed during synchronization.
        </h6>
      </div>
    </div>

    <div ng-show="repository.content_type === 'yum' || repository.content_type === 'puppet'">
      <h4 ng-show="repository.content_type !== undefined" translate> Published Repository Information </h4>

      <div bst-form-group label="{{ 'Checksum' | translate }}" ng-show="repository.content_type === 'yum'">
        <select id="checksum_type"
                name="checksum_type"
                ng-model="repository.checksum_type"
                ng-options="type.id as type.name for type in checksums">
        </select>
        <h6 translate>
          For older operating systems such as Red Hat Enterprise Linux 5 or CentOS 5 it is recommended to use sha1.
        </h6>
      </div>

      <div bst-form-group label="{{ 'Publish via HTTP' | translate }}">
        <input id="unprotected"
               name="unprotected"
               ng-model="repository.unprotected"
               type="checkbox"/>
      </div>

      <div bst-form-group label="{{ 'GPG Key' | translate }}" ng-show="repository.content_type === 'yum'">
        <select id="gpg_key_id"
                name="gpg_key_id"
                ng-model="repository.gpg_key_id"
                ng-options="gpg_key.id as gpg_key.name for gpg_key in gpgKeys">
          <option value=""></option>
        </select>
      </div>
    </div>

    <div bst-form-buttons ng-show="repository.content_type !== undefined"
         on-cancel="transitionTo('product.repositories', {productId: repository.product_id})"
         on-save="save(repository)"
         working="working">
    </div>
  </form>
</div>