Skip to content

Commit

Permalink
use switch case & fix remove loading dot
Browse files Browse the repository at this point in the history
Signed-off-by: BobDu <[email protected]>
  • Loading branch information
BobDu committed Oct 19, 2022
1 parent 18ee5de commit d5109bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
16 changes: 7 additions & 9 deletions airflow/www/static/js/dags.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'}`)
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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();
}
}

Expand Down
4 changes: 2 additions & 2 deletions airflow/www/templates/airflow/dags.html
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ <h2>{{ page_title }}</h2>
{% endfor %}
</td>
<td style="padding:0; width:130px;">
{{ loading_dots(classes='js-loading-dag-stats text-muted') }}
{{ loading_dots(classes='js-loading-dag-run-stats text-muted') }}
<svg height="10" width="10" id="dag-run-{{ dag.safe_dag_id }}" style="display: block;"></svg>
</td>
<td>
Expand Down Expand Up @@ -342,7 +342,7 @@ <h2>{{ page_title }}</h2>
{% endif %}
</td>
<td style="padding:0; width:323px; height:10px;">
{{ loading_dots(classes='js-loading-task-stats text-muted') }}
{{ loading_dots(classes='js-loading-task-run-stats text-muted') }}
<svg height="10" width="10" id='task-run-{{ dag.safe_dag_id }}' style="display: block;"></svg>
</td>
<td class="text-center">
Expand Down

0 comments on commit d5109bf

Please sign in to comment.