Skip to content

Commit

Permalink
Merge pull request #4 from EnessenE/featrue/gtfs-testing
Browse files Browse the repository at this point in the history
GTFS related changes for testing
  • Loading branch information
EnessenE authored Mar 8, 2024
2 parents 1fa4ae2 + 6381ad5 commit 2be8975
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/app/comps/disruption/disruption.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ <h5 class="mb-1">{{ disruption.title }}</h5>
<small>Geen {{ disruption.source }} advies</small>
}
</div>

<small class="text-body-secondary">{{ disruption.source }}</small>
<!-- <div class="col-12">
@for (stops of disruption.affectedStops; track stops) {
<small class="text-body-secondary">{{ stops }}, </small>
Expand Down
1 change: 1 addition & 0 deletions src/app/comps/stop/stop.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ stop.name }}
Empty file.
23 changes: 23 additions & 0 deletions src/app/comps/stop/stop.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { StopComponent } from './stop.component';

describe('StopComponent', () => {
let component: StopComponent;
let fixture: ComponentFixture<StopComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [StopComponent]
})
.compileComponents();

fixture = TestBed.createComponent(StopComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
14 changes: 14 additions & 0 deletions src/app/comps/stop/stop.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Component, Input, input } from '@angular/core';
import { SimplifiedStop } from '../../models/simplified-stop';

@Component({
selector: 'app-stop',
standalone: true,
imports: [],
templateUrl: './stop.component.html',
styleUrl: './stop.component.scss',
})
export class StopComponent {
@Input()
stop!: SimplifiedStop;
}
15 changes: 11 additions & 4 deletions src/app/comps/travel-advice/travel-advice.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,21 @@ <h6 class="mb-1">
@if (routePart.alternativeTransport) {
<span
style="color: brown"
ngbTooltip="Dit stuk maakt gebruik van alternatief transport"
>>{{ routePart.type }}></span
ngbTooltip="Dit stuk maakt gebruik van alternatief transport door {{ routePart.operator }}"
>>{{routePart.operator}} {{ routePart.type }} [{{ routePart.lineName }}]{{ routePart.direction }}></span
>
} @else if (routePart.type == 'Unknown') {
<span
style="color: brown"
ngbTooltip="Een reis met onbekend transport [{{ routePart.lineName }}] ({{ routePart.type }}) richting {{routePart.direction}} door {{ routePart.operator }}"
>>[{{ routePart.lineName }}]{{ routePart.direction }}></span
>
} @else {
<span
role="img"
aria-label="Reis met trein"
ngbTooltip="Een reis met de trein ({{routePart.type}})"
>>🚆></span
ngbTooltip="Een reis met [{{ routePart.lineName }}] ({{ routePart.type }}) richting {{routePart.direction}} door {{ routePart.operator }}"
>> {{ routePart.direction }}🚆></span
>
}

