Skip to content

Commit

Permalink
Cleaned up website files
Browse files Browse the repository at this point in the history
  • Loading branch information
jonafanho committed Oct 30, 2024
1 parent 9ae5964 commit 34cf84b
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 20 deletions.
10 changes: 5 additions & 5 deletions buildSrc/src/main/resources/website/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<app-side #sideDirections [onClose]="onCloseDirections">
<app-side #sideStation [onClose]="onCloseStation">
<app-side #sideDirections (closed)="onCloseDirections()">
<app-side #sideStation (closed)="onCloseStation()">
<app-side #sideMain>
<app-map (onClickStation)="onClickStation($event, sideStation, sideDirections, false)"/>
<app-map (stationClicked)="onClickStation($event, sideStation, sideDirections, false)"/>
<button mat-fab class="button-corner" color="" aria-label="Menu" (click)="sideMain.open()">
<mat-icon>menu</mat-icon>
</button>
<div sidenav class="column margin">
<app-search label="Search for anything..." [includeRoutes]="true" (onClickStation)="onClickStation($event, sideStation, sideDirections, true)"/>
<app-search label="Search for anything..." [includeRoutes]="true" (stationClicked)="onClickStation($event, sideStation, sideDirections, true)"/>
<app-panel/>
</div>
<div title>{{ getTitle() }}</div>
</app-side>
<app-station sidenav (onOpenDirections)="sideDirections.open()"/>
<app-station sidenav (directionsOpened)="sideDirections.open()"/>
<div title>Station Details</div>
</app-side>
<app-directions sidenav/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div>
@for (textLabel of textLabels; track $index) {
<div class="column center label" [style.transform]="'translate(-50%,0) translate(' + textLabel.x + 'px, ' + textLabel.y + 'px)'"
(mousedown)="onClickStation.emit(textLabel.id)"
(mousedown)="stationClicked.emit(textLabel.id)"
(mouseenter)="textLabel.hoverOverride = true"
(mouseleave)="textLabel.hoverOverride = false">
<div [style.width]="textLabel.stationWidth + 'px'" [style.height]="textLabel.stationHeight + 'px'"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const lineMaterialThin = new LineMaterial({color: 0xFFFFFF, linewidth: 3 * SETTI
styleUrls: ["./map.component.css"],
})
export class MapComponent implements AfterViewInit {
@Output() onClickStation = new EventEmitter<string>;
@Output() stationClicked = new EventEmitter<string>;
@ViewChild("wrapper") private readonly wrapperRef!: ElementRef<HTMLDivElement>;
@ViewChild("canvas") private readonly canvasRef!: ElementRef<HTMLCanvasElement>;
@ViewChild("stats") private readonly statsRef!: ElementRef<HTMLDivElement>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<mat-autocomplete #auto="matAutocomplete">
@for (station of searchedStations$ | async; track $index) {
<mat-option (click)="onClickStation.emit(station.id)">
<mat-option (click)="stationClicked.emit(station.id)">
<div class="row gap center">
<div class="station-color-dot" style="{{'background-color:#'+station.color}}"></div>
<div>{{ station.name | formatName }}</div>
Expand All @@ -16,7 +16,7 @@
<mat-divider/>
}
@for (route of searchedRoutes$ | async; track $index) {
<mat-option (click)="onClickRoute.emit(route.id)">
<mat-option (click)="routeClicked.emit(route.id)">
<div class="row gap center">
<div class="station-color-dot" style="{{'background-color:#'+route.color}}"></div>
<div>{{ route.name | formatName }}</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import {StationService} from "../../service/station.service";
styleUrl: "./search.component.css",
})
export class SearchComponent implements OnInit {
@Output() onClickStation = new EventEmitter<string>();
@Output() onClickRoute = new EventEmitter<string>();
@Output() stationClicked = new EventEmitter<string>();
@Output() routeClicked = new EventEmitter<string>();
@Input() label!: string;
@Input() includeRoutes!: boolean;
searchBox = new FormControl("");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, Input, ViewChild} from "@angular/core";
import {Component, EventEmitter, Output, ViewChild} from "@angular/core";
import {MapComponent} from "../map/map.component";
import {MatIconButton} from "@angular/material/button";
import {MatIcon} from "@angular/material/icon";
Expand All @@ -24,8 +24,7 @@ import {DirectionsService} from "../../service/directions.service";
})
export class SideComponent {
@ViewChild(MatSidenav) private readonly sidenav!: MatSidenav;
@Input() onClose: () => void = () => {
};
@Output() closed = new EventEmitter<void>;

constructor(private readonly stationService: StationService, private readonly directionsService: DirectionsService) {
}
Expand All @@ -40,6 +39,6 @@ export class SideComponent {

onCloseMenu() {
this.sidenav.close().then();
this.onClose();
this.closed.emit();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import {MatProgressSpinner} from "@angular/material/progress-spinner";
styleUrl: "./station.component.css",
})
export class StationComponent {
@Output() onOpenDirections = new EventEmitter<void>;
@Output() directionsOpened = new EventEmitter<void>;

constructor(private readonly stationService: StationService, private readonly dialog: MatDialog) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class DataService extends ServiceBase<{ currentTime: number, data: DataRe
};

constructor(private readonly httpClient: HttpClient, dimensionService: DimensionService) {
super(() => this.httpClient.get<{ currentTime: number, data: DataResponse }>(this.getUrl("map/stations-and-routes")), REFRESH_INTERVAL, dimensionService);
super(() => this.httpClient.get<{ currentTime: number, data: DataResponse }>(this.getUrl("stations-and-routes")), REFRESH_INTERVAL, dimensionService);
this.getData("");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class DirectionsService extends ServiceBase<{ data: { responseTime: numbe
constructor(private readonly httpClient: HttpClient, dimensionService: DimensionService) {
super(() => {
if (this.originStation && this.destinationStation) {
return this.httpClient.post<{ data: { responseTime: number, directionsSegments: DataResponse[] } }>(this.getUrl("operation/directions"), JSON.stringify({
return this.httpClient.post<{ data: { responseTime: number, directionsSegments: DataResponse[] } }>(this.getUrl("directions"), JSON.stringify({
startPosition: DirectionsService.stationPositionToObject(this.originStation),
endPosition: DirectionsService.stationPositionToObject(this.destinationStation),
maxWalkingDistance: 10000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export abstract class ServiceBase<T> {
}

protected getUrl(endpoint: string) {
return `${document.location.origin}${document.location.pathname.replace("index.html", "")}mtr/api/${endpoint}?dimension=${this.dimensionService.getDimensionIndex()}`;
return `${document.location.origin}${document.location.pathname}mtr/api/map/${endpoint}?dimension=${this.dimensionService.getDimensionIndex()}`;
}

public isLoading() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class StationService extends ServiceBase<{ data: { arrivals: DataResponse
constructor(private readonly httpClient: HttpClient, private readonly dataService: DataService, private readonly splitNamePipe: SplitNamePipe, dimensionService: DimensionService) {
super(() => {
if (this.selectedStation) {
return this.httpClient.post<{ data: { arrivals: DataResponse[] } }>(this.getUrl("map/arrivals"), JSON.stringify({
return this.httpClient.post<{ data: { arrivals: DataResponse[] } }>(this.getUrl("arrivals"), JSON.stringify({
stationIdsHex: [this.selectedStation.id],
maxCountPerPlatform: MAX_ARRIVALS,
}));
Expand Down

0 comments on commit 34cf84b

Please sign in to comment.