-
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.
Form to add allocations and page to view but backend model for alloca…
…tions still missing.
- Loading branch information
Showing
14 changed files
with
249 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* CSS options for the allocation component */ | ||
.center-button { | ||
text-align: center; | ||
padding-top: 10px; | ||
} |
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,41 @@ | ||
<!-- Show the header --> | ||
<app-header></app-header> | ||
|
||
<!-- Jumbotron with page title --> | ||
<div class="jumbotron"> | ||
<h1 class="display-4 text-center">Allocate Vehicle</h1> | ||
</div> | ||
|
||
<!-- Show an input box where the user can choose the route number --> | ||
<div class="form-group top-space m-5"> | ||
<label for="routeNumberList" style="font-weight: bold;">Route Number:</label> | ||
<select class="form-control" [(ngModel)]="selectedRouteNumber" id="routeNumberList"> | ||
<option *ngFor="let item of this.getDefinedRouteNumbers()" [ngValue]="item">{{ item }}</option> | ||
</select> | ||
</div> | ||
|
||
<!-- Show an input box where the user can choose the fleet number --> | ||
<div class="form-group top-space m-5"> | ||
<label for="fleetNumberList" style="font-weight: bold;">Fleet Number:</label> | ||
<select class="form-control" [(ngModel)]="selectedFleetNumber" id="fleetNumberList"> | ||
<option *ngFor="let item of this.getDefinedFleetNumbers()" [ngValue]="item">{{ item }}</option> | ||
</select> | ||
</div> | ||
|
||
<!-- Show an input box where the user can choose the tour number --> | ||
<div class="form-group top-space m-5"> | ||
<label for="tourNumberList" style="font-weight: bold;">Tour Number:</label> | ||
<select class="form-control" [(ngModel)]="selectedTourNumber" id="tourNumberList"> | ||
<option *ngFor="let item of this.getDefinedTourNumbers()" [ngValue]="item">{{ item }}</option> | ||
</select> | ||
</div> | ||
|
||
<!-- Submit button --> | ||
<div class="center-button"> | ||
<button type="submit" (click)="onSaveAllocation()" class="btn btn-primary btn-lg">Save Allocation</button> | ||
</div> | ||
|
||
<!-- Back to Management Screen button --> | ||
<div class="center-button"> | ||
<button class="btn btn-primary btn-lg" style="margin: 10px;" type="submit" (click)="backToManagementScreen()">Back to Management Screen</button> | ||
</div> |
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 { AllocationsComponent } from './allocations.component'; | ||
|
||
describe('AllocationsComponent', () => { | ||
let component: AllocationsComponent; | ||
let fixture: ComponentFixture<AllocationsComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [AllocationsComponent] | ||
}); | ||
fixture = TestBed.createComponent(AllocationsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
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,95 @@ | ||
import { Component } from '@angular/core'; | ||
import {GameService} from "../shared/game.service"; | ||
import {Router} from "@angular/router"; | ||
import {Route} from "../routes/route.model"; | ||
|
||
@Component({ | ||
selector: 'app-allocations', | ||
templateUrl: './allocations.component.html', | ||
styleUrls: ['./allocations.component.css'] | ||
}) | ||
export class AllocationsComponent { | ||
|
||
gameService: GameService; | ||
selectedRouteNumber: string; | ||
selectedFleetNumber: string; | ||
selectedTourNumber: string; | ||
|
||
/** | ||
* Construct a new Allocations component | ||
* @param gameService2 the game service containing the currently loaded game. | ||
* @param router the router for navigating to other pages. | ||
*/ | ||
constructor(private gameService2: GameService, public router: Router) { | ||
this.gameService = gameService2; | ||
if ( this.gameService.getGame().routes.length > 0 ) { | ||
this.selectedRouteNumber = this.gameService.getGame().routes[0].routeNumber; | ||
} | ||
if ( this.gameService.getGame().vehicles.length > 0 ) { | ||
this.selectedFleetNumber = this.gameService.getGame().vehicles[0].fleetNumber; | ||
} | ||
this.selectedTourNumber = "1"; | ||
} | ||
|
||
/** | ||
* Retrieve the list of defined route numbers. | ||
*/ | ||
getDefinedRouteNumbers(): string[] { | ||
var routeNumbers = []; | ||
for ( var i = 0; i < this.gameService.getGame().routes.length; i++ ) { | ||
routeNumbers[i] = this.gameService.getGame().routes[i].routeNumber; | ||
} | ||
return routeNumbers; | ||
} | ||
|
||
/** | ||
* Retrieve the list of defined fleet numbers. | ||
*/ | ||
getDefinedFleetNumbers(): string[] { | ||
var fleetNumbers = []; | ||
for ( var i = 0; i < this.gameService.getGame().vehicles.length; i++ ) { | ||
fleetNumbers[i] = this.gameService.getGame().vehicles[i].fleetNumber; | ||
} | ||
return fleetNumbers; | ||
} | ||
|
||
/** | ||
* Retrieve the list of defined tour numbers for the selected route. | ||
*/ | ||
getDefinedTourNumbers(): string[] { | ||
if ( this.selectedRouteNumber ) { | ||
var selectedRouteObject: Route; | ||
for ( var j = 0; j < this.gameService.getGame().routes.length; j++ ) { | ||
if ( this.selectedRouteNumber == this.gameService.getGame().routes[j].routeNumber ) { | ||
selectedRouteObject = this.gameService.getGame().routes[j]; | ||
break; | ||
} | ||
} | ||
if ( selectedRouteObject ) { | ||
// We take the first timetable at the moment. | ||
if ( selectedRouteObject.timetables.length > 0 && selectedRouteObject.timetables[0].frequencyPatterns.length > 0 ) { | ||
var tours = []; | ||
for (var k = 0; k < selectedRouteObject.timetables[0].frequencyPatterns[0].numTours; k++) { | ||
tours.push((k + 1)); | ||
} | ||
return tours; | ||
} | ||
return []; | ||
} else { | ||
return []; | ||
} | ||
} else { | ||
return []; | ||
} | ||
} | ||
|
||
onSaveAllocation(): void { | ||
alert('I want to use vehicle ' + this.selectedFleetNumber + ' for ' + this.selectedRouteNumber + '/' + this.selectedTourNumber); | ||
this.router.navigate(['management']); | ||
} | ||
|
||
backToManagementScreen(): void { | ||
this.router.navigate(['management']); | ||
} | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
desktop/src/app/allocationslist/allocationslist.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,5 @@ | ||
/* CSS options for the allocation component */ | ||
.center-button { | ||
text-align: center; | ||
padding-top: 10px; | ||
} |
14 changes: 14 additions & 0 deletions
14
desktop/src/app/allocationslist/allocationslist.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,14 @@ | ||
<!-- Show the header --> | ||
<app-header></app-header> | ||
|
||
<!-- Jumbotron with page title --> | ||
<div class="jumbotron"> | ||
<h1 class="display-4 text-center">Vehicle Allocations</h1> | ||
</div> | ||
|
||
<h1>Coming Soon!</h1> | ||
|
||
<!-- Back to Management Screen button --> | ||
<div class="center-button"> | ||
<button class="btn btn-primary btn-lg" style="margin: 10px;" type="submit" (click)="backToManagementScreen()">Back to Management Screen</button> | ||
</div> |
21 changes: 21 additions & 0 deletions
21
desktop/src/app/allocationslist/allocationslist.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 { AllocationslistComponent } from './allocationslist.component'; | ||
|
||
describe('AllocationslistComponent', () => { | ||
let component: AllocationslistComponent; | ||
let fixture: ComponentFixture<AllocationslistComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [AllocationslistComponent] | ||
}); | ||
fixture = TestBed.createComponent(AllocationslistComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
27 changes: 27 additions & 0 deletions
27
desktop/src/app/allocationslist/allocationslist.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,27 @@ | ||
import { Component } from '@angular/core'; | ||
import {GameService} from "../shared/game.service"; | ||
import {Router} from "@angular/router"; | ||
|
||
@Component({ | ||
selector: 'app-allocationslist', | ||
templateUrl: './allocationslist.component.html', | ||
styleUrls: ['./allocationslist.component.css'] | ||
}) | ||
export class AllocationslistComponent { | ||
|
||
gameService: GameService; | ||
|
||
/** | ||
* Construct a new Allocations list component | ||
* @param gameService2 the game service containing the currently loaded game. | ||
* @param router the router for navigating to other pages. | ||
*/ | ||
constructor(private gameService2: GameService, public router: Router) { | ||
this.gameService = gameService2; | ||
} | ||
|
||
backToManagementScreen(): void { | ||
this.router.navigate(['management']); | ||
} | ||
|
||
} |
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
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