{#
 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 page_title %}{{ dag.dag_id }} - DAG Details - {{ appbuilder.app_name }}{% endblock %}

{% block content %}
  {{ super() }}
  <h3>{{ title }}</h3>
  <div>
    {% for state, count in states %}
      <a
        class="btn"
        style="border: 0; background-color:{{ State.color(state)}}; color: {{ State.color_fg(state) }};"
        href="{{ url_for('TaskInstanceModelView.list', _flt_3_dag_id=dag.dag_id, _flt_3_state=state) }}">
        {{ state }} <span class="badge">{{ count }}</span>
      </a>
    {% endfor %}
  </div>
  <br>
  <table class="table table-striped table-bordered">
    {% if dag.parent_dag is defined and dag.parent_dag %}
      <tr>
        <th>Parent DAG</th>
        <td>
          <a href="{{ url_for('Airflow.' + dag.default_view, dag_id=dag.parent_dag.dag_id) }}">{{ dag.parent_dag.dag_id }}</a>
        </td>
      </tr>
    {% endif %}
    <tr>
      <th>Schedule Interval</th>
      <td>{{ dag.schedule_interval }}</td>
    </tr>
    <tr>
      <th>Catchup</th>
      <td>{{ dag.catchup }}</td>
    </tr>
    {% if dag.catchup %}
      <tr>
        <th>Start Date</th>
        <td><time datetime="{{ dag.start_date }}">{{ dag.start_date }}</time></td>
      </tr>
    {% else %}
      <tr>
        <th>Started</th>
        <td>{{ states|length > 0 }}</td>
      </tr>
    {% endif %}
    <tr>
      <th>End Date</th>
      <td><time datetime="{{ dag.end_date }}">{{ dag.end_date }}</time></td>
    </tr>
    <tr>
      <th>Max Active Runs</th>
      <td>{{ active_runs | length }} / {{ dag.max_active_runs }}</td>
    </tr>
    <tr>
      <th>Concurrency</th>
      <td>{{ dag.max_active_tasks }}</td>
    </tr>
    <tr>
      <th>Default Args</th>
      <td class="wrap">{{ dag.default_args | pprint }}</td>
    </tr>
    <tr>
      <th>Tasks Count</th>
      <td>{{ dag.tasks|length }}</td>
    </tr>
    <tr>
      <th>Task IDs</th>
      <td>{{ dag.task_ids }}</td>
    </tr>
    <tr>
      <th>Relative file location</th>
      <td>{{ dag.relative_fileloc }}</td>
    </tr>
    <tr>
      <th>Owner</th>
      <td>{{ dag.owner }}</td>
    </tr>
    <tr>
      <th>Owner Links</th>
      <td>
        {% if dag.owner_links %}
          {{ dag.owner_links }}
        {% else %}
          None
        {% endif %}
      </td>
    </tr>
    <tr>
      <th>DAG Run Timeout</th>
      <td>{{ dag.dagrun_timeout }}</td>
    </tr>
    <tr>
      <th>Tags</th>
      <td>
        {% if tags is defined and tags %}
          {% for tag in tags | sort(attribute='name') %}
            <a class="label label-info"
               href="{{ url_for('Airflow.index', tags=tag.name) }}"
               style="margin: 3px 6px 3px 0;"
               title="All DAGs tagged &ldquo;{{ tag.name }}&rdquo;"
            >
              {{ tag.name }}
            </a>
          {% endfor %}
        {% else %}
          None
        {% endif %}
      </td>
    </tr>
  </table>
  <h5>DagModel debug information</h5>
  <table class="table table-striped table-bordered">
    <tr>
      <th>Attribute</th>
      <th>Value</th>
    </tr>
    {% for attr, value in dag_model_attrs %}
    <tr>
      <td>{{ attr }}</td>
      <td class="code wrap">{{ value }}</td>
    </tr>
    {% endfor %}
  </table>
{% endblock %}
