-
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.
Add drivers detail screen in desktop client
- Loading branch information
Showing
5 changed files
with
79 additions
and
2 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
1 change: 1 addition & 0 deletions
1
desktop/src/app/drivers/driver-detail/driver-detail.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 @@ | ||
/* CSS options for the driver detail component */ |
16 changes: 16 additions & 0 deletions
16
desktop/src/app/drivers/driver-detail/driver-detail.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,16 @@ | ||
<br/><br/> | ||
|
||
<div class="row"> | ||
|
||
<div class="col"> | ||
<!-- Show the name --> | ||
<h3 class="text-center">Name: {{driver.name}}</h3> | ||
<!-- Show the contracted hours --> | ||
<h3 class="text-center">Contracted Hours: {{driver.contractedHours}}</h3> | ||
<!-- Show the start date --> | ||
<h3 class="text-center">Start Date: {{driver.startDate}}</h3> | ||
</div> | ||
</div> | ||
<div class="col text-center"> | ||
<button class="btn btn-primary btn-lg" style="margin: 10px;" type="submit" (click)="sackDriver(driver)">Sack Driver</button> | ||
</div> |
55 changes: 55 additions & 0 deletions
55
desktop/src/app/drivers/driver-detail/driver-detail.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,55 @@ | ||
import {Component, OnDestroy, OnInit} from '@angular/core'; | ||
import {ActivatedRoute, Params} from "@angular/router"; | ||
import {GameService} from "../../shared/game.service"; | ||
import {Driver} from "../driver.model"; | ||
import {Subscription} from "rxjs"; | ||
|
||
@Component({ | ||
selector: 'app-driver-detail', | ||
templateUrl: './driver-detail.component.html', | ||
styleUrls: ['./driver-detail.component.css'] | ||
}) | ||
/** | ||
* This class implements the functionality for the driver-detail component which retrieves detailed driver information and | ||
* sends it to the frontend component for rendering. | ||
*/ | ||
export class DriverDetailComponent implements OnInit, OnDestroy { | ||
|
||
driver: Driver; | ||
id: number; | ||
idSubscription: Subscription; | ||
|
||
/** | ||
* Construct a new driver-detail component based on the supplied information. | ||
* @param gameService a service which can retrieve game information | ||
* @param route a variable which contains the current driver that the user clicked on. | ||
*/ | ||
constructor(private route: ActivatedRoute, private gameService: GameService) { } | ||
|
||
/** | ||
* Initialise the vehicle information during construction and ensure all variables are set to the correct data. | ||
*/ | ||
ngOnInit(): void { | ||
this.idSubscription = this.route.params.subscribe((params: Params) => { | ||
this.id = +params['id']; | ||
this.driver = this.gameService.getGame().drivers[this.id]; | ||
}); | ||
} | ||
|
||
/** | ||
* When destroying this component we have nothing to do so far. | ||
*/ | ||
ngOnDestroy(): void { | ||
} | ||
|
||
sackDriver(driver: Driver): void { | ||
var allDrivers = this.gameService.getGame().drivers; | ||
for ( var i = 0; i < allDrivers.length; i++ ) { | ||
if ( this.gameService.getGame().drivers[i].name.valueOf() === driver.name.valueOf() ) { | ||
this.gameService.getGame().drivers.splice(i, 1); | ||
} | ||
} | ||
console.log('Currently the length of drivers is: ' + this.gameService.getGame().drivers.length ) | ||
} | ||
|
||
} |