Skip to content

Commit

Permalink
hack: add label service
Browse files Browse the repository at this point in the history
  • Loading branch information
Uriel-Sautron committed Sep 18, 2024
1 parent 5299d72 commit 1c59d9c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
15 changes: 9 additions & 6 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ export class AppComponent {
return this.authService.claims?.email;
}

constructor(private authService: AuthService,
private dataService: DataService,
private trainrunService: TrainrunService,
private trainrunSectionService: TrainrunSectionService,
private nodeService: NodeService,
) {
constructor(
private authService: AuthService,
private dataService: DataService,
private trainrunService: TrainrunService,
private trainrunSectionService: TrainrunSectionService,
private nodeService: NodeService,
private labelService: LabelService,
) {
if (!this.disableBackend) {
this.authenticated = authService.initialized;
}
Expand Down Expand Up @@ -76,5 +78,6 @@ export class AppComponent {
this.trainrunService.operation,
this.trainrunSectionService.operation,
this.nodeService.operation,
this.labelService.operation,
);
}
15 changes: 14 additions & 1 deletion src/app/models/operation.model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Node} from "./node.model";
import {Trainrun} from "./trainrun.model";
import {Label} from "./label.model";

enum OperationType {
create = "create",
Expand All @@ -10,7 +11,8 @@ enum OperationType {
enum OperationObjectType {
trainrun = "trainrun",
node = "node",
};
label = "label",
}

abstract class Operation {
readonly type: OperationType;
Expand Down Expand Up @@ -40,9 +42,20 @@ class NodeOperation extends Operation {
}
}

class LabelOperation extends Operation {
readonly label: Label;

constructor(operationType: OperationType, label: Label) {
super(operationType, OperationObjectType.label);
this.label = label;
console.log("this.label :", this.label);
}
}

export {
OperationType,
Operation,
TrainrunOperation,
NodeOperation,
LabelOperation,
};
10 changes: 9 additions & 1 deletion src/app/services/data/label.serivce.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Injectable, OnDestroy} from "@angular/core";
import {EventEmitter, Injectable, OnDestroy} from "@angular/core";
import {BehaviorSubject, Subject} from "rxjs";
import {LogService} from "../../logger/log.service";
import {
Expand All @@ -7,6 +7,11 @@ import {
} from "../../data-structures/business.data.structures";
import {Label} from "../../models/label.model";
import {LabelGroupService} from "./labelgroup.service";
import {
LabelOperation,
Operation,
OperationType,
} from "src/app/models/operation.model";

@Injectable({
providedIn: "root",
Expand All @@ -16,6 +21,8 @@ export class LabelService implements OnDestroy {
readonly labels = this.labelSubject.asObservable();
private labelStore: {labels: Label[]} = {labels: []}; // store the data in memory

readonly operation = new EventEmitter<Operation>();

private destroyed = new Subject<void>();

constructor(
Expand All @@ -36,6 +43,7 @@ export class LabelService implements OnDestroy {
labelObject.setLabel(newLabelValue);
}
this.labelUpdated();
this.operation.emit(new LabelOperation(OperationType.update, labelObject));
}

doUserDefinedLabelsOrdering(labelIds: number[]) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<h2 class="SummaryTitle">{{ 'app.view.editor-edit-tools-view-component.edit' | translate }}</h2>
<sbb-accordion [multi]="false">
<sbb-accordion [multi]="false" >
<sbb-expansion-panel
[expanded]="false"
[hideToggle]="false"
Expand All @@ -13,7 +13,8 @@ <h2 class="SummaryTitle">{{ 'app.view.editor-edit-tools-view-component.edit' | t
[componentLabelRef]="'Trainrun'"
></sbb-label-drop-list-component>
</sbb-expansion-panel>
<sbb-expansion-panel [expanded]="false">

<sbb-expansion-panel [expanded]="false" *ngIf="false">
<sbb-expansion-panel-header>{{ 'app.view.editor-edit-tools-view-component.nodes' | translate }}</sbb-expansion-panel-header>
<sbb-label-drop-list-component
[componentLabelRef]="'Node'"
Expand All @@ -29,7 +30,7 @@ <h2 class="SummaryTitle">{{ 'app.view.editor-edit-tools-view-component.edit' | t
</sbb-accordion>
</sbb-expansion-panel>

<sbb-expansion-panel [expanded]="true">
<sbb-expansion-panel [expanded]="true" *ngIf="false">
<sbb-expansion-panel-header>{{ 'app.view.editor-edit-tools-view-component.delete-netzgrafik-title' | translate }}</sbb-expansion-panel-header>

<ng-container
Expand Down Expand Up @@ -81,7 +82,7 @@ <h2 class="SummaryTitle">{{ 'app.view.editor-edit-tools-view-component.edit' | t
</button>
{{ 'app.view.editor-edit-tools-view-component.delete-all-visible-elements' | translate }}
</sbb-expansion-panel>
<sbb-expansion-panel [expanded]="false">
<sbb-expansion-panel [expanded]="false" *ngIf="false">
<sbb-expansion-panel-header>
{{ 'app.view.editor-edit-tools-view-component.merge-netzgrafik-title' | translate }}
</sbb-expansion-panel-header>
Expand Down

0 comments on commit 1c59d9c

Please sign in to comment.