diff --git a/src/lib/components/event/event-category-filter.svelte b/src/lib/components/event/event-category-filter.svelte index d0df07671..1e4784d2a 100644 --- a/src/lib/components/event/event-category-filter.svelte +++ b/src/lib/components/event/event-category-filter.svelte @@ -8,6 +8,7 @@ MenuContainer, MenuItem, } from '$lib/holocene/menu'; + import type { MenuButtonVariant } from '$lib/holocene/menu/menu-button.svelte'; import { translate } from '$lib/i18n/translate'; import { allEventTypeOptions, @@ -19,6 +20,7 @@ import { isVersionNewer } from '$lib/utilities/version-check'; export let compact = false; + export let variant: MenuButtonVariant = 'table-header'; $: label = compact ? translate('events', 'event-type') @@ -27,8 +29,10 @@ let parameter = 'category'; let options = compact ? compactEventTypeOptions : allEventTypeOptions; - if (isVersionNewer('1.21', $temporalVersion)) { - options = options.filter(({ option }) => option !== 'update'); + $: { + if (isVersionNewer('1.21', $temporalVersion)) { + options = options.filter(({ option }) => option !== 'update'); + } } $: visibleOption = options.find( @@ -48,7 +52,7 @@ diff --git a/src/lib/components/event/event-history-timeline-helpers.ts b/src/lib/components/event/event-history-timeline-helpers.ts new file mode 100644 index 000000000..27bb1a5e5 --- /dev/null +++ b/src/lib/components/event/event-history-timeline-helpers.ts @@ -0,0 +1,126 @@ +import { get } from 'svelte/store'; + +import { endOfMinute, startOfMinute } from 'date-fns'; +import type { TimelineOptionsZoomKey } from 'vis-timeline'; + +import { relativeTime, timeFormat } from '$lib/stores/time-format'; +import type { WorkflowExecution } from '$lib/types/workflows'; +import { formatDate } from '$lib/utilities/format-date'; +import { formatDistanceAbbreviated } from '$lib/utilities/format-time'; + +type TimelineOptionsTooltipOverflow = 'flip' | 'none' | 'cap'; + +export const getTimelineOptions = (workflow: WorkflowExecution) => ({ + stackSubgroups: true, + maxHeight: 520, + min: startOfMinute(new Date(workflow.startTime)), + max: workflow?.endTime + ? endOfMinute(new Date(workflow?.endTime)) + : Date.now(), + horizontalScroll: true, + verticalScroll: true, + zoomKey: 'ctrlKey' as TimelineOptionsZoomKey, + orientation: { + axis: 'both', + item: 'center', + }, + tooltip: { + delay: 0, + overflowMethod: 'flip' as TimelineOptionsTooltipOverflow, + followMouse: false, + template: tooltipTemplate, + }, + rollingMode: { + follow: false, + }, + format: { + majorLabels: { + millisecond: 'D MMMM HH:mm:ss', + second: 'D MMMM HH:mm', + minute: 'ddd D MMMM', + hour: 'ddd D MMMM', + weekday: 'MMMM YYYY', + day: 'MMMM YYYY', + week: 'MMMM YYYY', + month: 'YYYY', + year: '', + }, + }, + xss: { + disabled: true, + filterOptions: { + whiteList: { + div: ['class'], + }, + }, + }, +}); + +export const tooltipTemplate = (item, _parsedItems): string => { + if (!item?.data?.eventList) return workflowExecutionTooltipTemplate(item); + if (item?.data.eventList.length === 1) + return singleEventTooltipTemplate(item); + return groupEventTooltipTemplate(item); +}; + +const workflowExecutionTooltipTemplate = (item): string => { + return `
+
Start
+
${formatDate(item.start, get(timeFormat), { + relative: get(relativeTime), + })} +
+
+
+
End
+
${formatDate(item.end, get(timeFormat), { + relative: get(relativeTime), + })}
+
+
Duration
${formatDistanceAbbreviated( + { + start: item.start, + end: item.end, + includeMilliseconds: true, + }, + )}
+
+
`; +}; + +const singleEventTooltipTemplate = (item): string => { + return `
+
Event Time
+
${formatDate(item.start, get(timeFormat), { + relative: get(relativeTime), + })} +
+
+
+ `; +}; + +const groupEventTooltipTemplate = (item): string => { + return `
+
Start
+
${formatDate(item.start, get(timeFormat), { + relative: get(relativeTime), + })} +
+
+
+
End
+
${formatDate(item.end, get(timeFormat), { + relative: get(relativeTime), + })}
+
+
Duration
${formatDistanceAbbreviated( + { + start: item.start, + end: item.end, + includeMilliseconds: true, + }, + )}
+
+
`; +}; diff --git a/src/lib/components/event/event-history-timeline.svelte b/src/lib/components/event/event-history-timeline.svelte index 9ffc013f7..f15711eae 100644 --- a/src/lib/components/event/event-history-timeline.svelte +++ b/src/lib/components/event/event-history-timeline.svelte @@ -1,76 +1,103 @@ -
{ + $workflowTimelineViewOpen = !$workflowTimelineViewOpen; + }} > -
-

Timeline

-
- - - +
+
+
+ + timeline.zoomIn(1)}>+ + timeline.zoomOut(1)}>- + timeline.focus('workflow')}>Fit + +
+
-
-
+