<!---
  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. See accompanying LICENSE file.
-->
<div class="container content">
    <div class="row">
      <div class="col-xs-12 col-md-12 col-lg-12">
        <div class="form-group">
          <h1>Register Application</h1>
        </div>
        <div class="form-group">
          <label>Organization Name</label>
          <input type=text name="org" class="form-control" ng-model="details.organization" />
        </div>
        <div class="form-group">
          <label>Application Name</label>
          <input type=text name="name" class="form-control" ng-model="details.name" />
        </div>
        <div class="form-group">
          <label>Version</label>
          <input type=text name="version" class="form-control" ng-model="details.version" />
        </div>
        <div class="form-group">
          <label>Description</label>
          <textarea name="desc" class="form-control" ng-model="details.description"></textarea>
        </div>
        <div class="form-group">
          <label>Quick Link</label>
          <textarea json-text name="quicklink" class="form-control" ng-model="details.quicklinks"/></textarea>
        </div>
        <div class="form-group">
          <label>Icon</label>
          <input type=text name="icon" class="form-control" ng-model="details.icon" />
        </div>
      </div>
    </div>

    <div class="row">
      <div class="col-xs-12 col-md-12 col-lg-12" ng-repeat="docker in details.components track by $index">
        <div class="panel">
          <div class="pull-right">
            <a class="btn btn-secondary" ng-click="remove($index)">-</a>
          </div>
          <div class="form-group">
            <label>Component Name</label>
            <input type=text name="name" class="form-control" ng-model="docker.name" />
          </div>
          <div class="form-group">
            <label>Artifact</label>
            <input type=text name="artifact_id" class="form-control" ng-model="docker.artifact.id" />
          </div>
          <div class="form-group">
            <label>Number of containers</label>
            <input type=text name="artifact_id" class="form-control" ng-model="docker.number_of_containers" />
          </div>
          <div class="form-group">
            <label>Launch Command</label>
            <input type=text name="launch_command" class="form-control" ng-model="docker.launch_command" />
          </div>
          <div class="form-group">
            <label>CPU</label>
            <input type=text name="cpus" class="form-control" ng-model="docker.resource.cpus" />
          </div>
          <div class="form-group">
            <label>Memory</label>
            <input type=text name="memory" class="form-control" ng-model="docker.resource.memory" />
          </div>
          <div class="form-group">
            <input type="checkbox" ng-attr-id="{{'checkbox-priv-' + $index}}" ng-model="docker.run_privileged_container">
            <label for="checkbox-priv-{{$index}}"> Privileged Container</label>
          </div>
          <div class="form-group">
            <label>Dependencies</label>
            <input json-text type=text name="dependencies" class="form-control" ng-model="docker.dependencies" />
          </div>
          <div class="form-group">
            <label>Placement Policy</label>
            <input type=text name="placement" class="form-control" ng-model="docker.placement_policy.constraints" />
          </div>
          <div class="form-group">
            <label>Environments</label>
            <textarea json-text name="env" class="form-control" ng-model="docker.configuration.env"/></textarea>
          </div>
          <div class="form-group">
            <label>Properties</label>
            <textarea json-text name="properties" class="form-control" ng-model="docker.configuration.properties"/></textarea>
          </div>
        </div>
      </div>
    </div>

    <br>
    <div class="row">
      <div class="col-xs-12 col-md-12 col-lg-12">
        <p>
        <a class="btn btn-secondary" ng-click="add()">+</a>
        <a class="btn btn-secondary" ng-click="save()">Publish</a>
        <span class="infobox bg-info" ng-if="message">{{message}}</span>
        <span class="infobox bg-danger" ng-if="error">{{error}}</span>
      </div>
    </div>
</div>
