-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial timetable creator and frequency pattern creator for desktop c…
…lient
- Loading branch information
Showing
8 changed files
with
209 additions
and
1 deletion.
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
6 changes: 6 additions & 0 deletions
6
desktop/src/app/timetablecreator/timetablecreator.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,6 @@ | ||
/* CSS options for the timetable creator component */ | ||
.center-button { | ||
text-align: center; | ||
padding-top: 10px; | ||
margin-top: 25px; | ||
} |
84 changes: 84 additions & 0 deletions
84
desktop/src/app/timetablecreator/timetablecreator.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,84 @@ | ||
<!-- Show the header --> | ||
<app-header></app-header> | ||
|
||
<!-- Jumbotron with page title --> | ||
<div class="jumbotron"> | ||
<h1 class="display-4 text-center">Create New Timetable for Route {{getRouteNumber()}}</h1> | ||
</div> | ||
|
||
<!-- Show an input box where the user can enter a name for this timetable. --> | ||
<div class="form-group top-space m-5"> | ||
<label for="timetableName" style="font-weight: bold;">Timetable Name:</label> | ||
<input class="form-control" [(ngModel)]="timetableName" type="text" id="timetableName"/> | ||
</div> | ||
|
||
<!-- Show an input box where the user can choose the valid from date --> | ||
<div class="form-group top-space m-5"> | ||
<label for="validFromDate" style="font-weight: bold;">Valid From:</label> | ||
<input class="form-control" [(ngModel)]="validFromDate" type="date" id="validFromDate"/> | ||
</div> | ||
|
||
<!-- Show an input box where the user can choose the valid to date --> | ||
<div class="form-group top-space m-5"> | ||
<label for="validToDate" style="font-weight: bold;">Valid To:</label> | ||
<input class="form-control" [(ngModel)]="validToDate" type="date" id="validToDate"/> | ||
</div> | ||
|
||
<!-- Button to open the frequency pattern modal --> | ||
<div class="center-button"> | ||
<button type="button" class="btn btn-primary btn-lg" data-bs-toggle="modal" data-bs-target="#frequencyPatternModal"> | ||
Create Frequency Pattern | ||
</button> | ||
</div> | ||
|
||
<!-- Modal --> | ||
<div class="modal fade" id="frequencyPatternModal" tabindex="-1" aria-labelledby="frequencyPatternModalLabel" aria-hidden="true"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title" id="exampleModalLabel">Create Frequency Pattern</h5> | ||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> | ||
</div> | ||
<div class="modal-body"> | ||
<!-- Show an input box where the user can enter a name for this frequency pattern. --> | ||
<div class="form-group top-space m-2"> | ||
<label for="frequencyPatternName" style="font-weight: bold;">Name:</label> | ||
<input class="form-control" [(ngModel)]="frequencyPatternName" type="text" id="frequencyPatternName"/> | ||
</div> | ||
|
||
<!-- Show a set of checkboxes so that the user can choose the days of operation --> | ||
<div class="form-group top-space m-2"> | ||
<label style="font-weight: bold;">Days of Operation:</label> | ||
<div class="col" *ngFor="let item of this.getDaysOfWeek() let i = index" > | ||
<input class="checkbox" type="checkbox" [id]="'checkbox-' + i"> {{item.split(':')[0]}} | ||
</div> | ||
</div> | ||
|
||
<div class="form-group top-space m-2"> | ||
<div class="row"> | ||
<div class="col"> | ||
From: <select class="form-control" [(ngModel)]="frequencyPatternStartStop" id="frequencyPatternStartStop"> | ||
<option *ngFor="let item of this.getFrequencyPatternStartStops()" [ngValue]="item">{{ item }}</option> | ||
</select> | ||
</div> | ||
<div class="col"> | ||
To: <select class="form-control" [(ngModel)]="frequencyPatternEndStop" id="frequencyPatternEndStop"> | ||
<option *ngFor="let item of this.getFrequencyPatternEndStops()" [ngValue]="item">{{ item }}</option> | ||
</select> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> | ||
<button type="button" class="btn btn-primary">Save changes</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<!-- Button to save the timetable --> | ||
<div class="center-button"> | ||
<button type="submit" (click)="onSubmitTimetable()" class="btn btn-primary btn-lg">Save Timetable</button> | ||
</div> |
21 changes: 21 additions & 0 deletions
21
desktop/src/app/timetablecreator/timetablecreator.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,21 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { TimetablecreatorComponent } from './timetablecreator.component'; | ||
|
||
describe('TimetablecreatorComponent', () => { | ||
let component: TimetablecreatorComponent; | ||
let fixture: ComponentFixture<TimetablecreatorComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [TimetablecreatorComponent] | ||
}); | ||
fixture = TestBed.createComponent(TimetablecreatorComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
78 changes: 78 additions & 0 deletions
78
desktop/src/app/timetablecreator/timetablecreator.component.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,78 @@ | ||
import { Component } from '@angular/core'; | ||
import {ActivatedRoute, Router} from "@angular/router"; | ||
import {GameService} from "../shared/game.service"; | ||
import {DatePipe} from "@angular/common"; | ||
|
||
@Component({ | ||
selector: 'app-timetablecreator', | ||
templateUrl: './timetablecreator.component.html', | ||
styleUrls: ['./timetablecreator.component.css'] | ||
}) | ||
export class TimetablecreatorComponent { | ||
|
||
routeNumber: string; | ||
timetableName: string; | ||
validFromDate: string; | ||
validToDate: string; | ||
gameService: GameService; | ||
|
||
frequencyPatternName: string; | ||
frequencyPatternStartStop: string; | ||
frequencyPatternEndStop: string; | ||
|
||
constructor(private route: ActivatedRoute, private gameService2: GameService, | ||
public router: Router, private datePipe: DatePipe) { | ||
this.gameService = gameService2; | ||
// Valid from date is current date. | ||
this.validFromDate = this.datePipe.transform(new Date(), 'yyyy-MM-dd'); | ||
// Valid to date is current date + 1 year. | ||
let oneFromYearNow = new Date(new Date().setFullYear(new Date().getFullYear() + 1)); | ||
this.validToDate = this.datePipe.transform(oneFromYearNow, 'yyyy-MM-dd'); | ||
} | ||
|
||
/** | ||
* Copy parameters from last request so that we do not lose the information that the user has provided. | ||
*/ | ||
ngOnInit(): void { | ||
this.route.queryParams | ||
.subscribe(params => { | ||
this.routeNumber = params.routeNumber; | ||
} | ||
); | ||
} | ||
|
||
getRouteNumber(): string { | ||
return this.routeNumber; | ||
} | ||
|
||
getDaysOfWeek(): string[] { | ||
return ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] | ||
} | ||
|
||
getFrequencyPatternStartStops(): string[] { | ||
let possibleStops = []; | ||
let route = this.gameService.getGame().getRoute(this.routeNumber); | ||
if ( !this.frequencyPatternStartStop ) { | ||
this.frequencyPatternStartStop = route.startStop; | ||
} | ||
possibleStops.push(route.startStop); | ||
possibleStops = possibleStops.concat(route.stops); | ||
return possibleStops; | ||
} | ||
|
||
getFrequencyPatternEndStops(): string[] { | ||
let possibleStops = []; | ||
let route = this.gameService.getGame().getRoute(this.routeNumber); | ||
if ( !this.frequencyPatternEndStop ) { | ||
this.frequencyPatternEndStop = route.endStop; | ||
} | ||
possibleStops.push(route.endStop); | ||
possibleStops = possibleStops.concat(route.stops); | ||
return possibleStops; | ||
} | ||
|
||
onSubmitTimetable(): void { | ||
console.log('Timetable submission coming soon!'); | ||
} | ||
|
||
} |