{#
#
# 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 "airflow/dag.html" %}

{% block content %}
  {{ super() }}
  <h4>
<form method="get" id="daform" action="#">
    <input type="hidden" name="dag_id" value="{{ dag.dag_id }}" >

    <div class="form-inline">
            <span style='color:#AAA;'>Task Instance: </span>
            <span>
              {{ task_id }}
              <input type="hidden" value="{{ task_id }}" name="task_id">
            </span>
        {{ form.execution_date(class_="form-control") | safe }}

    </div>
</form>
  </h4>
  <ul class="nav nav-pills">
    <li><a href="{{ url_for("Airflow.task", dag_id=dag.dag_id, task_id=task_id, execution_date=execution_date) }}">
        <span class="glyphicon glyphicon-certificate" aria-hidden="true"></span>
      Task Instance Details</a></li>
    <li><a href="{{ url_for("Airflow.rendered", dag_id=dag.dag_id, task_id=task_id, execution_date=execution_date) }}">
        <span class="glyphicon glyphicon-certificate" aria-hidden="true"></span>
      Rendered Template</a></li>
    <li><a href="{{ url_for("Airflow.log", dag_id=dag.dag_id, task_id=task_id, execution_date=execution_date) }}">
        <span class="glyphicon glyphicon-certificate" aria-hidden="true"></span>
      Log</a></li>
    <li><a href="{{ url_for("Airflow.xcom", dag_id=dag.dag_id, task_id=task_id, execution_date=execution_date) }}">
        <span class="glyphicon glyphicon-certificate" aria-hidden="true"></span>
      XCom</a></li>
  </ul>
  <hr>
{% endblock %}
{% block tail %}
  {{ super() }}
  <script>
    $( document ).ready(function() {
      function date_change(e) {
          // We don't want to navigate away if the datetimepicker is still visible
          if ($(".datetimepicker bootstrap-datetimepicker-widget :visible").length > 0)
            return

          $("input#execution_date").parents("form").submit();
      }
      $("input#execution_date").parents(".datetimepicker").on("dp.change", date_change);
      $("input#execution_date").parents(".datetimepicker").on("dp.hide", date_change);
    });
  </script>
{% endblock %}
