diff --git a/airflow/www/static/js/main.js b/airflow/www/static/js/main.js index 95861ea6c13a6..98222bafff5da 100644 --- a/airflow/www/static/js/main.js +++ b/airflow/www/static/js/main.js @@ -287,3 +287,18 @@ $(document).ready(() => { // Global Tooltip selector $(".js-tooltip").tooltip(); }); + +$(".reparse_dag").click((event) => { + console.log(event); + event.preventDefault(); + $.ajax({ + url: event.currentTarget.attributes.href.value, + type: "PUT", + done(response) { + console.log(response); + }, + fail(response) { + console.log(response); + }, + }); +}); diff --git a/airflow/www/templates/airflow/dag.html b/airflow/www/templates/airflow/dag.html index c91d4b4454a44..6a180bc5e591d 100644 --- a/airflow/www/templates/airflow/dag.html +++ b/airflow/www/templates/airflow/dag.html @@ -235,6 +235,12 @@

+ + cached + diff --git a/airflow/www/templates/airflow/dags.html b/airflow/www/templates/airflow/dags.html index 1bb5ac25abf4d..77e96768a9753 100644 --- a/airflow/www/templates/airflow/dags.html +++ b/airflow/www/templates/airflow/dags.html @@ -398,6 +398,10 @@

{{ page_title }}

class="btn btn-sm btn-default btn-icon-only{{ ' disabled' if not dag.can_delete }}"> + + cached + {% endif %} diff --git a/airflow/www/views.py b/airflow/www/views.py index fbc5296f733db..2ce7ee6829dea 100644 --- a/airflow/www/views.py +++ b/airflow/www/views.py @@ -48,6 +48,7 @@ Response, abort, before_render_template, + current_app, flash, g, has_request_context, @@ -67,6 +68,7 @@ from flask_appbuilder.urltools import get_order_args, get_page_args, get_page_size_args from flask_appbuilder.widgets import FormWidget from flask_babel import lazy_gettext +from itsdangerous import URLSafeSerializer from jinja2.utils import htmlsafe_json_dumps, pformat # type: ignore from markupsafe import Markup, escape from pendulum.datetime import DateTime @@ -163,6 +165,7 @@ SENSITIVE_FIELD_PLACEHOLDER = "RATHER_LONG_SENSITIVE_FIELD_PLACEHOLDER" logger = logging.getLogger(__name__) +url_serializer = URLSafeSerializer(current_app.config["SECRET_KEY"]) def sanitize_args(args: dict[str, Any]) -> dict[str, Any]: @@ -937,6 +940,7 @@ def index(self): dag.can_delete = get_auth_manager().is_authorized_dag( method="DELETE", details=DagDetails(id=dag.dag_id), user=g.user ) + dag.file_token = url_serializer.dumps(dag.fileloc) dagtags = session.execute(select(func.distinct(DagTag.name)).order_by(DagTag.name)).all() tags = [ @@ -2846,6 +2850,7 @@ def grid(self, dag_id: str, session: Session = NEW_SESSION): color_log_warning_keywords = conf.get("logging", "color_log_warning_keywords", fallback="") dag = get_airflow_app().dag_bag.get_dag(dag_id, session=session) + dag.file_token = url_serializer.dumps(dag.fileloc) dag_model = DagModel.get_dagmodel(dag_id, session=session) if not dag: flash(f'DAG "{dag_id}" seems to be missing from DagBag.', "error")