{% load i18n static utils %}
  <!-- menu -->
  <nav class="navbar navbar-default navbar-fixed-top">
    <div class="container">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
          <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="{{ lava.branding_url }}"><p><img height={{ lava.branding_height }}
                width={{ lava.branding_width }} src="{% static lava.branding_icon %}" alt="{{ lava.branding_alt }}" /> LAVA</p></a>
      </div>
      <div id="navbar" class="navbar-collapse collapse">
        <ul class="nav navbar-nav">
          <li><a href="{% url 'lava.home' %}"><span class="glyphicon glyphicon-home"></span> Home</a></li>
          <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-signal"></span> Results <b class="caret"></b></a>
            <ul class="dropdown-menu">
              <li><a href="{% url 'lava_results' %}">Results</a></li>
              <li><a href="{% url 'lava.results.query_list' %}">Queries</a></li>
              <li><a href="{% url 'lava.results.chart_list' %}">Charts</a></li>
            </ul>
          </li>
          <li class="dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-calendar"></span> Scheduler <b class="caret"></b></a>
            <ul class="dropdown-menu">
              <li><a href="{% url 'lava.scheduler' %}">Status</a></li>
              <li><a href="{% url 'lava.scheduler.reports' %}">Reports</a></li>
              <li role="separator" class="divider"></li>
              <li><a href="{% url 'lava.scheduler.device_types' %}">Device Types</a></li>
              <li><a href="{% url 'lava.scheduler.active_devices' %}">Devices</a></li>
              <li><a href="{% url 'lava.scheduler.job.list' %}">Jobs</a></li>
              <li><a href="{% url 'lava.scheduler.workers' %}">Workers</a></li>
              {% if user.is_authenticated %}
              <li role="separator" class="divider"></li>
              <li><a href="{% url 'lava.scheduler.job.submit' %}">Submit</a></li>
              {% endif %}
            </ul>
          </li>
          <li class="dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-flash"></span> API <b class="caret"></b></a>
            <ul class="dropdown-menu">
              <li><a href="{% url 'lava.api_help' %}">Available Methods</a></li>
              <li><a href="{% url 'linaro_django_xmlrpc_tokens' %}">Authentication Tokens</a></li>
              <li><a href="{% url 'api-root' 'v0.2'%}">REST (v0.2)</a></li>
            </ul>
          </li>
          {% assign_setting 'CUSTOM_DOCS' as userdocs %}
              {% if userdocs %}
                  <li class="dropdown">
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-question-sign"></span> Help <b class="caret"></b></a>
                  <ul class="dropdown-menu">
                      <li><a href="{{ STATIC_URL }}docs/v2/index.html">Help</a></li>
                  {% for label, url in userdocs.items %}
                      {% if label and url %}
                         <li role="separator" class="divider"></li>
                         <li><a href="{{ url }}">{{ label }}</a></li>
                      {% endif %}
                  {% endfor %}
                  </ul>
                  </li>
              {% else %}
                  <li><a href="{{ STATIC_URL }}docs/v2/index.html"><span class="glyphicon glyphicon-question-sign"></span> Help</a></li>
              {% endif %}
        </ul>
        <ul class="nav navbar-nav navbar-right">
          {% if lava.instance_name %}
          <li class="visible-lg"><p class="navbar-text">Instance: {{ lava.instance_name }}</p></li>
          {% endif %}
          {% if user.is_authenticated %}
          <li class="dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-user"></span> {{ user.get_full_name|default:user.username }} <b class="caret"></b></a>
            <ul class="dropdown-menu">
              <li><a href="{% url 'lava.me' %}"><span class="glyphicon glyphicon-cog"></span> Profile</a></li>
              <li><a href="{% url 'lava.scheduler.myjobs' %}"><span class="glyphicon glyphicon-tasks"></span> Jobs</a></li>
              <li><a href="{% url 'lava.scheduler.favorite_jobs' %}"><span class="glyphicon glyphicon-tasks"></span> Favorite Jobs</a></li>
              <li><a href="{% url 'lava.scheduler.mydevice_list' %}"><span class="glyphicon glyphicon-phone"></span> Devices</a></li>
              <li><a href="{% url 'lava.scheduler.mydevices_health_history_log' %}"><span class="glyphicon glyphicon-time"></span> Devices Health History</a></li>
              {% if user.is_staff %}
              <li class="divider"></li>
              <li><a href="{% url 'admin:index' %}"><span class="glyphicon glyphicon-fire"></span> Administration</a></li>
              {% endif %}
              <li class="divider"></li>
              <li><a href="{% url 'logout' %}?next={% url 'lava.home' %}"><span class="glyphicon glyphicon-off"></span> Sign out</a></li>
            </ul>
          </li>
          {% else %}
          <li><p class="navbar-text">
          {% if request.get_full_path == "/accounts/logout/" %}
            <a href="{% url 'login' %}">{% trans "Sign In" %}</a>
           {% else %}
            <a href="{% url 'login' %}?next={{request.get_full_path}}">{% trans "Sign In" %}</a>
           {% endif %}
          </p></li>
          {% endif %}
        </ul>
      </div>
    </div>
  </nav>
