{% load static %}
<header class="navbar navbar-inverse navbar-static-top" role="navigation">
    <nav class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="/">
                <img alt="Promgen {{ VERSION }}" src="{% static 'images/promgen_logo_color.png' %}">
            </a>
        </div>
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            {% if user.is_authenticated %}
            <ul class="nav navbar-nav">
                <li><a href="{% url 'service-list' %}">Services</a></li>
                <li><a href="{% url 'rules-list' %}">Rules</a></li>
                <li><a href="{% url 'url-list' %}">URLs</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Misc <span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="{% url 'audit-list' %}">Edit History</a></li>
                        <li><a href="{% url 'alert-list' %}">Alert History</a></li>
                        <li role="separator" class="divider"></li>

                        <li><a href="{% url 'site-detail' %}">Shared</a></li>
                        <li><a href="{% url 'farm-list' %}">Farms</a></li>
                        <li><a href="{% url 'host-list' %}">Hosts</a></li>
                        <li><a href="{% url 'datasource-list' %}">Datasource</a></li>
                        <li><a href="{% url 'import' %}">Import Config</a></li>
                        <li role="separator" class="divider"></li>

                        <li><a href="{% url 'api:api-root' %}">API</a></li>
                        <li><a href="{% url 'config-targets' %}">Export Targets</a></li>
                        <li><a href="{% url 'api:all-rules' %}">Export Rules</a></li>
                        <li><a href="{% url 'config-urls' %}">Export URL</a></li>
                    </ul>
                </li>
                {% include 'promgen/help_menu.inc.html' %}
            </ul>
            <form class="navbar-form navbar-left" action="{% url 'search' %}">
                <div class="form-group">
                    <input name="search" type="text" class="form-control" placeholder="Service, Project, etc">
                </div>
                <button type="submit" class="btn btn-default">Search</button>
            </form>
            <a @click="toggleComponent('global-alerts')" class="btn btn-danger navbar-btn" role="button">
                Alerts
                <span v-text="activeAlerts.length" class="badge"></span>
            </a>
            <a @click="toggleComponent('global-silences')" class="btn btn-warning navbar-btn" role="button">
                Silences
                <span v-text="activeSilences.length" class="badge"></span>
            </a>

            <ul class="nav navbar-nav navbar-right">
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                        {{user.username}} <span class="caret"></span>
                    </a>
                    <ul class="dropdown-menu">
                        <li><a href="{% url 'profile' %}">Profile</a></li>
                        <li><a href="{% url 'logout' %}">Logout</a></li>
                        {% if user.is_superuser %}
                        <li role="separator" class="divider"></li>
                        <li><a href="{% url 'admin:index' %}">Admin</a></li>
                        {% endif %}
                    </ul>
                </li>
            </ul>
            {% else %}
            <ul class="nav navbar-nav">
                <li><a href="{% url 'login' %}">Login</a></li>
                {% include 'promgen/help_menu.inc.html' %}
            </ul>
            {% endif %}
        </div><!-- /.navbar-collapse -->
    </nav><!-- /.container-fluid -->
</header>
