<!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">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->

    {% if title %}
    <title>{{ title }}</title>
    {% else %}
    <title>{{ instance_name }} Web Interface</title>
    {% endif %}

    <!-- Latest compiled and minified Bootstrap CSS, optional theme -->
    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap-theme.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.min.css" rel="stylesheet">

    <!-- Prism syntax highlighting stylesheet -->
    <link href="https://cdn.jsdelivr.net/npm/prismjs@1.17.1/themes/prism.min.css" rel="stylesheet" />
    <link href="https://cdn.jsdelivr.net/npm/prismjs@1.17.1/plugins/line-numbers/prism-line-numbers.min.css" rel="stylesheet" />

    <!-- CSS overrides should go last -->
    <link rel=stylesheet type=text/css href="{{ url_for('static', filename='style.css') }}">
    <link rel=stylesheet type=text/css href="{{ url_for('static', filename='code.css') }}">

    <!-- Favicons -->

    <link rel="apple-touch-icon" sizes="180x180" href="{{ url_for('static', filename='apple-touch-icon.png') }}">
    <link rel="icon" type="image/png" sizes="32x32" href="{{ url_for('static', filename='favicon-32x32.png') }}">
    <link rel="icon" type="image/png" sizes="16x16" href="{{ url_for('static', filename='favicon-16x16.png') }}">
    <link rel="manifest" href="{{ url_for('static', filename='site.webmanifest') }}">
    <link rel="mask-icon" href="{{ url_for('static', filename='safari-pinned-tab.svg') }}" color="#24b175">
    <meta name="msapplication-TileColor" content="#24b175">
    <meta name="theme-color" content="#ffffff">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

    <!-- Add axios library for AJAX requests from javascript -->
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
    <!-- fixed navbar -->
    <nav class="navbar navbar-expand-md navbar-dark fixed-top">
        <div class="container">
            <a class="navbar-brand" href="{{ url_for('web.index') }}">
                <img src="{{ url_for('static', filename='img/logo_trans.svg') }}" alt="" class="d-inline-block align-top mr-2" height="30" />
                <strong>{{ instance_name }}</strong>
            </a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle Navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="navbar-collapse collapse" id="navbarCollapse">
                <ul class="navbar-nav mr-auto">
                    {% for endpoint, caption in [
                            ('web.index', 'Home'),
                            ('web.web_subjects', 'Subjects'),
                            ('web.web_experiments', 'Experiments'),
                            ('web.web_workflows', 'Workflows'),
                            ('web.web_states', 'States'),
                            ('web.web_transitions', 'Transitions'),
                            ('web.users', 'Users'),
                    ] %}
                        <li class="nav-item {{ 'active' if endpoint == request.endpoint }}">
                            <a class="nav-link" href="{{ url_for(endpoint) }}">{{ caption }}</a>
                      </li>
                    {% endfor %}
                </ul>
                <ul class="navbar-nav navbar-right">
                    {% if current_user.is_anonymous %}
                    <li class="nav-item {{'active' if 'login' == request.endpoint }}">
                      <a class="nav-link" href="{{ url_for('security.login') }}">Login</a>
                    </li>
                    {% else %}
                      <li class="nav-item dropdown">
                          <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">{{ current_user.name }}</a>
                          <div class="dropdown-menu">
                              <a class="dropdown-item" href="{{ url_for('web.users') }}/{{ current_user.id }}">Profile</a>
                              <div class="dropdown-divider"></div>
                              <a class="dropdown-item" href="{{ url_for('security.logout') }}">Log out</a>
                          </div>
                      </li>
                    {% endif %}
                  </ul>
            </div> <!-- /.nav-collapse -->
        </div> <!-- /.container -->
    </nav>

    <main role="main" class="container">
    {% with messages = get_flashed_messages(with_categories=True) %}
      {% if messages %}
        {% for category, message in messages %}
          <!-- available categories: succes, info, warning, danger -->
          <div class="alert alert-{{category}}" role="alert">{{message}}</div>
        {% endfor %}
      {% endif %}
    {% endwith %}

    {% block content %}{% endblock %}
    </main> <!-- /.container page -->

    <!-- jquery and bootstrap js at the end for faster page loading. -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

    <script src="{{ url_for('static', filename='js/misc_jquery.js') }} "></script>

    <!-- Prism syntax highlighting -->
    <script src="https://cdn.jsdelivr.net/npm/prismjs@1.17.1/components/prism-core.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/prismjs@1.17.1/plugins/autoloader/prism-autoloader.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/prismjs@1.17.1/plugins/line-numbers/prism-line-numbers.min.js"></script>
</body>
</html>
