<!--
  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.
-->
<div class="row">
    <div class="col-md-12">
        <p class="page-subheading">Enter the details of your new BYON location</p>
        <div class="brooklyn-home-card">
            <div class="title">
                <form novalidate name="form">
                    <div class="form-group" ng-class="{'has-error': form.id.$invalid && form.id.$touched}">
                        <label class="control-label" for="id">Location ID*</label>
                        <input ng-model="vm.id" type="text" class="form-control" id="id" name="id" required placeholder="A label to identify this location in YAML. Typically this is lower case using hyphens and no spaces">
                        <p class="help-block" ng-show="form.$submitted || form.id.$touched">
                            <span ng-show="form.id.$error.required">You must specify a location ID</span>
                        </p>
                    </div>
                    <div class="form-group" ng-class="{'has-error': form.version.$invalid && form.version.$touched}">
                        <label class="control-label" for="id">Location version*</label>
                        <input ng-model="vm.version" type="text" class="form-control" id="version" name="version" required placeholder="A version number to identify this location">
                        <p class="help-block" ng-show="form.$submitted || form.version.$touched">
                            <span ng-show="form.id.$error.required">You must specify a location version</span>
                        </p>
                    </div>

                    <div class="form-group" ng-class="{'has-error': form.name.$invalid && form.name.$touched}">
                        <label class="control-label" for="name">Location name</label>
                        <input ng-model="vm.name" type="text" class="form-control" id="name" name="name" placeholder="A display name to present this location to a user (optional)">
                    </div>

                    <div class="form-group" ng-class="{'has-error': form.user.$invalid && form.user.$touched}">
                        <label class="control-label" for="user">User</label>
                        <input ng-model="vm.user" type="text" class="form-control" id="user" name="user" placeholder="The user to use to connect to the machines">
                    </div>

                    <div class="form-group" ng-class="{'has-error': form.password.$invalid && form.password.$touched}">
                        <label class="control-label" for="password">Password</label>
                        <input ng-model="vm.password" type="password" class="form-control" id="password" name="password" placeholder="The password to use to connect to the machines (if using password access)">
                    </div>

                    <div class="form-group" ng-class="{'has-error': form.privateKeyData.$invalid && form.privateKeyData.$touched}">
                        <label class="control-label" for="privateKeyData">Private key data</label>
                        <textarea ng-model="vm.privateKeyData" class="form-control" id="privateKeyData" name="privateKeyData" rows="5" placeholder="The contents of the private key file to use to connect to the machines (if using key access, where the corresponding public key is in the .authorized_keys file on the servers)"></textarea>
                    </div>

                    <div class="form-group" ng-class="{'has-error': form.privateKeyPassphrase.$invalid && form.privateKeyPassphrase.$touched}">
                        <label class="control-label" for="privateKeyPassphrase">Private key passphrase</label>
                        <input ng-model="vm.privateKeyPassphrase" type="text" class="form-control" id="privateKeyPassphrase" name="privateKeyPassphrase" placeholder="The passphrase to unlock the private key specified above (if applicable)">
                    </div>

                    <div class="form-group" ng-class="{'has-error': form.hosts.$invalid && form.hosts.$touched}">
                        <label class="control-label" for="hosts">Hosts*</label>
                        <textarea ng-model="vm.hosts" class="form-control" id="hosts" name="hosts" rows="5" required placeholder="The IP addresses of the machines to include in this location definition, one per line" required></textarea>
                        <p class="help-block" ng-show="form.$submitted || form.hosts.$touched">
                            <span ng-show="form.hosts.$error.required">You must specify at least one host</span>
                        </p>
                    </div>
                </form>

                <section>
                    <h3>Additional configuration</h3>
                    <dynamic-config model="vm.config" type="configuration"></dynamic-config>
                </section>

                <div class="col-md-12 text-right">
                    <button class="btn btn-primary btn-lg" ng-disabled="form.$invalid" ng-click="vm.save()">Save</button>
                </div>
            </div>
        </div>
    </div>
</div>
