-
Notifications
You must be signed in to change notification settings - Fork 16.3k
[DRAFT] [AIRFLOW-3891] Make the Graph View time-zone aware #4893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Note: this PR isn't fit to be merged, as it only addresses the Graph view page. I'm sharing this for early review to make sure it's on the right track. If there are no major objections to this approach, then I'll apply similar changes to the other views. The clock element in the navbar is now a drop-down that allows time-zone selection from two options: 'UTC' or 'Local' (the browser default). The default is UTC, and this selection does not persist across page refreshes. I'm open to suggestions here on whether the time-zone selection should be "sticky", and if so, what's the right way to make it so. The `Base date:` datetimepicker requires a bit of hackery, since the datetimepicker element bundled with Flask-AppBuilder doesn't seem to have time zone support (see [1]). To work around this, we have to add an offset to the (UTC) value in the picker so that the date string displayed in the picker appears to be in the selected time zone, then subtract the offset when we read the actual (UTC) value from the picker. [1] dpgaspar/Flask-AppBuilder#920
Codecov Report
@@ Coverage Diff @@
## master #4893 +/- ##
======================================
Coverage 75.3% 75.3%
======================================
Files 450 450
Lines 29023 29023
======================================
Hits 21855 21855
Misses 7168 7168
Continue to review full report at Codecov.
|
|
hey @astahlman , does the default timezone in UI based on a config? Currently there is a config(https://github.com/apache/airflow/blob/master/airflow/config_templates/default_airflow.cfg#L78) to decide the default timezone for scheduler. I wonder whether we could do something similar in webserver as well. |
Yes, it probably should be. Using a (client-side) cookie would be the way to go. I agree with Feng - the default TZ should probably be what is in the config file. So we possibly need three options (depending on the values of the tzs): UTC, Airflow configured, Browser local. |
| @@ -0,0 +1,21 @@ | |||
| /** | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably call this "base" or "common" or something - "index" is a unmeaningful to work out what might be in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I picked 'index' only because that's the file name that the webpack docs on Libraries used. I'm guessing there's a way to override that - I'll dig in a bit more and see if I can use base.js instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that important actually.
| <script src="{{ url_for_asset('graph.js') }}"></script> | ||
| <script src="{{ url_for_asset('index.js') }}"></script> | ||
| <script type="text/javascript"> | ||
| let dagTz = '{{ dag.timezone.name }}'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've started putting thins like this in <meta> tags, rather than blocks of JS (or we have open PRs by @mik-laj to do that. I forget if we've merged them yet)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
I like where this is going though. |
|
|
||
| </script> | ||
| <script src="{{ url_for_asset('graph.js') }}"></script> | ||
| <script src="{{ url_for_asset('index.js') }}"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this play with the import of export { initRefreshButton, update_nodes_states } from './graph'; inside index.js? Is the include of graph.js on the previous line the same file?
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |



Note: this PR isn't fit to be merged, as it only addresses the Graph
view page. I'm sharing this for early review to make sure it's on the
right track. If there are no major objections to this approach, then
I'll apply similar changes to the other views.
Make sure you have checked all steps below.
Jira
Description
The clock element in the navbar is now a drop-down that allows time-zone
selection from two options: 'UTC' or 'Local' (the browser default). The
default is UTC, and this selection does not persist across page
refreshes. I'm open to suggestions here on whether the time-zone
selection should be "sticky", and if so, what's the right way to make it
so.
The
Base date:datetimepicker requires a bit of hackery, since thedatetimepicker element bundled with Flask-AppBuilder doesn't seem to
have time zone support (see [1]). To work around this, we have to add an
offset to the (UTC) value in the picker so that the date string
displayed in the picker appears to be in the selected time zone, then
subtract the offset when we read the actual (UTC) value from the picker.
[1] dpgaspar/Flask-AppBuilder#920
Tests
Front-end changes only
Commits
Documentation
Code Quality
flake8