-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
London Tube Departure Display (#290)
* Added basic ui structure for tubes * Improved mobile formatting * Further work on new tube api * Added tube api calls * Fix mobile center container * Added tube searching * Fix missing schema file --------- Co-authored-by: benfl3713 <buses3713@gmail.com>
- Loading branch information
1 parent
a6ca3c3
commit 518a393
Showing
30 changed files
with
1,226 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text.Json; | ||
using RestSharp; | ||
|
||
namespace DepartureBoardCore.DataSource; | ||
|
||
public class TflBase | ||
{ | ||
protected readonly RestClient _client = new RestClient("https://api.tfl.gov.uk"); | ||
protected static string AppKey => ConfigService.TflApiToken; | ||
protected JsonSerializerOptions SerializerOptions = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; | ||
protected RestResponse SendRequest(RestRequest request) | ||
{ | ||
request.AddQueryParameter("app_key", AppKey); | ||
return _client.Execute(request); | ||
} | ||
|
||
protected int? GetConvertedTimeToStation(int? timeInSeconds) | ||
{ | ||
if (!timeInSeconds.HasValue) | ||
return null; | ||
|
||
return Convert.ToInt32(Math.Ceiling(timeInSeconds.Value / 60m)); | ||
} | ||
|
||
public class TflStopPointResponse | ||
{ | ||
public List<StopPoint> StopPoints { get; set; } | ||
} | ||
|
||
public class StopPoint | ||
{ | ||
public string NaptanId { get; set; } | ||
public string StopType { get; set; } | ||
public string StationNaptan { get; set; } | ||
public string CommonName { get; set; } | ||
public string PlatformName { get; set; } | ||
public List<string> Modes { get; set; } | ||
public List<Line> Lines { get; set; } | ||
public List<LineModeGroup> LineModeGroups { get; set; } | ||
public List<StopPoint> Children { get; set; } | ||
|
||
public class Line | ||
{ | ||
public string Id { get; set; } | ||
public string Name { get; set; } | ||
} | ||
|
||
public class LineModeGroup | ||
{ | ||
public string ModeName { get; set; } | ||
public List<string> LineIdentifier { get; set; } | ||
} | ||
|
||
public bool IsHubStation() | ||
{ | ||
return StopType == "TransportInterchange"; | ||
} | ||
|
||
public List<StopPoint> GetChildTubeStopPoints() | ||
{ | ||
return Children?.Where(c => c.Modes.Contains("tube")).ToList() ?? new List<StopPoint>(); | ||
} | ||
} | ||
|
||
public class TflArrival | ||
{ | ||
public string StationName { get; set; } | ||
public string LineId { get; set; } | ||
public string LineName { get; set; } | ||
public string DestinationName { get; set; } | ||
public DateTime ExpectedArrival { get; set; } | ||
public string PlatformName { get; set; } | ||
public int? TimeToStation { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...b/ClientApp/src/app/Pages/london-tube/london-tube-search/london-tube-search.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#search-title { | ||
padding-bottom: 10px; | ||
} | ||
|
||
.container { | ||
border: 2px solid var(--mainColour); | ||
border-radius: 8px; | ||
color: var(--mainColour); | ||
padding: 20px; | ||
margin-top: 5px; | ||
} | ||
|
||
#btnSearch { | ||
background-color: var(--mainColour); | ||
color: black; | ||
margin-top: 5px; | ||
} | ||
|
||
#search-box { | ||
height: 90px; | ||
} | ||
|
||
form, | ||
mat-form-field, | ||
button { | ||
width: 100%; | ||
} | ||
|
||
/* input color class */ | ||
::ng-deep input.mat-input-element { | ||
color: var(--mainColour); | ||
} | ||
|
||
/* Change label color on focused */ | ||
::ng-deep .mat-form-field.mat-focused .mat-form-field-label { | ||
color: var(--mainColour) !important; | ||
} | ||
|
||
/* underline border color on focused */ | ||
::ng-deep .mat-focused .mat-form-field-underline .mat-form-field-ripple { | ||
background-color: var(--mainColour) !important; | ||
} | ||
|
||
.options mat-checkbox { | ||
padding-right: 10px; | ||
} |
42 changes: 42 additions & 0 deletions
42
.../ClientApp/src/app/Pages/london-tube/london-tube-search/london-tube-search.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<div class="container"> | ||
<h1 id="search-title" class="led centre-text clickable" style="padding-left: 10px" [routerLink]="['/search']"> | ||
Tube Search | ||
</h1> | ||
<form class="example-form"> | ||
<mat-form-field id="search-box"> | ||
<mat-icon matIconPrefix style="padding-bottom: 30px">search</mat-icon> | ||
<mat-label>Station Name</mat-label> | ||
<input id="search-input-box" type="text" placeholder="Ex. Baker" aria-label="station name" matInput | ||
[formControl]="searchBox" | ||
[matAutocomplete]="auto" (keyup)="keyPressed()" /> | ||
<mat-autocomplete autoActiveFirstOption #auto="matAutocomplete" [displayWith]="stationDisplay"> | ||
<mat-option *ngFor="let station of filteredOptions" [value]="station"> | ||
{{ station.name }} | ||
</mat-option> | ||
</mat-autocomplete> | ||
</mat-form-field> | ||
|
||
<div class="options" *ngIf="showSubSearchParams"> | ||
<mat-label>Optional filters</mat-label> | ||
<mat-form-field> | ||
<mat-label>Line</mat-label> | ||
<mat-select [formControl]="lineFilter"> | ||
<mat-option *ngFor="let line of stationInfo?.lines" [value]="line"> | ||
{{line.name}} | ||
</mat-option> | ||
</mat-select> | ||
</mat-form-field> | ||
|
||
<!-- <mat-form-field>--> | ||
<!-- <mat-label>Direction</mat-label>--> | ||
<!-- <mat-select>--> | ||
<!-- <mat-option *ngFor="let line of stationInfo?.lines" [value]="line">--> | ||
<!-- {{line.name}}--> | ||
<!-- </mat-option>--> | ||
<!-- </mat-select>--> | ||
<!-- </mat-form-field>--> | ||
</div> | ||
|
||
<button mat-button id="btnSearch" (click)="Search()">Search</button> | ||
</form> | ||
</div> |
23 changes: 23 additions & 0 deletions
23
...ientApp/src/app/Pages/london-tube/london-tube-search/london-tube-search.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { LondonTubeSearchComponent } from './london-tube-search.component'; | ||
|
||
describe('LondonTubeSearchComponent', () => { | ||
let component: LondonTubeSearchComponent; | ||
let fixture: ComponentFixture<LondonTubeSearchComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ LondonTubeSearchComponent ] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(LondonTubeSearchComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Oops, something went wrong.