Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions airflow/www/static/js/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,29 @@ function setFocusMap(state) {

const stateIsSet = () => !!Object.keys(stateFocusMap).find((key) => stateFocusMap[key]);

let prevTis;

function handleRefresh() {
$('#loading-dots').css('display', 'inline-block');
$.get(getTaskInstanceURL)
.done(
(tis) => {
// only refresh if the data has changed
if (prevTis !== tis) {
// eslint-disable-next-line no-global-assign
taskInstances = JSON.parse(tis);
updateNodesStates(taskInstances);
taskInstances = JSON.parse(tis);
const states = Object.values(taskInstances).map((ti) => ti.state);
updateNodesStates(taskInstances);

// end refresh if all states are final
if (!states.some((state) => (
['success', 'failed', 'upstream_failed', 'skipped', 'removed'].indexOf(state) === -1))
) {
$('#auto_refresh').prop('checked', false);
clearInterval(refreshInterval);
}
}
prevTis = tis;
setTimeout(() => { $('#loading-dots').hide(); }, 500);
$('#error').hide();
},
Expand Down Expand Up @@ -409,7 +424,7 @@ $('#auto_refresh').change(() => {

function initRefresh() {
if (localStorage.getItem('disableAutoRefresh')) {
$('#auto_refresh').removeAttr('checked');
$('#auto_refresh').prop('checked', false);
}
startOrStopRefresh();
d3.select('#refresh_button').on('click', () => handleRefresh());
Expand Down
4 changes: 2 additions & 2 deletions airflow/www/static/js/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ document.addEventListener('DOMContentLoaded', () => {
if (getActiveRuns()) {
handleRefresh();
} else {
$('#auto_refresh').removeAttr('checked');
$('#auto_refresh').prop('checked', false);
}
}, 3000); // run refresh every 3 seconds
} else {
Expand All @@ -474,7 +474,7 @@ document.addEventListener('DOMContentLoaded', () => {
function initRefresh() {
// default to auto-refresh if there are any active dag runs
if (getActiveRuns() && !localStorage.getItem('disableAutoRefresh')) {
$('#auto_refresh').attr('checked', true);
$('#auto_refresh').prop('checked', true);
}
startOrStopRefresh();
d3.select('#refresh_button').on('click', () => handleRefresh());
Expand Down