{% extends 'components/base_nhncloud.html' %}
{% load static %}
{% block main_area %}
<section class="pt-3">
    <h3>nginx ingress만 생성가능</h3>
    <div class="row">
        <div class="mt-5 col-12 text-center">Create LoadBalancer for ingress
            <br>
            <samp>충돌 여부 확인 후 문제 없을시 기본값 사용 가능.</samp>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-4"></div>
        <div class="col-lg-4">
            <form method="post" action="{% url 'nhncloud:kubectlApplyLB' %}">{% csrf_token %}
                <div class="mb-3 mt-5">
                    <div class="row">
                        <div class="col-md-4">
                            <label for="clusterName">Cluster Name</label>
                        </div>
                        <div class="col-md-8">
                            <input type="text" class="form-control" name="clusterName" id="clusterName"
                                value="demo-cluster">
                        </div>
                    </div>
                </div>
                <div class="mb-3">
                    <div class="row">
                        <div class="col-md-4">
                            <label for="loadBancerName">LoadBalancer Name</label>
                        </div>
                        <div class="col-md-8">
                            <input type="text" class="form-control" name="loadBancerName" id="loadBancerName"
                                value="demo-lb-ingress">
                        </div>
                    </div>
                </div>
                <div class="mb-3">
                    <div class="row">
                        <div class="col-md-4">
                            <label for="floatingIP">Floating IP</label>
                        </div>
                        <div class="col-md-8">
                            <input type="text" class="form-control" name="floatingIP" id="floatingIP">
                        </div>
                    </div>
                </div>
                <div class="mb-3">
                    <div class="row">
                        <div class="col-md-4 form-group">
                            <label for="region">Region</label>
                        </div>
                        <div class="col-md-8">
                            <select class="form-control" name="region" id="region" onchange="selectRegion(this.value);">
                                <option value="select...">select...</option>
                                <option value="kr1">판교</option>
                                <option value="kr2">평촌</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="mb-3">
                    <div class="row">
                        <div class="col-md-4">
                            <label for="tenantId">Tenant ID</label>
                        </div>
                        <div class="col-md-8">
                            <input type="password" class="form-control" name="tenantId" id="tenantId">
                        </div>
                    </div>
                </div>
                <div class="mb-3">
                    <div class="row">
                        <div class="col-md-4">
                            <label for="usrEmail">User Email</label>
                        </div>
                        <div class="col-md-8">
                            <input type="text" class="form-control" name="usrEmail" id="usrEmail"
                                value="{{ user.nhnc_id }}">
                        </div>
                    </div>
                </div>
                <div class="mb-3">
                    <div class="row">
                        <div class="col-md-4">
                            <label for="apiPw">API Password</label>
                        </div>
                        <div class="col-md-8">
                            <input type="password" class="form-control" name="apiPw" id="apiPw">
                        </div>
                    </div>
                </div>
                <button type="submit" class="btn btn-info float-right">Request</button>
            </form>
        </div>
        <div class="col-lg-4"></div>
    </div>
</section>
<script>
    function selectRegion() {
        let selectRegionValue = document.getElementById('region').value;
        console.log(selectRegionValue);
        document.getElementById('tenantId').value = "{{ user.nhnc_api_tenant_id }}";
    }
</script>
<script>
    function createClickMsg() {
        alert('Cluster 상태가 조회됩니다.');
    }
</script>
{% endblock %}