Skip to content

Commit 43a0b02

Browse files
committed
wip: add inputs/outputs to root component
1 parent 52e9b86 commit 43a0b02

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

src/app/app.component.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
import {Component} from "@angular/core";
1+
import {Component, Input, Output} from "@angular/core";
22
import {AuthService} from "./services/auth/auth.service";
3+
import {TrainrunService} from "./services/data/trainrun.service";
4+
import {TrainrunSectionService} from "./services/data/trainrunsection.service";
5+
import {DataService} from "./services/data/data.service";
36
import {environment} from "../environments/environment";
47
import packageJson from "../../package.json";
58
import {Observable} from "rxjs";
69
import {ProjectDto} from "./api/generated";
10+
import {NetzgrafikDto} from "./data-structures/business.data.structures";
711

812
@Component({
913
selector: "sbb-root",
@@ -33,7 +37,20 @@ export class AppComponent {
3337
return this.authService.claims?.email;
3438
}
3539

36-
constructor(private authService: AuthService) {
40+
constructor(private authService: AuthService, private trainrunService: TrainrunService, private trainrunSectionService: TrainrunSectionService, private dataService: DataService) {
41+
42+
/*trainrunService.trainruns.subscribe((value) => {
43+
console.log('trainrunService', value);
44+
});
45+
46+
trainrunSectionService.trainrunSections.subscribe((value) => {
47+
console.log('trainrunSectionService', value);
48+
});*/
49+
50+
/*trainrunSectionService.trainrunSectionCreated.subscribe((trainrunSection) => {
51+
console.log('trainrunSectionCreated', trainrunSection);
52+
});*/
53+
3754
if (!this.disableBackend) {
3855
this.authenticated = authService.initialized;
3956
}
@@ -44,4 +61,15 @@ export class AppComponent {
4461
this.authService.logOut();
4562
}
4663
}
64+
65+
@Input()
66+
get dto() {
67+
return this.dataService.getNetzgrafikDto();
68+
}
69+
set dto(dto: NetzgrafikDto) {
70+
this.dataService.loadNetzgrafikDto(dto);
71+
}
72+
73+
@Output()
74+
trainrunSectionOperation = this.trainrunSectionService.trainrunSectionOperation;
4775
}

src/app/services/data/trainrunsection.service.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
TrainrunSectionDto,
66
} from "../../data-structures/business.data.structures";
77
import {Node} from "../../models/node.model";
8-
import {Injectable, OnDestroy} from "@angular/core";
8+
import {Injectable, OnDestroy, EventEmitter} from "@angular/core";
99
import {BehaviorSubject, Subject} from "rxjs";
1010
import {TrainrunService} from "./trainrun.service";
1111
import {NodeService} from "./node.service";
@@ -35,6 +35,11 @@ export interface InformSelectedTrainrunClick {
3535
open: boolean;
3636
}
3737

38+
export class TrainrunSectionOperation {
39+
type: 'create' | 'update' | 'delete';
40+
trainrunSection: TrainrunSection;
41+
}
42+
3843
@Injectable({
3944
providedIn: "root",
4045
})
@@ -46,6 +51,8 @@ export class TrainrunSectionService implements OnDestroy {
4651
trainrunSections: [],
4752
}; // store the data in memory
4853

54+
trainrunSectionOperation = new EventEmitter<TrainrunSectionOperation>();
55+
4956
informSelectedTrainrunClickSubject =
5057
new BehaviorSubject<InformSelectedTrainrunClick>({
5158
trainrunSectionId: undefined,
@@ -698,6 +705,11 @@ export class TrainrunSectionService implements OnDestroy {
698705
this.propagateTimesForNewTrainrunSection(trainrunSection);
699706
//this.trainrunSectionsUpdated();
700707
this.trainrunService.trainrunsUpdated();
708+
709+
this.trainrunSectionOperation.emit({
710+
type: 'create',
711+
trainrunSection: trainrunSection,
712+
});
701713
}
702714

703715
reconnectTrainrunSection(

0 commit comments

Comments
 (0)