Expand Down Expand Up @@ -127,4 +133,5 @@ <h6 class="mb-1">
}
</small>
</div>
<small>{{ travelAdvice.source }}</small>
</div>
4 changes: 2 additions & 2 deletions src/app/comps/travel-advice/travel-advice.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Component, Input, input } from '@angular/core';
import { TravelAdvice } from '../../models/journey-result';
import { DatePipe } from '@angular/common';
import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap';
import { NgbAccordionModule, NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap';

@Component({
selector: 'app-travel-advice',
standalone: true,
imports: [DatePipe, NgbTooltipModule],
imports: [DatePipe, NgbTooltipModule, NgbAccordionModule],
templateUrl: './travel-advice.component.html',
styleUrl: './travel-advice.component.scss',
})
Expand Down
8 changes: 6 additions & 2 deletions src/app/models/journey-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ export interface JourneyResult {
export interface TravelAdvice {
source: DataSource
realistic: boolean
route: Route[]
route: RoutePart[]
plannedDurationInMinutes: number
actualDurationInMinutes: number
}

export interface Route {
export interface RoutePart {
departureStation: string;
arrivalStation: string;

Expand All @@ -47,5 +47,9 @@ export interface JourneyResult {

actualArrivalTrack: string;
actualDepartureTrack: string;

direction: string;
lineName: string;
operator: string;
}

7 changes: 7 additions & 0 deletions src/app/models/simplified-stop.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { SimplifiedStop } from './simplified-stop';

describe('SimplifiedStop', () => {
it('should create an instance', () => {
expect(new SimplifiedStop()).toBeTruthy();
});
});
5 changes: 5 additions & 0 deletions src/app/models/simplified-stop.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class SimplifiedStop {
ids!: Map<string, string[]>
codes!: Map<string, string[]>
name!: string
}
4 changes: 2 additions & 2 deletions src/app/pages/main/main.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h1>Iets ging fout!</h1>
class="dropdown-item"
(click)="selectStopOrigin(stop)"
>
{{ stop }}
<app-stop [stop]="stop"></app-stop>
</button>
} @empty {
@if (foundStopsOrigin !== undefined) {
Expand Down Expand Up @@ -61,7 +61,7 @@ <h1>Iets ging fout!</h1>
class="dropdown-item"
(click)="selectStopDestination(stop)"
>
{{ stop }}
<app-stop [stop]="stop"></app-stop>
</button>
} @empty {
@if (foundStopsDestination !== undefined) {
Expand Down
18 changes: 10 additions & 8 deletions src/app/pages/main/main.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ import { JourneyResult } from '../../models/journey-result';
import { DatePipe } from '@angular/common';
import { ErrorComponent } from '../../comps/error/error.component';
import { HttpErrorResponse } from '@angular/common/http';
import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap';
import { NgbAccordionModule, NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap';
import { DisruptionComponent } from '../../comps/disruption/disruption.component';
import { TravelAdviceComponent } from '../../comps/travel-advice/travel-advice.component';
import { StopComponent } from '../../comps/stop/stop.component';
import { SimplifiedStop } from '../../models/simplified-stop';

@Component({
selector: 'app-main',
standalone: true,
imports: [DatePipe, ErrorComponent, NgbTooltipModule, DisruptionComponent, TravelAdviceComponent],
imports: [DatePipe, ErrorComponent, NgbTooltipModule, DisruptionComponent, TravelAdviceComponent, NgbAccordionModule, StopComponent],
templateUrl: './main.component.html',
styleUrl: './main.component.scss',
})
export class MainComponent implements OnInit {
foundStopsDestination: string[] | undefined;
foundStopsOrigin: string[] | undefined;
foundStopsDestination: SimplifiedStop[] | undefined;
foundStopsOrigin: SimplifiedStop[] | undefined;
originStop: string = 'Amsterdam Centraal';
destinationStop: string = 'Eindhoven Centraal';
possibility: JourneyResult | undefined;
Expand Down Expand Up @@ -60,14 +62,14 @@ export class MainComponent implements OnInit {
});
}

selectStopOrigin(value: string) {
this.originStop = value;
selectStopOrigin(value: SimplifiedStop) {
this.originStop = value.name;
this.foundStopsOrigin = undefined;
this.checkPossibility();
}

selectStopDestination(value: string) {
this.destinationStop = value;
selectStopDestination(value: SimplifiedStop) {
this.destinationStop = value.name;
this.foundStopsDestination = undefined;
this.checkPossibility();
}
Expand Down
5 changes: 3 additions & 2 deletions src/app/services/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { environment } from '../../environments/environment';
import { JourneyResult } from '../models/journey-result';
import { SimplifiedStop } from '../models/simplified-stop';

@Injectable({
providedIn: 'root',
})
export class ApiService {
constructor(private http: HttpClient) {}

GetStops(text: string): Observable<Array<string>> {
GetStops(text: string): Observable<Array<SimplifiedStop>> {
if (!(text.length > 0)) {
text = 'Amsterdam';
}

return this.http.get<Array<string>>(
return this.http.get<Array<SimplifiedStop>>(
environment.apiServer + '/v1/stops/search?filter=' + text
);
}
Expand Down

0 comments on commit 2be8975

Please sign in to comment.