This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch v1-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 6804841948b11fb343733fb098dddebbf2b30e72
Author: Kaxil Naik <[email protected]>
AuthorDate: Mon Jun 29 19:53:38 2020 +0100

    fixup! Avoid color info in response of /dag_stats & /task_stats (#8742)
---
 airflow/www/templates/airflow/dags.html |  5 +++--
 airflow/www/views.py                    | 10 ++++++----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/airflow/www/templates/airflow/dags.html 
b/airflow/www/templates/airflow/dags.html
index ec4e4d0..6d7019d 100644
--- a/airflow/www/templates/airflow/dags.html
+++ b/airflow/www/templates/airflow/dags.html
@@ -217,6 +217,7 @@
 
       const DAGS_INDEX = "{{ url_for('admin.index') }}";
       const ENTER_KEY_CODE = 13;
+      const STATE_COLOR = {{ state_color|tojson }};
 
       $('#dag_query').on('keypress', function (e) {
         // check for key press on ENTER (key code 13) to trigger the search
@@ -349,7 +350,7 @@
               })
               .attr('stroke', function(d) {
                   if (d.count > 0)
-                    return d.color;
+                    return STATE_COLOR[d.state];
                   else {
                     return 'gainsboro';
                   }
@@ -428,7 +429,7 @@
               })
               .attr('stroke', function(d) {
                   if (d.count > 0)
-                    return d.color;
+                    return STATE_COLOR[d.state];
                   else {
                     return 'gainsboro';
                   }
diff --git a/airflow/www/views.py b/airflow/www/views.py
index 9d8e37a..737b1e4 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -602,8 +602,7 @@ class Airflow(AirflowViewMixin, BaseView):
                 count = d.get(state, 0)
                 payload[dag_id].append({
                     'state': state,
-                    'count': count,
-                    'color': State.color(state)
+                    'count': count
                 })
         return wwwutils.json_response(payload)
 
@@ -685,8 +684,7 @@ class Airflow(AirflowViewMixin, BaseView):
                 count = data.get(dag_id, {}).get(state, 0)
                 payload[dag_id].append({
                     'state': state,
-                    'count': count,
-                    'color': State.color(state)
+                    'count': count
                 })
         return wwwutils.json_response(payload)
 
@@ -2319,11 +2317,15 @@ class HomeView(AirflowViewMixin, AdminIndexView):
             auto_complete_data.add(row.dag_id)
             auto_complete_data.add(row.owners)
 
+        state_color_mapping = State.state_color.copy()
+        state_color_mapping["null"] = state_color_mapping.pop(None)
+
         return self.render(
             'airflow/dags.html',
             dags=dags,
             hide_paused=hide_paused,
             current_page=current_page,
+            state_color=state_color_mapping,
             search_query=arg_search_query if arg_search_query else '',
             page_size=dags_per_page,
             num_of_pages=num_of_pages,

Reply via email to