From d5109bfff27471c312a42a70fc8754cf87fd0909 Mon Sep 17 00:00:00 2001 From: BobDu Date: Wed, 19 Oct 2022 23:59:05 +0800 Subject: [PATCH] use switch case & fix remove loading dot Signed-off-by: BobDu --- airflow/www/static/js/dags.js | 16 +++++++--------- airflow/www/templates/airflow/dags.html | 4 ++-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/airflow/www/static/js/dags.js b/airflow/www/static/js/dags.js index cbb494b7c4d98..7a9c1625bce99 100644 --- a/airflow/www/static/js/dags.js +++ b/airflow/www/static/js/dags.js @@ -209,13 +209,11 @@ function drawDagAndTaskStatsForDag(selector, dagId, states) { params.append('_flt_3_dag_id', dagId); /* eslint no-unused-expressions: ["error", { "allowTernary": true }] */ d.state ? params.append('_flt_3_state', d.state) : params.append('_flt_8_state', ''); - if (selector === 'dag-run') { - return `${dagRunUrl}?${params.toString()}`; + switch (selector) { + case 'dag-run': return `${dagRunUrl}?${params.toString()}`; + case 'task-run': return `${taskInstanceUrl}?${params.toString()}`; + default: return ''; } - if (selector === 'task-run') { - return `${taskInstanceUrl}?${params.toString()}`; - } - return ''; }) .append('circle') .attr('id', (d) => `${selector}-${dagId.replace(/\./g, '_')}-${d.state || 'none'}`) @@ -251,7 +249,7 @@ function drawDagAndTaskStatsForDag(selector, dagId, states) { .delay((d, i) => i * 50) .style('opacity', 1); - d3.select('.js-loading-dag-stats').remove(); + d3.select(`.js-loading-${selector}-stats`).remove(); g.append('text') .attr('fill', '#51504f') @@ -309,8 +307,8 @@ function getDagStats() { .post(params, taskStatsHandler); } else { // no dags, hide the loading dots - $('.js-loading-task-stats').remove(); - $('.js-loading-dag-stats').remove(); + $('.js-loading-task-run-stats').remove(); + $('.js-loading-dag-run-stats').remove(); } } diff --git a/airflow/www/templates/airflow/dags.html b/airflow/www/templates/airflow/dags.html index 4639c17ace231..2468461cd34bf 100644 --- a/airflow/www/templates/airflow/dags.html +++ b/airflow/www/templates/airflow/dags.html @@ -268,7 +268,7 @@

{{ page_title }}

{% endfor %} - {{ loading_dots(classes='js-loading-dag-stats text-muted') }} + {{ loading_dots(classes='js-loading-dag-run-stats text-muted') }} @@ -342,7 +342,7 @@

{{ page_title }}

{% endif %} - {{ loading_dots(classes='js-loading-task-stats text-muted') }} + {{ loading_dots(classes='js-loading-task-run-stats text-muted') }}