ashb commented on a change in pull request #8043: Use same tooltip for Graph
and Tree views for TaskInstances
URL: https://github.com/apache/airflow/pull/8043#discussion_r401535087
##########
File path: airflow/www/static/js/datetime-utils.js
##########
@@ -16,41 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
-export const moment = require('moment-timezone');
+
+/* global moment */
export const defaultFormat = 'YYYY-MM-DD, HH:mm:ss';
export const defaultFormatWithTZ = 'YYYY-MM-DD, HH:mm:ss z';
-const makeDateTimeHTML = (start, end) => {
- return (
- `Started: ${start.format(defaultFormat)} <br> Ended:
${end.format(defaultFormat)} <br>`
- )
-};
-
-export const generateTooltipDateTime = (startDate, endDate, dagTZ) => {
- const tzFormat = 'z (Z)';
- const localTZ = moment.tz.guess();
- startDate = moment.utc(startDate);
- endDate = moment.utc(endDate);
- dagTZ = dagTZ.toUpperCase();
-
- // Generate UTC Start and End Date
- let tooltipHTML = '<br><strong>UTC</strong><br>';
- tooltipHTML += makeDateTimeHTML(startDate, endDate);
-
- // Generate User's Local Start and End Date
- tooltipHTML += `<br><strong>Local:
${moment.tz(localTZ).format(tzFormat)}</strong><br>`;
- tooltipHTML += makeDateTimeHTML(startDate.local(), endDate.local());
-
- // Generate DAG's Start and End Date
- if (dagTZ !== 'UTC' && dagTZ !== localTZ) {
- tooltipHTML += `<br><strong>DAG's TZ:
${moment.tz(dagTZ).format(tzFormat)}</strong><br>`;
- tooltipHTML += makeDateTimeHTML(startDate.tz(dagTZ), endDate.tz(dagTZ));
- }
-
- return tooltipHTML
-};
-
Review comment:
I moved these fns in to a new "task-instances.js" as they are specific to
there, and not general "datetime" utils.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services