You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ep...@apache.org on 2022/03/22 19:16:19 UTC
[airflow] 08/31: Fix graph autorefresh on page load (#21736)
This is an automated email from the ASF dual-hosted git repository.
ephraimanierobi pushed a commit to branch v2-2-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
commit ecdbacfe7a4b3c20725a715bffa5c88138538a7e
Author: Brent Bovenzi <br...@gmail.com>
AuthorDate: Tue Feb 22 11:41:39 2022 -0500
Fix graph autorefresh on page load (#21736)
* fix auto refresh check on page load
* minor code cleanup
* remove new line
(cherry picked from commit b2c0a921c155e82d1140029e6495594061945025)
---
airflow/www/static/js/graph.js | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/airflow/www/static/js/graph.js b/airflow/www/static/js/graph.js
index 2d3b22e..615e238 100644
--- a/airflow/www/static/js/graph.js
+++ b/airflow/www/static/js/graph.js
@@ -57,6 +57,13 @@ const stateFocusMap = {
deferred: false,
no_status: false,
};
+
+const checkRunState = () => {
+ const states = Object.values(taskInstances).map((ti) => ti.state);
+ return !states.some((state) => (
+ ['success', 'failed', 'upstream_failed', 'skipped', 'removed'].indexOf(state) === -1));
+};
+
const taskTip = d3.tip()
.attr('class', 'tooltip d3-tip')
.html((toolTipHtml) => toolTipHtml);
@@ -362,13 +369,11 @@ function handleRefresh() {
if (prevTis !== tis) {
// eslint-disable-next-line no-global-assign
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))
- ) {
+ const isFinal = checkRunState();
+ if (isFinal) {
$('#auto_refresh').prop('checked', false);
clearInterval(refreshInterval);
}
@@ -410,9 +415,9 @@ $('#auto_refresh').change(() => {
});
function initRefresh() {
- if (localStorage.getItem('disableAutoRefresh')) {
- $('#auto_refresh').prop('checked', false);
- }
+ const isDisabled = localStorage.getItem('disableAutoRefresh');
+ const isFinal = checkRunState();
+ $('#auto_refresh').prop('checked', !(isDisabled || isFinal));
startOrStopRefresh();
d3.select('#refresh_button').on('click', () => handleRefresh());
}