Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
name: Continuous Integration
on:
push:
branches:
- main
pull_request:
branches:
- main
on: [push]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand All @@ -29,6 +23,7 @@ jobs:

lint:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand Down Expand Up @@ -100,3 +95,26 @@ jobs:
with:
name: build-standalone-demo
path: dist/netzgrafik-frontend/

publish:
runs-on: ubuntu-latest
needs: build-standalone
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-standalone
path: dist/netzgrafik-frontend/
- uses: actions/setup-node@v4
with:
registry-url: "https://registry.npmjs.org"
- run: npm pkg set name="@osrd-project/netzgrafik-frontend"
- run: npm version --no-git-tag-version "0.0.0-snapshot.$GITHUB_SHA"
- run: npm pkg delete dependencies optionalDependencies devDependencies
- run: npm publish --provenance --access public --tag snapshot
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,68 @@
# Netzgrafik-Editor's OSRD fork

Our fork uses the branch `standalone`, regularily rebased onto the base
repository's `main` branch. We try to keep the list of patches applied on top
of the base repository as small as possible, ideally upstreaming them little by
little when it makes sense. The list of patches can be viewed here:
https://github.com/SchweizerischeBundesbahnen/netzgrafik-editor-frontend/compare/main...osrd-project:netzgrafik-editor-frontend:standalone

A new NPM package is automatically published on all pushes to any branch of the
fork. The list of versions can be seen here:
https://www.npmjs.com/package/@osrd-project/netzgrafik-frontend?activeTab=versions

## Initial setup

Clone the base repository, add OSRD's fork as a separate remote, checkout the
fork's branch:

```sh
git clone [email protected]:SchweizerischeBundesbahnen/netzgrafik-editor-frontend.git
cd netzgrafik-editor-frontend
git remote add osrd-project [email protected]:osrd-project/netzgrafik-editor-frontend.git
git fetch osrd-project
git checkout standalone
```

## Pulling in changes from the base repository

Fetch changes from the base repository and rebase our fork:

```sh
git fetch --all
git checkout standalone
git reset --hard osrd-project/standalone
git rebase origin/main
git push --force-with-lease
```

## Making changes to fork patches

Sometimes it's necessary to make a change to one of our fork's patches (as
opposed to one of the commits present in the base repository).

First switch to the `standalone` branch and identify the commit you want to
edit. Then create a new working branch, make the changes to the source files,
and create a fixup commit:

```sh
git checkout standalone
git checkout -b emersion/fix-all-the-bugs
# edit source files, work work work
git commit -a --fixup <hash>
git push osrd-project
```

A pull request can then be opened and the changes can be reviewed. Once the PR
is merged, the fixup can be squashed into its original commit:

```sh
git fetch --all
git checkout standalone
git reset --hard osrd-project/standalone
git rebase --autosquash --keep-base origin/main
git push --force-with-lease
```

# Netzgrafik-Editor

