<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

{% extends 'admin/base.html' %}
{% block head_css %}
  {{ super() }}
  <link href="{{ url_for('static', filename='bootstrap-theme.css') }}" rel="stylesheet">
  <link rel="icon" type="image/png" href="{{ url_for("static", filename="pin_30.png") }}">
  <link rel="stylesheet" type="text/css" href="{{ url_for("static", filename="main.css") }}">
{% endblock %}

{% block tail_js %}
{{ super() }}
<script src="{{ url_for('static', filename='jqClock.min.js') }}" type="text/javascript"></script>
<script>
    x = new Date()
    var UTCseconds = (x.getTime() + x.getTimezoneOffset()*60*1000);
    $("#clock").clock({
        "dateFormat":"Y-m-d ",
        "timeFormat":"H:i:s %UTC%",
        "timestamp":UTCseconds
    }).click(function(){
        alert('{{ hostname }}');
    });
    $('span').tooltip();

    $.ajaxSetup({
      beforeSend: function(xhr, settings) {
        if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) {
          xhr.setRequestHeader("X-CSRFToken", "{{ csrf_token() }}");
        }
      }
    });
</script>
{% endblock %}

{% block page_body %}
<div class="container">

<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation" style="background-color: {{ navbar_color }};">
    <div class="container">
      <!-- Brand and toggle get grouped for better mobile display -->
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#admin-navbar-collapse">
          <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" rel="home" href="{{ url_for('admin.index') }}" style="cursor: pointer;">
              <img style="float: left; width:35px; margin-top: -7px;"
                   src="{{ url_for("static", filename="pin_100.png") }}"
                   {% if current_user.user is defined %}
                      title="{{ current_user.user.username }}"
                   {% else %}
                      title="{{ current_user.username }}"
                   {% endif %}>
              <span>Airflow</span>
          </a>
      </div>
      <!-- navbar content -->
      <div class="collapse navbar-collapse" id="admin-navbar-collapse">
        {% block main_menu %}
        <ul class="nav navbar-nav">
          {{ layout.menu() }}
        </ul>
        {% endblock %}

        {% block menu_links %}
        <ul class="nav navbar-right">
          {{ layout.menu_links() }}
        </ul>
        {% endblock %}
        <!-- clock and logout -->
        <ul class="nav navbar-nav navbar-right">
            <li><a id="clock"></a></li>
            {% if current_user.is_authenticated %}
              <li class="never_active"><a href="{{ url_for('airflow.logout') }}"><span data-toggle="tooltip" data-placement="left" title="Logout" class="glyphicon glyphicon-log-out"></span></a></li>
            {% endif %}
        </ul>
          <ul class="nav navbar-nav navbar-right">
              <li><a id="clock"></a></li>
          </ul>
      </div>
      </div>
</nav>
  {% block messages %}
  {{ layout.messages() }}
  {% endblock %}

  {# store the jinja2 context for form_rules rendering logic #}
  {% set render_ctx = h.resolve_ctx() %}
  {% block body %}
    {{ content }}
  {% endblock %}

</div>
{% endblock %}

