Skip to content

Commit

Permalink
implemented timetable endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuki_kamI_ committed May 3, 2024
1 parent c3b78f4 commit 0649507
Show file tree
Hide file tree
Showing 15 changed files with 2,750 additions and 183 deletions.
2,318 changes: 2,228 additions & 90 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,19 @@
"@angular/platform-browser": "^17.3.0",
"@angular/platform-browser-dynamic": "^17.3.0",
"@angular/router": "^17.3.0",
"component": "^1.1.0",
"cors": "^2.8.5",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"xml2js": "^0.6.2",
"zone.js": "~0.14.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "^17.3.6",
"@angular/cli": "^17.3.6",
"@angular/compiler-cli": "^17.3.0",
"@types/jasmine": "~5.1.0",
"@types/xml2js": "^0.4.14",
"autoprefixer": "^10.4.19",
"jasmine-core": "~5.1.0",
"karma": "~6.4.0",
Expand All @@ -41,4 +44,4 @@
"tailwindcss": "^3.4.3",
"typescript": "~5.4.2"
}
}
}
7 changes: 5 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {NavbarComponent} from "./shared/navbar/navbar.component";
import {HeaderComponent} from "./shared/header/header.component";
import {FooterComponent} from "./shared/footer/footer.component";
import {CacheService} from "../services/cache.service";
import {TimetableComponent} from "./main/timetable/timetable.component";

export const routes: Routes = [
{path: 'home', component: HomeComponent},
Expand All @@ -42,7 +43,8 @@ export const routes: Routes = [
HomeComponent,
NavigationsComponent,
NavbarComponent,
FooterComponent
FooterComponent,
TimetableComponent
],
imports: [
HttpClientModule,
Expand Down Expand Up @@ -79,7 +81,8 @@ export const routes: Routes = [
HomeComponent,
NavigationsComponent,
NavbarComponent,
FooterComponent
FooterComponent,
TimetableComponent
],
schemas: [
CUSTOM_ELEMENTS_SCHEMA
Expand Down
2 changes: 1 addition & 1 deletion src/app/main/search/search.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Component, OnInit} from '@angular/core';
import {Router, ActivatedRoute} from '@angular/router';
import {DbService} from "../../../services/db.service";
import {Station} from "../../../models/resultModel";
import {Station} from "../../../models/result.StationData.Stations";
import {Subject} from 'rxjs';
import {debounceTime, distinctUntilChanged} from 'rxjs/operators';
import {typeCheckFilePath} from "@angular/compiler-cli/src/ngtsc/typecheck";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div class="container mx-auto px-4 w-full md:w-1/2 whitespace-nowrap" *ngIf="station">
<div class="flex items-center justify-center mt-10">
<div class="mb-4 bg-white rounded-lg p-4 shadow flex flex-col md:flex-row w-full">
<div class="flex flex-col w-full md:w-1/2" *ngIf="station.name">
<div class="font-bold text-xl mb-2">{{ station.name }}</div>
<div (click)="openTimeTablePage()" class="flex flex-col w-full md:w-1/2" *ngIf="station.name">
<div class="font-bold text-xl mb-2">{{ station.name }}</div>
<div class="text-gray-700 text-base"
*ngIf="station.evaNumbers && station.evaNumbers[0]">{{ station.evaNumbers[0].number }}
</div>
Expand Down
20 changes: 11 additions & 9 deletions src/app/main/search/station-detail/station-detail.component.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
import {Component, Input, OnInit} from '@angular/core';
import {Station} from '../../../../models/resultModel';
import {Station} from '../../../../models/result.StationData.Stations';
import {MatDialog} from '@angular/material/dialog';
import {IconExplanationDialogComponent} from "./icon-explanation-dialog/icon-explanation-dialog.component";
import {ConfigService} from "../../../../services/config.service";
import {join} from "@angular/compiler-cli";
import {
Explanation,
IconExplanationConfigModel,
Explanations,
ExplanationsModel
} from "../../../../models/iconExplanationConfigModel";
import {handleAutoChangeDetectionStatus} from "@angular/cdk/testing";
import {DbService} from "../../../../services/db.service";
import {
convertToModel,
Timetable
} from "../../../../models/result.TimeTable.Plan";


@Component({
selector: 'app-station-detail',
templateUrl: './station-detail.component.html',
styleUrls: ['./station-detail.component.css']
})
export class StationDetailComponent{
export class StationDetailComponent {
@Input() station: Station;
config: IconExplanationConfigModel;

constructor(
private dialog: MatDialog,
private dbService: DbService,
private configService: ConfigService) {
this.configService.fetchConfig("data/iconExplanations.json").subscribe(
(value: ExplanationsModel) => {
console.log(value);
this.config = new IconExplanationConfigModel(value);
}
);
Expand All @@ -49,9 +51,9 @@ export class StationDetailComponent{
color: color
}
})

}

protected readonly HashChangeEvent = HashChangeEvent;
protected readonly handleAutoChangeDetectionStatus = handleAutoChangeDetectionStatus;
openTimeTablePage() {

}
}
Empty file.
1 change: 1 addition & 0 deletions src/app/main/timetable/timetable.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>timetable works!</p>
23 changes: 23 additions & 0 deletions src/app/main/timetable/timetable.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 { TimetableComponent } from './timetable.component';

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

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

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

it('should create', () => {
expect(component).toBeTruthy();
});
});
37 changes: 37 additions & 0 deletions src/app/main/timetable/timetable.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {Component, Input} from '@angular/core';
import {convertToModel, Timetable} from "../../../models/result.TimeTable.Plan";
import {DbService} from "../../../services/db.service";
import {Station} from "../../../models/result.StationData.Stations";

@Component({
selector: 'app-timetable',
templateUrl: './timetable.component.html',
styleUrl: './timetable.component.css'
})
export class TimetableComponent {
@Input() station: Station;

constructor(
private dbService: DbService
) {
}

getTimeTable(station: Station) {
const now = new Date();
const year = now.getUTCFullYear().toString().slice(-2); // Get last two digits of year
const month = (now.getUTCMonth() + 1).toString().padStart(2, '0'); // Months are 0-indexed in JavaScript
const date = now.getUTCDate().toString().padStart(2, '0');
const hour = now.getUTCHours().toString().padStart(2, '0');
const formattedDate = year + month + date;
const formattedHour = hour;
this.dbService.getTimeTablesPlan(
station.evaNumbers[0].number.toString(),
formattedDate,
formattedHour,
true,
false)
.subscribe((value: any) => {
const timetable: Timetable = convertToModel(value?.data?.timetable);
});
}
}
File renamed without changes.
Loading

0 comments on commit 0649507

Please sign in to comment.