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

<head>
    <meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="description" content="">
    <meta name="author" content="">

    <link rel="shortcut icon" href="#" />
    <title>RestAPI - Infosys (InfoWS v3)</title>

    <!-- Bootstrap core CSS -->
    <link href="/static/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="/static/css/bootstrap-theme.min.css" rel="stylesheet" type="text/css">

    <!-- Bootstrap core JavaScript -->
    <script src="/static/js/jquery-3.5.1.slim.min.js"></script>
    <script src="/static/js/popper.min.js"></script>
    <script src="/static/js/bootstrap.bundle.min.js"></script>
</head>

<body>
    {% include 'header/header.html' %}

    <div class="row" style="padding-top: 65px;margin: auto;">
        <form class="form-inline ml-2 mr-2">
            <div class="input-group-prepend">
                <div class="input-group-text">Date:</div>
            </div>
            <input type="date" name="date" class="form-control mb-2 mr-sm-2 mb-sm-0" id="date" value="{{date}}" date-format="yyyy-mm-dd">

            <div class="form-check form-check-inline">
                {% if only_errors %}
                <input class="form-check-input" name="only_errors" type="checkbox" id="inlineCheckbox1" value=true onclick="checkCheck()" checked>
                {% else %}
                <input class="form-check-input" name="only_errors" type="checkbox" id="inlineCheckbox1" value=false onclick="checkCheck()">
                {% endif %}
                <label class="form-check-label" for="inlineCheckbox1">Show only errors</label>
            </div>
            <button name="action" type="submit" class="btn btn-primary ml-2 mr-2" value="load">Load</button>
            <button name="action" type="submit" class="btn btn-info ml-2 mr-2" value="download">Download</button>
        </form>
    </div>
    <div class="dropdown-divider m-1"></div>
    <div class="container m-1">
        <div class="table-responsive-sm">
            <table class="table table-hover table-sm">
                <thead>
                    <tr>
                        <th scope="col">Date</th>
                        <th scope="col">Time</th>
                        <th scope="col">RemoteIP</th>
                        <th scope="col">RemotePort</th>
                        <th scope="col">AppOption</th>
                        <th scope="col">ErrorState</th>
                        <th scope="col">RErrorState</th>
                        <th scope="col">SessionID</th>
                        <th scope="col">ReqID</th>
                        <th scope="col">Disk</th>
                        <th scope="col">PoslGod</th>
                        <th scope="col">Job</th>
                        <th scope="col">Pozicija</th>
                        <th scope="col">SifFirme</th>
                        <th scope="col">Referent</th>
                        <th scope="col">ClientID</th>
                        <th scope="col">ClientVer</th>
                        <th scope="col">ApiVer</th>
                        <th scope="col">ErrStatCM</th>
                        <th scope="col">ErrRStatCM</th>
                        <th scope="col">ExecTime</th>
                        <th scope="col">ReqClVer</th>
                    </tr>
                </thead>
                <tbody>
                    {% for row in log %}
                    <tr>
                        {% if row[-1] != 1 %}
                        <td class="table-warning">{{row[0][0]}}</td>
                        <td class="table-warning">{{row[0][1]}}</td>
                        <td class="table-warning">{{row[1]}}</td>
                        <td class="table-warning">{{row[2]}}</td>
                        <td class="table-warning">{{row[3]}}</td>
                        {% if row[-1] == -6 %}
                        <td class="table-danger">{{row[4]}}</td>
                        {% else %}
                        <td class="table-warning">{{row[4]}}</td>
                        {% endif %}
                        {% if row[-1] == -4 %}
                        <td class="table-danger">{{row[5]}}</td>
                        {% else %}
                        <td class="table-warning">{{row[5]}}</td>
                        {% endif %}
                        <td class="table-warning">{{row[6]}}</td>
                        {% if row[-1] == -2 %}
                        <td class="table-danger">{{row[7]}}</td>
                        {% else %}
                        <td class="table-warning">{{row[7]}}</td>
                        {% endif %}
                        <td class="table-warning">{{row[8]}}</td>
                        <td class="table-warning">{{row[9]}}</td>
                        <td class="table-warning">{{row[10]}}</td>
                        <td class="table-warning">{{row[11]}}</td>
                        <td class="table-warning">{{row[12]}}</td>
                        <td class="table-warning">{{row[13]}}</td>
                        {% if row[-1] == -3 %}
                        <td class="table-danger">{{row[14]}}</td>
                        {% else %}
                        <td class="table-warning">{{row[14]}}</td>
                        {% endif %}
                        <td class="table-warning">{{row[15]}}</td>
                        <td class="table-warning">{{row[16]}}</td>
                        <td class="table-warning">{{row[17]}}</td>
                        {% if row[-1] == -5 %}
                        <td class="table-danger">{{row[18]}}</td>
                        {% else %}
                        <td class="table-warning">{{row[18]}}</td>
                        {% endif %}
                        <td class="table-warning">{{row[19]}}</td>
                        {% if row[-1] == -1 %}
                        <td class="table-danger">{{row[20]}}</td>
                        {% else %}
                        <td class="table-warning">{{row[20]}}</td>
                        {% endif %}
                        {% else %}
                        <td>{{row[0][0]}}</td>
                        <td>{{row[0][1]}}</td>
                        <td>{{row[1]}}</td>
                        <td>{{row[2]}}</td>
                        <td>{{row[3]}}</td>
                        <td>{{row[4]}}</td>
                        <td>{{row[5]}}</td>
                        <td>{{row[6]}}</td>
                        <td>{{row[7]}}</td>
                        <td>{{row[8]}}</td>
                        <td>{{row[9]}}</td>
                        <td>{{row[10]}}</td>
                        <td>{{row[11]}}</td>
                        <td>{{row[12]}}</td>
                        <td>{{row[13]}}</td>
                        <td>{{row[14]}}</td>
                        <td>{{row[15]}}</td>
                        <td>{{row[16]}}</td>
                        <td>{{row[17]}}</td>
                        <td>{{row[18]}}</td>
                        <td>{{row[19]}}</td>
                        <td>{{row[20]}}</td>
                        {% endif %}
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>

    <script>
        function checkCheck() {
            var checkBox = document.getElementById("inlineCheckbox1");
            if (checkBox.checked == true){
                checkBox.value = true;
            } else {
                checkBox.value = false;
            }
        }
    </script>
</body>

</html>