Skip to content

Commit

Permalink
Fix oversized width of DAGs table with hide/reveal of "links" (apache…
Browse files Browse the repository at this point in the history
…#11866)

* Conserve horizontal space by adding hide/reveal "links" in DAGs table

* Reverse the order of links to reduce mouse distance for most popular
  • Loading branch information
ryanahamilton authored Oct 29, 2020
1 parent 164a707 commit b4b90da
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 73 deletions.
121 changes: 121 additions & 0 deletions airflow/www/static/css/dags.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*!
* 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.
*/

.dags-table-wrap {
border-radius: 4px 4px 0 0;
background-color: #f0f0f0;
}

.dags-table-header {
margin: 0;
padding: 16px 0;
}

.dags-table-more {
position: relative;
}

.dags-table-more__toggle,
.dags-table-more__toggle:hover,
.dags-table-more__toggle:focus {
display: block;
padding: 8px 16px;
cursor: default;
border-color: transparent;
background: transparent;
}

.dags-table-more__menu {
position: absolute;
top: 0;
right: 0;
bottom: 0;
padding-right: 4px;
white-space: nowrap;
display: flex;
align-items: center;
overflow: hidden;
}

.dags-table-more__menu:hover {
overflow: visible;
}

.dags-table-more__menu::before {
width: 0;
height: 100%;
content: '';
pointer-events: none;
transition: width 0.3s ease-in;
}

.dags-table-more__menu:hover::before {
margin-left: -200px;
width: 200px;
background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, #fff 100%);
}

tr:nth-child(odd) .dags-table-more__menu:hover {
background-color: #fff;
}

tr:nth-child(2n) .dags-table-more__menu:hover {
background-color: #f9f9f9;
}

tr:nth-child(2n) .dags-table-more__menu:hover::before {
background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, #f9f9f9 100%);
}

tr:nth-child(odd):hover .dags-table-more__menu:hover,
tr:nth-child(2n):hover .dags-table-more__menu:hover {
background-color: #f5f5f5;
}

tr:nth-child(odd):hover .dags-table-more__menu:hover::before,
tr:nth-child(2n):hover .dags-table-more__menu:hover::before {
background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, #f5f5f5 100%);
}

.dags-table-more__links {
margin-right: 16px;
width: 0;
overflow: hidden;
}

.dags-table-more__menu:hover .dags-table-more__links {
width: auto;
overflow: visible;
}

.dags-table-more__link {
display: inline-block;
max-width: 0;
overflow: hidden;
margin-right: 16px;
transition: max-width 0.3s ease-in;
}

.dags-table-more__link:last-child {
margin-right: 0;
}

.dags-table-more__menu:hover .dags-table-more__link {
max-width: 200px;
}
10 changes: 0 additions & 10 deletions airflow/www/static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -391,16 +391,6 @@ label[for="timezone-other"],
background-color: #f5f5f5;
}

.dags-table-wrap {
border-radius: 4px 4px 0 0;
background-color: #f0f0f0;
}

.dags-table-header {
margin: 0;
padding: 16px 0;
}

