<!DOCTYPE html>
<html lang="en">

<head>
    <title>Redeye login Page</title>
    <link rel="icon" href="{{ url_for('static', filename='pics/redeye.ico') }}" type="image/x-icon" />
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!--===============================================================================================-->
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='bootstrap-4.4.1-dist/css/bootstrap.min.css') }}">
    <!--===============================================================================================-->
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/login.css') }}">
    <!--===============================================================================================-->
    <link rel="stylesheet" href="{{ url_for('static', filename='bootstrap-4.4.1-dist/css/all.css') }}">
</head>

<body>
    <div class="login">
        <form class="login-form" action="login" method="POST">
            <span class="login-form-title">
                Redeye Login
            </span><br><br>

            <input class="login-input" type="text" name="username" placeholder="Username"><br>
            <input class="login-input" type="password" name="password" placeholder="Password">
            <div style="top:-30px">
                <select class="login-input" name="project">
                    {% for project in projects %}
                    <option value="{{ project[1] }}">{{ project[2] }}</option>
                    {% endfor %}
                </select>
            </div>

            <button class="login-form-btn">
                Login
            </button>

        </form>
    </div>
        {% if show_create_project %}
        <a href="javascript:newProject()" class="new-project-btn"><i class="fas fa-plus"></i></a>
        <form id="new-project-form" action="{{ url_for('new_project') }}" method="POST" style="display:none">
            <input type="text" value="" name="name" id="project-name">
            <input type="text" value="" name="dbname" id="project-dbname">
            <input type="text" value="" name="username" id="project-user">
            <input type="text" value="" name="password" id="project-password">
        </form>
        {% endif %}
    </div>

    {% if show_create_project %}
    <script>
        function newProject() {
            if (window.confirm("Would you like to create a new project?")) {
                var name = prompt("Enter project/network name: ");
                var dbname = prompt("Enter db name (name.db): ");
                var adminUser = prompt("Enter Admin username: ");
                var adminPassword = prompt("Enter Admin password: ");
                if (window.confirm("Would you like to create a new project - " + name + " with the db - " + dbname)) {
                    document.getElementById("project-name").value = name;
                    document.getElementById("project-dbname").value = dbname;
                    document.getElementById("project-user").value = adminUser;
                    document.getElementById("project-password").value = adminPassword;
                    document.getElementById("new-project-form").submit();
                }
            }
        }
    </script>
    {% endif %} {% if msg %}
    <script>
        alert("{{ msg }}")
    </script>
    {% endif %}

</body>

</html>