<details>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"version": "2.9.29",
"repository": {
"type": "git",
"url": "https://github.com/SchweizerischeBundesbahnen/netzgrafik-editor-frontend.git"
"url": "https://github.com/osrd-project/netzgrafik-editor-frontend.git"
},
"files": [
"dist/*"
Expand Down
1 change: 1 addition & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
label="Netzgrafik-Editor"
[subtitle]="'app.version' | translate: {version: version}"
class="sbb-header-fixed-columns noprint"
*ngIf="!disableBackend"
>
<sbb-app-chooser-section [label]="'app.user-guide' | translate" class="noprint">
<a
Expand Down
2 changes: 1 addition & 1 deletion src/app/data-structures/technical.data.structures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export interface TimeFormatter {
* Represents the time data in TrainrunSectionDto.
*/
export interface TimeLockDto {
time: number; // minutes [0..60]
time: number | null; // minutes [0..60]
consecutiveTime: number; // automatically updated after any data changes in the application
lock: boolean; // used to stop the time propagation (forward/backward)
warning: WarningDto; // warning - if business logic detects an issue -> set human-readable warning
Expand Down
9 changes: 9 additions & 0 deletions src/app/models/trainrunsection.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from "../data-structures/technical.data.structures";
import {TrainrunSectionValidator} from "../services/util/trainrunsection.validator";
import {formatDate} from "@angular/common";
import {environment} from "src/environments/environment";

export class TrainrunSection {
private static currentId = 0;
Expand Down Expand Up @@ -171,6 +172,9 @@ export class TrainrunSection {
}

private static formatDisplayText(time: TimeLockDto, offset: number): string {
if (time.time === null) {
return "?";
}
if (!time?.timeFormatter?.stylePattern) {
return undefined;
}
Expand Down Expand Up @@ -455,22 +459,27 @@ export class TrainrunSection {
}

hasTravelTimeWarning(): boolean {
if (environment.disableBackend) return false;
return this.travelTime.warning !== null;
}

hasSourceDepartureWarning(): boolean {
if (environment.disableBackend) return false;
return this.sourceDeparture.warning !== null;
}

hasSourceArrivalWarning(): boolean {
if (environment.disableBackend) return false;
return this.sourceArrival.warning !== null;
}

hasTargetDepartureWarning(): boolean {
if (environment.disableBackend) return false;
return this.targetDeparture.warning !== null;
}

hasTargetArrivalWarning(): boolean {
if (environment.disableBackend) return false;
return this.targetArrival.warning !== null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ a.SideBarMainIcon.sbb-active {
}

.sbb-icon-sidebar-container.disableBackend {
top: 53px;
top: 0px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
height="28px"
/>
<text x="8" y="55" class="node_text">{{ perlenketteNode.shortName }}</text>
<text x="88" y="55" text-anchor="end" class="node_connection_time">
<text x="88" y="55" text-anchor="end" class="node_connection_time" *ngIf="false">
{{ perlenketteNode.connectionTime }}
</text>

Expand Down Expand Up @@ -267,6 +267,7 @@
[attr.y]="55 + heightConnectionSurplus"
text-anchor="end"
class="node_connection_time"
*ngIf="false"
>
{{ perlenketteNode.connectionTime }}
</text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ export class PerlenketteNodeComponent implements OnInit {
}

getTextNameOrTime(connection: PerlenketteConnection, connectionGrpKey: number, pos: number) {
return pos === 0
? connection.categoryShortName + "" + connection.title
: "" + connection.remainingTime;
return pos === 0 ? "" + connection.title : "" + connection.remainingTime;
}

transformIndex(index: number, connectionGrpKey: number): number {
Expand Down Expand Up @@ -311,7 +309,7 @@ export class PerlenketteNodeComponent implements OnInit {
this.perlenketteTrainrun.pathItems.forEach((item: PerlenketteItem) => {
if (item.isPerlenketteNode()) {
item.getPerlenketteNode().connections.forEach((connection: PerlenketteConnection) => {
const name = connection.categoryShortName + "" + connection.title;
const name = "" + connection.title;
maxTrainrunNameLen = Math.max(
3 + connection.terminalStationBackward.length,
Math.max(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,9 @@ export class PerlenketteSectionComponent implements OnInit, AfterContentInit, On
}

getTravelTime() {
if (this.trainrunSectionTimesService.getTimeStructure().travelTime === null) {
return null;
}
if (
TrainrunSectionsView.getNode(this.trainrunSection, true).isNonStop(this.trainrunSection) ||
TrainrunSectionsView.getNode(this.trainrunSection, false).isNonStop(this.trainrunSection)
Expand Down Expand Up @@ -899,6 +902,9 @@ export class PerlenketteSectionComponent implements OnInit, AfterContentInit, On
}

roundTime(time: number) {
if (time === null) {
return time;
}
return MathUtils.round(time, this.filterService.getTimeDisplayPrecision());
}

Expand Down
4 changes: 1 addition & 3 deletions src/app/perlenkette/perlenkette.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
>
<ng-container *ngIf="showTrainrunName()">
<p class="alignleft trainname" (click)="trainrunNameClicked($event)">
<span class="trainname"
>{{ perlenketteTrainrun.categoryShortName }}{{ perlenketteTrainrun.title }}</span
>
<span class="trainname">{{ perlenketteTrainrun.title }}</span>
</p>

<span class="trainrun-od alignright" (click)="trainrunNameClicked($event)">
Expand Down
40 changes: 32 additions & 8 deletions src/app/services/data/trainrun-section-times.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,21 +422,38 @@ export class TrainrunSectionTimesService {
this.initialLeftAndRightElement === LeftAndRightElement.LeftRightTrainrunName
) {
this.timeStructure.leftDepartureTime =
(this.timeStructure.leftDepartureTime + this.offset) % 60;
this.timeStructure.leftDepartureTime === null
? null
: (this.timeStructure.leftDepartureTime + this.offset) % 60;
this.timeStructure.rightArrivalTime =
(this.timeStructure.rightArrivalTime + this.offset) % 60;
this.timeStructure.rightArrivalTime === null
? null
: (this.timeStructure.rightArrivalTime + this.offset) % 60;
this.timeStructure.leftArrivalTime =
(maxMinutes + this.timeStructure.leftArrivalTime - this.offset) % 60;
this.timeStructure.leftArrivalTime === null
? null
: (maxMinutes + this.timeStructure.leftArrivalTime - this.offset) % 60;
this.timeStructure.rightDepartureTime =
(maxMinutes + this.timeStructure.rightDepartureTime - this.offset) % 60;
this.timeStructure.rightDepartureTime === null
? null
: (maxMinutes + this.timeStructure.rightDepartureTime - this.offset) % 60;
} else {
this.timeStructure.leftDepartureTime =
(maxMinutes + this.timeStructure.leftDepartureTime - this.offset) % 60;
this.timeStructure.leftDepartureTime === null
? null
: (maxMinutes + this.timeStructure.leftDepartureTime - this.offset) % 60;
this.timeStructure.rightArrivalTime =
(maxMinutes + this.timeStructure.rightArrivalTime - this.offset) % 60;
this.timeStructure.leftArrivalTime = (this.timeStructure.leftArrivalTime + this.offset) % 60;
this.timeStructure.rightArrivalTime === null
? null
: (maxMinutes + this.timeStructure.rightArrivalTime - this.offset) % 60;
this.timeStructure.leftArrivalTime =
this.timeStructure.leftArrivalTime === null
? null
: (this.timeStructure.leftArrivalTime + this.offset) % 60;
this.timeStructure.rightDepartureTime =
(this.timeStructure.rightDepartureTime + this.offset) % 60;
this.timeStructure.rightDepartureTime === null
? null
: (this.timeStructure.rightDepartureTime + this.offset) % 60;
}
this.offsetTransformationActive = true;
this.fixAllTimesPrecision();
Expand Down Expand Up @@ -495,6 +512,13 @@ export class TrainrunSectionTimesService {
this.timeStructure.travelTime,
timeDisplayPrecision,
);
// Populate travel time here, otherwise it'll be up to
// setTimeStructureToTrainrunSections() and it may overwrite values entered
// by the user
const minTravelTime = 1.0 / Math.pow(10, this.filterService.getTimeDisplayPrecision());
if (this.timeStructure.travelTime < 0.1) {
this.timeStructure.travelTime = 0.1;
}
}

private fixAllTimesPrecision() {
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/data/trainrunsection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ export class TrainrunSectionService implements OnDestroy {
const newTotalTravelTime = timeStructure.travelTime;

const oldTotalTravelTime = this.trainrunService.getCumulativeTravelTime(trainrunSection);
const travelTimeFactor = newTotalTravelTime / oldTotalTravelTime;
const travelTimeFactor = newTotalTravelTime / (oldTotalTravelTime || 1);

// prepare data structure for the first trainrunsection
const bothLastNonStopNodes = this.trainrunService.getBothLastNonStopNodes(trainrunSection);
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/ui/ui.interaction.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
this.loadUserSettingFromLocalStorage();
if (this.activeTheme === null) {
// detect at initialization
if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
if (false && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {

Check failure on line 226 in src/app/services/ui/ui.interaction.service.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected constant condition
this.setActiveTheme(new ThemeFachDark(), false);
} else {
this.setActiveTheme(new ThemeFach(), false);
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/util/trainrunsection.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ export class TrainrunsectionHelper {
leftArrivalTime: lastLeftNode.getArrivalTime(leftTrainrunSection),
rightDepartureTime: lastRightNode.getDepartureTime(rightTrainrunSection),
rightArrivalTime: lastRightNode.getArrivalTime(rightTrainrunSection),
travelTime: cumulativeTravelTime,
travelTime: cumulativeTravelTime || null,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ export class TrainRunSectionComponent implements OnDestroy, UpdateCounterHandler
}

getText(): string {
return this.trainrun.categoryShortName + this.trainrun.title;
return this.trainrun.title;
}

textWidth(): number {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
></sbb-icon>
<div class="TrainrunTabGrupe">
<sbb-tab-group [selectedIndex]="data.type">
<sbb-tab
label="{{ selectedTrainrun.getCategoryShortName() }}{{ selectedTrainrun.getTitle() }}"
id="trainrun-tab"
>
<sbb-tab label="{{ selectedTrainrun.getTitle() }}" id="trainrun-tab">
<sbb-trainrun-tab
[trainrunDialogParameter]="trainrunDialogParameter"
(trainrunDeleted)="closeDialog()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
[title]="
'app.view.dialogs.trainrun-and-section-dialog.trainrun-tab.trainrunDuplicate' | translate
"
*ngIf="false"
>
<sbb-icon svgIcon="plus-medium" aria-hidden="false"></sbb-icon>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</button>
</div>
</div>
<div class="column" style="float: left; width: 150px">
<div class="column" style="float: left; width: 150px" *ngIf="false">
<sbb-label>{{
"app.view.dialogs.trainrun-and-section-dialog.trainrun-tab.verkehrt" | translate
}}</sbb-label>
Expand All @@ -74,6 +74,7 @@
[title]="
'app.view.dialogs.trainrun-and-section-dialog.trainrun-tab.trainrunDuplicate' | translate
"
*ngIf="false"
>
<sbb-icon svgIcon="plus-medium" aria-hidden="false"></sbb-icon>
</button>
Expand Down
Loading
Loading