.dag-view-tools {
margin: 16px 0;
padding: 16px 0;
Expand Down
135 changes: 72 additions & 63 deletions airflow/www/templates/airflow/dags.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
{% block head_css %}
{{ super() }}
<link rel="stylesheet" type="text/css" href="{{ url_for_asset('switch.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url_for_asset('dags.css') }}">
{% endblock %}

{% block content %}
<h2>DAGs</h2>

<div id="main_content">
<div class="dags-table-wrap">
<div class="row dags-table-header">
Expand Down Expand Up @@ -76,22 +76,22 @@ <h2>DAGs</h2>
<thead>
<tr>
<th width="12">
<span id="pause_header" class="material-icons text-muted" title="Use this toggle to pause a DAG. The scheduler won't schedule new tasks instances for a paused DAG. Tasks already running at pause time won't be affected.">info</span>
<span class="material-icons text-muted js-tooltip" title="Use this toggle to pause a DAG. The scheduler won't schedule new tasks instances for a paused DAG. Tasks already running at pause time won't be affected.">info</span>
</th>
<th>DAG</th>
<th>Schedule</th>
<th>Owner</th>
<th>Recent Tasks
<span class="material-icons text-muted js-tooltip" aria-hidden="true" title="Status of tasks from all active DAG runs or, if not currently active, from most recent run.">info</span>
<th>Runs
<span class="material-icons text-muted js-tooltip" aria-hidden="true" title="Status of all previous DAG runs.">info</span>
</th>
<th>Schedule</th>
<th style="width:180px;">Last Run
<span class="material-icons text-muted js-tooltip" aria-hidden="true" title="Execution Date/Time of Highest Dag Run.">info</span>
</th>
<th>DAG Runs
<span class="material-icons text-muted js-tooltip" aria-hidden="true" title="Status of all previous DAG runs.">info</span>
<th>Recent Tasks
<span class="material-icons text-muted js-tooltip" aria-hidden="true" title="Status of tasks from all active DAG runs or, if not currently active, from most recent run.">info</span>
</th>
<th class="text-center" style="width:205px;">Links</th>
<th class="text-center" style="width:140px;">Actions</th>
<th class="text-center" style="width:110px;">Actions</th>
<th style="width:52px;">Links</th>
</tr>
</thead>
<tbody>
Expand All @@ -101,86 +101,53 @@ <h2>DAGs</h2>
{% for dag in dags %}
<tr>
{# Column 1: Turn dag on/off #}
<td>
<td style="padding-right:0;">
<label class="switch-label js-tooltip" title="Pause/Unpause DAG">
<input class="switch-input" id="toggle-{{ dag.dag_id }}" dag_id="{{ dag.dag_id }}" type="checkbox" {{ "checked" if not dag.is_paused else "" }} method="post">
<span class="switch" aria-hidden="true"></span>
</label>
</td>
{# Column 2: Name #}
<td>
<span>
<a href="{{ url_for('Airflow.'+ dag.get_default_view(), dag_id=dag.dag_id) }}"
title="{{ dag.description[0:80] + '…' if dag.description and dag.description|length > 80 else dag.description|default('', true) }}">
<strong>{{ dag.dag_id }}</strong>
</a>
</span>
<div style="float: right; max-width: 70%; text-align: right; line-height: 160%;">
<a href="{{ url_for('Airflow.'+ dag.get_default_view(), dag_id=dag.dag_id) }}"
title="{{ dag.description[0:80] + '…' if dag.description and dag.description|length > 80 else dag.description|default('', true) }}">
<strong>{{ dag.dag_id }}</strong>
</a>
<div>
{% for tag in dag.tags | sort(attribute='name') %}
<a class="label label-success"
<a class="label label-info"
href="?tags={{ tag.name }}"
style="margin: 3px;">
style="margin: 6px 6px 0 0;">
{{ tag.name }}
</a>
{% endfor %}
</div>
</td>
{# Column 3: Dag Schedule #}
{# Column 3: Dag Owners #}
<td>{{ dag.owners }}</td>
{# Column 4: Dag Runs #}
<td style="padding:0; width:120px;">
{{ loading_dots(classes='js-loading-dag-stats text-muted') }}
<svg height="10" width="10" id="dag-run-{{ dag.safe_dag_id }}" style="display: block;"></svg>
</td>
{# Column 5: Dag Schedule #}
<td>
<a class="label label-default schedule" href="{{ url_for('DagRunModelView.list') }}?_flt_3_dag_id={{ dag.dag_id }}">
{{ dag.schedule_interval }}
</a>
</td>
{# Column 4: Dag Owners #}
<td>
{{ dag.owners }}
</td>
{# Column 5: Recent Tasks #}
<td style="padding:0; width:323px; height:10px;">
{{ loading_dots(classes='js-loading-task-stats text-muted') }}
<svg height="10" width="10" id='task-run-{{ dag.safe_dag_id }}' style="display: block;"></svg>
</td>
{# Column 6: Last Run #}
<td id="last-run-{{ dag.safe_dag_id }}" class="text-nowrap latest_dag_run">
{{ loading_dots(classes='js-loading-last-run text-muted') }}
<a></a>
<span aria-hidden="true" title=" " class="material-icons text-muted js-tooltip" style="display:none">info</span>
</td>
{# Column 7: Dag Runs #}
<td style="padding:0; width:120px;">
{{ loading_dots(classes='js-loading-dag-stats text-muted') }}
<svg height="10" width="10" id='dag-run-{{ dag.safe_dag_id }}' style="display: block;"></svg>
</td>
{# Column 8: Links #}
<td class="text-center">
{% if dag %}
<a href="{{ url_for('Airflow.tree', dag_id=dag.dag_id, num_runs=num_runs) }}" class="js-tooltip" title="Tree View" aria-label="Tree View">
<span class="material-icons" aria-hidden="true">nature</span>
</a>
<a href="{{ url_for('Airflow.graph', dag_id=dag.dag_id) }}" class="js-tooltip" title="Graph View" aria-label="Graph View">
<span class="material-icons" aria-hidden="true">account_tree</span>
</a>
<a href="{{ url_for('Airflow.duration', dag_id=dag.dag_id) }}" class="js-tooltip" title="Task Duration" aria-label="Task Duration">
<span class="material-icons" aria-hidden="true">hourglass_bottom</span>
</a>
<a href="{{ url_for('Airflow.tries', dag_id=dag.dag_id) }}" class="js-tooltip" title="Task Tries" aria-label="Task Tries">
<span class="material-icons" aria-hidden="true">repeat</span>
</a>
<a href="{{ url_for('Airflow.landing_times', dag_id=dag.dag_id) }}" class="js-tooltip" title="Landing Times" aria-label="Landing Times">
<span class="material-icons" aria-hidden="true">flight_land</span>
</a>
<a href="{{ url_for('Airflow.gantt', dag_id=dag.dag_id) }}" class="js-tooltip" title="Gantt View" aria-label="Gantt">
<span class="material-icons" aria-hidden="true" data-original-title="Gantt">vertical_distribute</span>
</a>
<a href="{{ url_for('Airflow.dag_details', dag_id=dag.dag_id) }}" class="js-tooltip" title="DAG Details" aria-label="DAG Details">
<span class="material-icons" aria-hidden="true">details</span>
</a>
<a href="{{ url_for('Airflow.code', dag_id=dag.dag_id) }}" class="js-tooltip" title="Code View" aria-label="Code">
<span class="material-icons" aria-hidden="true">code</span>
</a>
{% endif %}
{# Column 7: Recent Tasks #}
<td style="padding:0; width:323px; height:10px;">
{{ loading_dots(classes='js-loading-task-stats text-muted') }}
<svg height="10" width="10" id='task-run-{{ dag.safe_dag_id }}' style="display: block;"></svg>
</td>
{# Column 9: Actions #}
{# Column 8: Actions #}
<td class="text-center">
<div class="btn-group">
{% if dag %}
Expand All @@ -197,6 +164,48 @@ <h2>DAGs</h2>
</a>
</div>
</td>
{# Column 9: Links #}
<td class="dags-table-more">
{% if dag %}
<div class="dags-table-more__menu">
<div class="dags-table-more__links">
<a href="{{ url_for('Airflow.code', dag_id=dag.dag_id) }}" class="dags-table-more__link">
<span class="material-icons" aria-hidden="true">code</span>
Code
</a>
<a href="{{ url_for('Airflow.dag_details', dag_id=dag.dag_id) }}" class="dags-table-more__link">
<span class="material-icons" aria-hidden="true">details</span>
Details
</a>
<a href="{{ url_for('Airflow.gantt', dag_id=dag.dag_id) }}" class="dags-table-more__link">
<span class="material-icons" aria-hidden="true">vertical_distribute</span>
Gantt
</a>
<a href="{{ url_for('Airflow.landing_times', dag_id=dag.dag_id) }}" class="dags-table-more__link">
<span class="material-icons" aria-hidden="true">flight_land</span>
Landing
</a>
<a href="{{ url_for('Airflow.tries', dag_id=dag.dag_id) }}" class="dags-table-more__link">
<span class="material-icons" aria-hidden="true">repeat</span>
Tries
</a>
<a href="{{ url_for('Airflow.duration', dag_id=dag.dag_id) }}" class="dags-table-more__link">
<span class="material-icons" aria-hidden="true">hourglass_bottom</span>
Duration
</a>
<a href="{{ url_for('Airflow.graph', dag_id=dag.dag_id) }}" class="dags-table-more__link">
<span class="material-icons" aria-hidden="true">account_tree</span>
Graph
</a>
<a href="{{ url_for('Airflow.tree', dag_id=dag.dag_id, num_runs=num_runs) }}" class="dags-table-more__link">
<span class="material-icons" aria-hidden="true">nature</span>
Tree
</a>
</div>
<span class="dags-table-more__toggle"><span class="material-icons">more_horiz</span></span>
</div>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
Expand Down
1 change: 1 addition & 0 deletions airflow/www/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const config = {
airflowDefaultTheme: `${STATIC_DIR}/css/bootstrap-theme.css`,
base: `${STATIC_DIR}/js/base.js`,
connectionForm: `${STATIC_DIR}/js/connection_form.js`,
dags: `${STATIC_DIR}/css/dags.css`,
flash: `${STATIC_DIR}/css/flash.css`,
gantt: `${STATIC_DIR}/css/gantt.css`,
ganttChartD3v2: `${STATIC_DIR}/js/gantt-chart-d3v2.js`,
Expand Down
Binary file modified docs/img/dags.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b4b90da

Please sign in to comment.