<!DOCTYPE html>
{% load static %}
<html lang="ko">

<head>
    <title>Create Cluster | sdjo web site</title>
    <link rel="stylesheet" href="{% static 'blog/bootstrap/bootstrap.min.css' %}" type="text/css">
    <script src="https://kit.fontawesome.com/77d81e5d17.js" crossorigin="anonymous"></script>
</head>

<body class="pb-5">
    {% include 'common/navbar.html' %}
    <section>
        <div class="mt-3 row">
            <div class="mt-5 col-12 text-center">Create NKS Public-Subnet
                <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:createCluster' %}">{% csrf_token %}
                    <div class="mb-3 mt-5">
                        <div class="row">
                            <div class="col-md-4">
                                <label for="taskName">Task Name</label>
                            </div>
                            <div class="col-md-8">
                                <input type="text" class="form-control" name="taskName" id="taskName" value="demo">
                            </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 form-group">
                                <label for="keyPair">KeyPair Name</label>
                            </div>
                            <div class="col-md-8">
                                <select class="form-control" name="KeyPair" id="KeyPair" value="selectKeyPair">
                                    <option value="select...">select...</option>
                                    <option value="keyPair-kr1">keyPair-kr1</option>
                                    <option value="keyPair-kr2">keyPair-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.nhn_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>
                    <div class="mb-3">
                        <div class="row">
                            <div class="col-md-4">
                                <label for="vpcCidr">Vpc cidr</label>
                            </div>
                            <div class="col-md-8">
                                <input type="text" class="form-control" name="vpcCidr" id="vpcCidr" value="10.5.0.0/16">
                            </div>
                        </div>
                    </div>
                    <div class="mb-3">
                        <div class="row">
                            <div class="col-md-4">
                                <label for="subnetCidr">Subnet cidr</label>
                            </div>
                            <div class="col-md-8">
                                <input type="text" class="form-control" name="subnetCidr" id="subnetCidr" value="10.5.2.0/24">
                            </div>
                        </div>
                    </div>
                    <div class="mb-3">
                        <div class="row">
                            <div class="col-md-4">
                                <label for="igwId">InternetGateway ID</label>
                            </div>
                            <div class="col-md-8">
                                <input type="text" class="form-control" name="igwId" id="igwId">
                            </div>
                        </div>
                    </div>
                    <button type="submit" class="btn btn-primary float-right" onclick="createClickMsg();">Create</button>
                </form>
            </div>
            <div class="col-lg-4"></div>
        </div>
    </section>
    
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js"
        integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
        crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"
        integrity="sha384-Fy6S3B9q64WdZWQUiU+q4/2Lc9npb8tCaSX9FK7E8HnRr0Jz8D6OP9dO5Vg3Q9ct"
        crossorigin="anonymous"></script>
    <script>
        function selectRegion(){
            let selectRegionValue = document.getElementById('region').value;
            console.log(selectRegionValue);
            document.getElementById('tenantId').value = "{{ user.nhn_cpt_tntid }}";
            if (selectRegionValue == "kr1") {
                document.getElementById('KeyPair').value = "keyPair-kr1";
            }
            else if (selectRegionValue == "kr2") {
                document.getElementById('KeyPair').value = "keyPair-kr2";
            }
            else {
                document.getElementById('KeyPair').value = "none";
            }
        }
    </script>
    <script>
        function createClickMsg(){
            alert('약 15분 이내로 Cluster가 생성됩니다.\n페이지 새로고침을 하지 말아주세요.\n생성이 완료되면 페이지가 변경됩니다.');
        }
    </script>
</body>
</html>