{#
 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 title %}Airflow - DAGs{% endblock %}

{% block head_css %}
{{ super() }}
<link rel="stylesheet" type="text/css"
    href="{{ url_for('static', filename='tree.css') }}">
<link href="{{ admin_static.url(filename='vendor/bootstrap-daterangepicker/daterangepicker-bs2.css') }}" rel="stylesheet">
<link rel="stylesheet" type="text/css"
      href="{{ url_for("static", filename="dataTables.bootstrap.css") }}">
<link rel="stylesheet" type="text/css"
      href="{{ url_for("static", filename="nv.d3.css") }}">
<script src="{{ url_for('static', filename='d3.v3.min.js') }}"></script>
<script src="{{ url_for('static', filename='nv.d3.js') }}"></script>
{% endblock %}

{% block body %}
{{ super() }}
<div>
  <label for="isCumulative">Cumulative Duration</label>
  <input id="isCumulative" type="checkbox" value="1">
</div>
<div style="float: left" class="form-inline">
    <form method="get" style="float:left;">
        Base date: {{ form.base_date(class_="form-control") }}
        Number of runs: {{ form.num_runs(class_="form-control") }}
        <input type="hidden" name="root" value="{{ root if root else '' }}">
        <input type="hidden" value="{{ dag.dag_id }}" name="dag_id">
        <input type="submit" value="Go" class="btn btn-default"
         action="" method="get">
        <input name="_csrf_token" type="hidden" value="{{ csrf_token() }}">
    </form>
</div>
<div id="dur_chart" style="clear: both;">{{ chart }}</div>
<div id="cum_dur_chart" style="clear: both;">{{ cum_chart }}</div>
<hr/>
{% endblock %}

{% block tail %}
  <script>
    function handleCheck() {
      if ($('#isCumulative').is(':checked')) {
        $('#dur_chart').hide();
        $('#cum_dur_chart').show();
      } else {
        $('#dur_chart').show();
        $('#cum_dur_chart').hide();
      };
    };
    $( document ).on('chartload', function() {
      handleCheck();
    });
    $('#isCumulative').click(function() {
      handleCheck();
    });
  </script>
  <script src="{{ admin_static.url(
    filename='vendor/bootstrap-daterangepicker/daterangepicker.js') }}"></script>
  {{ super() }}
{% endblock %}
