diff --git a/airflow/www/templates/airflow/dags.html b/airflow/www/templates/airflow/dags.html index 416e10e9e1b56..14f8b7ef60f40 100644 --- a/airflow/www/templates/airflow/dags.html +++ b/airflow/www/templates/airflow/dags.html @@ -46,15 +46,16 @@

DAGs

-
-
- {% for tag in tags %} {% endfor %} - - + {% if tags_filter|length > 0 %} + + {% endif %}
@@ -233,6 +234,31 @@

DAGs

allowClear: true }); + $('#tags_filter').on('change', function (e) { + e.preventDefault(); + var query = new URLSearchParams(window.location.search); + if (!!e.val.length) { + if (query.has('tags')) query.delete('tags'); + e.val.map(function(value) { + query.append('tags', value); + }) + } else { + query.delete('tags'); + query.set('reset_tags', 'reset') + } + if (query.has('page')) query.delete('page'); + window.location = `${DAGS_INDEX}?${query.toString()}`; + }); + + $('#tags_form').on('reset', function(e) { + e.preventDefault(); + var query = new URLSearchParams(window.location.search); + query.delete('tags'); + if (query.has('page')) query.delete('page'); + query.set('reset_tags', 'reset') + window.location = `${DAGS_INDEX}?${query.toString()}`; + }); + $('#dag_query').on('keypress', function (e) { // check for key press on ENTER (key code 13) to trigger the search if (e.which === ENTER_KEY_CODE) { diff --git a/airflow/www/views.py b/airflow/www/views.py index 2862af0381610..e223013330419 100644 --- a/airflow/www/views.py +++ b/airflow/www/views.py @@ -417,13 +417,15 @@ def get_int_arg(value, default=0): if request.args.get('reset_tags') is not None: flask_session[FILTER_TAGS_COOKIE] = None - arg_tags_filter = None - else: - cookie_val = flask_session.get(FILTER_TAGS_COOKIE) - if arg_tags_filter: - flask_session[FILTER_TAGS_COOKIE] = ','.join(arg_tags_filter) - elif cookie_val: - arg_tags_filter = cookie_val.split(',') + # Remove the reset_tags=reset from the URL + return redirect(url_for('Airflow.index')) + + cookie_val = flask_session.get(FILTER_TAGS_COOKIE) + if arg_tags_filter: + flask_session[FILTER_TAGS_COOKIE] = ','.join(arg_tags_filter) + elif cookie_val: + # If tags exist in cookie, but not URL, add them to the URL + return redirect(url_for('Airflow.index', tags=cookie_val.split(','))) if arg_status_filter is None: cookie_val = flask_session.get(FILTER_STATUS_COOKIE) @@ -536,7 +538,8 @@ def get_int_arg(value, default=0): status_filter=arg_status_filter, status_count_all=all_dags_count, status_count_active=status_count_active, - status_count_paused=status_count_paused) + status_count_paused=status_count_paused, + tags_filter=arg_tags_filter) @expose('/dag_stats', methods=['POST']) @has_access diff --git a/docs/img/dags.png b/docs/img/dags.png index eb003b5625cb1..360b9906ecf80 100644 Binary files a/docs/img/dags.png and b/docs/img/dags.png differ