-
Notifications
You must be signed in to change notification settings - Fork 22
feat: add more details to trainrun events #853
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
base: main
Are you sure you want to change the base?
Changes from all commits
32f422c
09ad4a7
40b2ee1
8b9d6f6
8e8cb5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,7 +29,13 @@ import {FilterService} from "../ui/filter.service"; | |
| import {Transition} from "../../models/transition.model"; | ||
| import {Port} from "../../models/port.model"; | ||
| import {Connection} from "../../models/connection.model"; | ||
| import {Operation, OperationType, TrainrunOperation} from "../../models/operation.model"; | ||
| import { | ||
| Operation, | ||
| OperationType, | ||
| TrainrunCreateOperation, | ||
| TrainrunDeleteOperation, | ||
| TrainrunUpdateOperation, | ||
| } from "../../models/operation.model"; | ||
| import {TrainrunsectionHelper} from "../util/trainrunsection.helper"; | ||
|
|
||
| @Injectable({ | ||
|
|
@@ -158,7 +164,7 @@ export class TrainrunService { | |
| if (enforceUpdate) { | ||
| this.trainrunsUpdated(); | ||
| } | ||
| this.operation.emit(new TrainrunOperation(OperationType.delete, trainrun)); | ||
| this.operation.emit(new TrainrunDeleteOperation(trainrun)); | ||
| } | ||
|
|
||
| getSelectedTrainrun(): Trainrun { | ||
|
|
@@ -230,7 +236,7 @@ export class TrainrunService { | |
| this.nodeService.reorderPortsOnNodesForTrainrun(trainrun, false); | ||
| this.propagateTrainrunInitialConsecutiveTimes(trainrun); | ||
| this.trainrunsUpdated(); | ||
| this.operation.emit(new TrainrunOperation(OperationType.update, trainrun)); | ||
| this.operation.emit(new TrainrunUpdateOperation(trainrun, ["times", "frequencyId"])); | ||
| return freqOffset; | ||
| } | ||
|
|
||
|
|
@@ -242,7 +248,7 @@ export class TrainrunService { | |
| this.getTrainrunFromId(trainrun.getId()).setTrainrunCategory(category); | ||
| this.nodeService.reorderPortsOnNodesForTrainrun(trainrun, false); | ||
| this.trainrunsUpdated(); | ||
| this.operation.emit(new TrainrunOperation(OperationType.update, trainrun)); | ||
| this.operation.emit(new TrainrunUpdateOperation(trainrun, ["categoryId"])); | ||
| } | ||
|
|
||
| updateTrainrunTimeCategory(trainrun: Trainrun, timeCategory: TrainrunTimeCategory) { | ||
|
|
@@ -254,21 +260,25 @@ export class TrainrunService { | |
| this.getTrainrunFromId(trainrun.getId()).setTrainrunTimeCategory(timeCategory); | ||
| this.nodeService.reorderPortsOnNodesForTrainrun(trainrun, false); | ||
| this.trainrunsUpdated(); | ||
| this.operation.emit(new TrainrunOperation(OperationType.update, trainrun)); | ||
| this.operation.emit(new TrainrunUpdateOperation(trainrun, ["timeCategoryId"])); | ||
| } | ||
|
|
||
| updateTrainrunTitle(trainrun: Trainrun, title: string) { | ||
| this.getTrainrunFromId(trainrun.getId()).setTitle(title); | ||
| this.nodeService.reorderPortsOnNodesForTrainrun(trainrun, false); | ||
| this.trainrunsUpdated(); | ||
| this.operation.emit(new TrainrunOperation(OperationType.update, trainrun)); | ||
| this.operation.emit(new TrainrunUpdateOperation(trainrun, ["name"])); | ||
| } | ||
|
|
||
| updateDirection(trainrun: Trainrun, direction: Direction) { | ||
| updateDirection(trainrun: Trainrun, direction: Direction, isTrainInverted?: boolean) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we pass
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure! |
||
| const trainrunSection = this.getTrainrunFromId(trainrun.getId()); | ||
| trainrunSection.setDirection(direction); | ||
| this.trainrunsUpdated(); | ||
| this.operation.emit(new TrainrunOperation(OperationType.update, trainrun)); | ||
| let oneWayDirection = undefined; | ||
| if (direction === Direction.ONE_WAY) oneWayDirection = isTrainInverted ? "backward" : "forward"; | ||
| this.operation.emit( | ||
| new TrainrunUpdateOperation(trainrun, ["direction", "nodes", "times"], oneWayDirection), | ||
| ); | ||
| } | ||
|
|
||
| getTrainruns(): Trainrun[] { | ||
|
|
@@ -300,6 +310,7 @@ export class TrainrunService { | |
| if (this.filterService.filterTrainrun(t)) { | ||
| this.filterService.clearDeletetFilterTrainrunLabel(labelObject.getId()); | ||
| t.setLabelIds(t.getLabelIds().filter((labelId: number) => labelId !== labelObject.getId())); | ||
| this.operation.emit(new TrainrunUpdateOperation(t, ["labelIds"])); | ||
| } | ||
| }); | ||
|
|
||
|
|
@@ -385,7 +396,10 @@ export class TrainrunService { | |
| newTrainrun.select(); | ||
| this.nodeService.transitionsUpdated(); | ||
| this.trainrunsUpdated(); | ||
| this.operation.emit(new TrainrunOperation(OperationType.create, newTrainrun)); | ||
| this.operation.emit(new TrainrunCreateOperation(newTrainrun)); | ||
| this.operation.emit( | ||
| new TrainrunUpdateOperation(trainrun2split, ["nodes", "times", "numberOfStops"]), | ||
emersion marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ); | ||
| } | ||
|
|
||
| combineTwoTrainruns(node: Node, port1: Port, port2: Port) { | ||
|
|
@@ -498,6 +512,9 @@ export class TrainrunService { | |
|
|
||
| // update | ||
| this.trainrunsUpdated(); | ||
| this.operation.emit( | ||
| new TrainrunUpdateOperation(trainrun1, ["nodes", "times", "numberOfStops"]), | ||
| ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aren't we missing a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm I don't think so, there is a call to this.deleteTrainrun earlier which I believe already emits the event |
||
| this.nodeService.nodesUpdated(); | ||
| this.nodeService.connectionsUpdated(); | ||
| this.nodeService.transitionsUpdated(); | ||
|
|
@@ -532,7 +549,7 @@ export class TrainrunService { | |
| this.nodeService.nodesUpdated(); | ||
| this.trainrunsUpdated(); | ||
| } | ||
| this.operation.emit(new TrainrunOperation(OperationType.create, copiedtrainrun)); | ||
| this.operation.emit(new TrainrunCreateOperation(copiedtrainrun, trainrunId)); | ||
| return copiedtrainrun; | ||
| } | ||
|
|
||
|
|
@@ -552,7 +569,7 @@ export class TrainrunService { | |
| trainrun.setLabelIds(labelIds); | ||
| this.trainrunsUpdated(); | ||
| if (uniqueLabels.length === labels.length) { | ||
| this.operation.emit(new TrainrunOperation(OperationType.update, trainrun)); | ||
| this.operation.emit(new TrainrunUpdateOperation(trainrun, ["labelIds"])); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,12 @@ import {Transition} from "../../models/transition.model"; | |
| import {takeUntil} from "rxjs/operators"; | ||
| import {FilterService} from "../ui/filter.service"; | ||
| import {DirectedTrainrunSectionProxy} from "../util/trainrun.iterator"; | ||
| import {Operation, OperationType, TrainrunOperation} from "../../models/operation.model"; | ||
| import { | ||
| Operation, | ||
| OperationType, | ||
| TrainrunCreateOperation, | ||
| TrainrunUpdateOperation, | ||
| } from "../../models/operation.model"; | ||
|
|
||
| interface DepartureAndArrivalTimes { | ||
| nodeFromDepartureTime: number; | ||
|
|
@@ -309,7 +314,9 @@ export class TrainrunSectionService implements OnDestroy { | |
| const trainrunSection = this.getTrainrunSectionFromId(trs.getId()); | ||
| trainrunSection.setNumberOfStops(numberOfStops); | ||
| this.trainrunSectionsUpdated(); | ||
| this.operation.emit(new TrainrunOperation(OperationType.update, trainrunSection.getTrainrun())); | ||
| this.operation.emit( | ||
| new TrainrunUpdateOperation(trainrunSection.getTrainrun(), ["numberOfStops"]), | ||
| ); | ||
| } | ||
|
|
||
| updateTrainrunSectionTime( | ||
|
|
@@ -583,12 +590,14 @@ export class TrainrunSectionService implements OnDestroy { | |
| this.trainrunService.trainrunsUpdated(); | ||
|
|
||
| if (initialTrainrunsLength !== this.trainrunService.trainrunsStore.trainruns.length) { | ||
| this.operation.emit( | ||
| new TrainrunOperation(OperationType.create, trainrunSection.getTrainrun()), | ||
| ); | ||
| this.operation.emit(new TrainrunCreateOperation(trainrunSection.getTrainrun())); | ||
| } else { | ||
| this.operation.emit( | ||
| new TrainrunOperation(OperationType.update, trainrunSection.getTrainrun()), | ||
| new TrainrunUpdateOperation(trainrunSection.getTrainrun(), [ | ||
| "nodes", | ||
| "times", | ||
| "numberOfStops", | ||
| ]), | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -667,7 +676,13 @@ export class TrainrunSectionService implements OnDestroy { | |
| this.nodeService.transitionsUpdated(); | ||
| this.trainrunSectionsUpdated(); | ||
| } | ||
| this.operation.emit(new TrainrunOperation(OperationType.update, trainrunSection.getTrainrun())); | ||
| this.operation.emit( | ||
| new TrainrunUpdateOperation(trainrunSection.getTrainrun(), [ | ||
| "nodes", | ||
| "numberOfStops", | ||
| "times", | ||
| ]), | ||
| ); | ||
| } | ||
|
|
||
| deleteListOfTrainrunSections(trainrunSections: TrainrunSection[], enforceUpdate = true) { | ||
|
|
@@ -740,7 +755,11 @@ export class TrainrunSectionService implements OnDestroy { | |
| } | ||
| if (this.getTrainrunSections().length) { | ||
| this.operation.emit( | ||
| new TrainrunOperation(OperationType.update, trainrunSection.getTrainrun()), | ||
| new TrainrunUpdateOperation(trainrunSection.getTrainrun(), [ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, do you recall why we fire a
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I honestly don't remember :/
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My understanding is as follow:
|
||
| "nodes", | ||
| "numberOfStops", | ||
| "times", | ||
| ]), | ||
| ); | ||
| } | ||
| } | ||
|
|
@@ -785,7 +804,7 @@ export class TrainrunSectionService implements OnDestroy { | |
| ) { | ||
| this.updateTrainrunSectionLeftAndRightTimes(section, timeStructure); | ||
| this.operation.emit( | ||
| new TrainrunOperation(OperationType.update, section.trainrunSection.getTrainrun()), | ||
| new TrainrunUpdateOperation(section.trainrunSection.getTrainrun(), ["times"]), | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -849,7 +868,7 @@ export class TrainrunSectionService implements OnDestroy { | |
|
|
||
| this.trainrunSectionsUpdated(); | ||
| this.nodeService.connectionsUpdated(); | ||
| this.operation.emit(new TrainrunOperation(OperationType.update, trainrunSection.getTrainrun())); | ||
| this.operation.emit(new TrainrunUpdateOperation(trainrunSection.getTrainrun(), ["times"])); | ||
| } | ||
|
|
||
| trainrunSectionsUpdated() { | ||
|
|
@@ -976,6 +995,13 @@ export class TrainrunSectionService implements OnDestroy { | |
| this.nodeService.connectionsUpdated(); | ||
| this.nodeService.nodesUpdated(); | ||
| this.trainrunSectionsUpdated(); | ||
| this.operation.emit( | ||
| new TrainrunUpdateOperation(trainrunSection1.getTrainrun(), [ | ||
| "nodes", | ||
| "times", | ||
| "numberOfStops", | ||
| ]), | ||
| ); | ||
| } | ||
|
|
||
| setWarningOnNode( | ||
|
|
||
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 don't think
numberOfStopschanges when toggling non-stop?Uh oh!
There was an error while loading. Please reload this page.
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 will trust you on this.
I am relatively confident about the other tags, but for numberOfStops I only have a general idea of its meaning. So I added it to anything that seemed to touch stops (better to update for nothing than miss an update). But yeah, if you do know which functions actually touch it, that's better =p