<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one
  ~ or more contributor license agreements.  See the NOTICE file
  ~ distributed with this work for additional information
  ~ regarding copyright ownership.  The ASF licenses this file
  ~ to you 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.
  -->

<nz-modal [(nzVisible)]="isVisible" nzTitle="{{ 'Create Environment' | translate }}" [nzWidth]="700" (nzOnCancel)="closeModal()">
  <form nz-form [formGroup]="environmentForm" nzLayout="horizontal">
    <div *nzModalFooter>
      <button id="btn-cancel" nz-button nzType="default" (click)="closeModal()">{{ 'Cancel' | translate }}</button>
      <button id="btn-submit" nz-button nzType="primary" [disabled]="checkStatus()" (click)="createEnvironment()">
        {{ 'Create' | translate }}
      </button>
    </div>
    <h2>{{ 'Meta' | translate }}</h2>
    <nz-form-item>
      <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="environmentName">{{ 'Environment Name' | translate }}</nz-form-label>
      <div nz-col nzSpan="16">
        <nz-form-control nzErrorTip="{{ 'Please input environment name!' | translate }}">
          <input
            required
            nz-input
            style="width: 80%"
            type="text"
            name="environmentName"
            id="environmentName"
            formControlName="environmentName"
          />
        </nz-form-control>
      </div>
    </nz-form-item>
    <nz-form-item>
      <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="dockerImage">{{ 'Docker Image' | translate }}</nz-form-label>
      <div nz-col nzSpan="16">
        <nz-form-control nzErrorTip="{{ 'Please input docker image!' | translate }}">
          <input
            required
            nz-input
            style="width: 80%"
            type="text"
            name="dockerImage"
            id="dockerImage"
            formControlName="dockerImage"
          />
        </nz-form-control>
      </div>
    </nz-form-item>
    <nz-form-item style="margin-bottom: 0">
      <nz-upload id="upload-config" nzType="drag" [nzMultiple]="false" [nzBeforeUpload]="beforeUpload">
        <p class="ant-upload-drag-icon">
          <i nz-icon nzType="inbox"></i>
        </p>
        <p class="ant-upload-text">{{ 'Click or drag a conda config YAML file here' | translate }}</p>
        <div style="text-align: left; margin: 1rem">
          <div
            #preview
            style="overflow-y: auto"
            [style.height]="previewCondaConfig !== '' ? '8rem' : '0rem'"
            [innerText]="previewCondaConfig"
          ></div>
        </div>
      </nz-upload>
    </nz-form-item>
  </form>
</nz-modal>
