Skip to content

Commit

Permalink
[frontend] Interactive Timeline Display
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimfacion committed Aug 28, 2024
1 parent b766741 commit 988774b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions openbas-front/src/components/ChainedTimeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,11 @@ const ChainedTimelineFlow: FunctionComponent<Props> = ({ injects, exerciseOrScen

const onNodePhantomClick = (event: React.MouseEvent) => {
if (newNodeCursorClickable) {
const position = reactFlow.screenToFlowPosition({ x: event.clientX, y: event.clientY });
const position = reactFlow.screenToFlowPosition({ x: event.clientX - 25, y: event.clientY });

const totalMinutes = moment.duration((position.x / gapSize) * minutesPerGapAllowed[minutesPerGapIndex] * 60, 's');
const totalMinutes = position.x > 0
? moment.duration((position.x / gapSize) * minutesPerGapAllowed[minutesPerGapIndex] * 60, 's')
: moment.duration(0);
openCreateInjectDrawer({
inject_depends_duration_days: totalMinutes.days(),
inject_depends_duration_hours: totalMinutes.hours(),
Expand All @@ -246,15 +248,15 @@ const ChainedTimelineFlow: FunctionComponent<Props> = ({ injects, exerciseOrScen
if (startDate === undefined) {
const momentOfTime = moment.utc(
moment.duration(convertCoordinatesToTime(
{ x: sidePosition.x, y: sidePosition.y },
{ x: sidePosition.x > 0 ? sidePosition.x : 0, y: sidePosition.y },
), 's').asMilliseconds(),
);

setCurrentMouseTime(`${momentOfTime.dayOfYear() - 1} d, ${momentOfTime.hour()} h, ${momentOfTime.minute()} m`);
} else {
const momentOfTime = moment.utc(startDate)
.add(-new Date().getTimezoneOffset() / 60, 'h')
.add(convertCoordinatesToTime({ x: sidePosition.x, y: sidePosition.y }), 's');
.add(convertCoordinatesToTime({ x: sidePosition.x > 0 ? sidePosition.x : 0, y: sidePosition.y }), 's');

setCurrentMouseTime(momentOfTime.format('MMMM Do, YYYY - h:mmA'));
}
Expand Down

0 comments on commit 988774b

Please sign in to comment.