Skip to content

Commit

Permalink
Removed Math from consumed tank component
Browse files Browse the repository at this point in the history
  • Loading branch information
jirkapok committed Mar 22, 2024
1 parent bfe3fcb commit 4b2b72b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<small>
<fa-icon *ngIf="gasRemainingDifference > 0" [icon]="faArrowLeft" class="text-success"/>
<strong *ngIf="gasRemainingDifference != 0">
{{Math.abs(gasRemainingDifference) | number:'1.0-0' }}
{{ absoluteRemainingDifference | number:'1.0-0' }}
</strong>
<fa-icon *ngIf="gasRemainingDifference < 0" [icon]="faArrowRight" class="text-success"/>
<fa-icon *ngIf="gasRemainingDifference === 0" [icon]="faMinus"/>
Expand All @@ -41,7 +41,7 @@
<small>
<fa-icon *ngIf="gasReserveDifference > 0" [icon]="faArrowLeft" class="text-success"/>
<strong *ngIf="gasReserveDifference != 0">
{{Math.abs(gasReserveDifference) | number:'1.0-0' }}
{{ absoluteReserveDifference | number:'1.0-0' }}
</strong>
<fa-icon *ngIf="gasReserveDifference < 0" [icon]="faArrowRight" class="text-success"/>
<fa-icon *ngIf="gasReserveDifference === 0" [icon]="faMinus"/>
Expand All @@ -63,17 +63,17 @@
</div>
<div class="progress gas-bar mt-1 mb-2">
<div class="reserve-bar rounded-progress"></div>
<div class="combined_wrapper" [ngClass]="{'flip': gasRemainingDifference > 0}" >
<div class="combined_wrapper" [ngClass]="{'flip': remainingRight }" >
<div role="progressbar"
class="progress-bar rounded-progress bg-primary"
[style.width]="gasRemainingPercentageDifference + '%'">
{{Math.abs(gasRemainingDifference) | number:'1.0-0' }}</div>
{{ absoluteRemainingDifference | number:'1.0-0' }}</div>
</div>
<div class="combined_wrapper" [ngClass]="{'flip': gasReserveDifference > 0}" >
<div class="combined_wrapper" [ngClass]="{'flip': reserveRight }" >
<div role="progressbar"
class="progress-bar rounded-progress bg-warning "
[style.width]="gasReservePercentageDifference + '%'">
{{Math.abs(gasReserveDifference) | number:'1.0-0' }}</div>
{{ absoluteReserveDifference | number:'1.0-0' }}</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,26 @@ export class GasConsumedDifferenceTankComponent implements OnChanges{
public get gasRemainingDifference(): number {
return this.units.fromLiter(this.profileAGasRemaining - this.profileBGasRemaining);
}

public get absoluteRemainingDifference(): number {
return Math.abs(this.gasRemainingDifference);
}
public get gasReserveDifference(): number {
return this.units.fromLiter(this.profileACombinedGas.reserve - this.profileBCombinedGas.reserve);
}

public get absoluteReserveDifference(): number {
return Math.abs(this.gasReserveDifference);
}

public get reserveRight(): boolean {
return this.gasReserveDifference > 0;
}

public get remainingRight(): boolean {
return this.gasRemainingDifference > 0;
}

public get gasRemainingPercentageDifference(): number {
const totalGasRemaining = this.profileAGasRemaining + this.profileBGasRemaining;

Expand Down Expand Up @@ -102,14 +118,10 @@ export class GasConsumedDifferenceTankComponent implements OnChanges{
return this.profileComparatorService.profileB.title;
}


ngOnChanges(changes: SimpleChanges) {
public ngOnChanges(changes: SimpleChanges) {
if (changes.profileACombinedGas || changes.profileBCombinedGas) {
this.profileAGasRemaining = this.profileACombinedGas.total - this.profileACombinedGas.consumed;
this.profileBGasRemaining = this.profileBCombinedGas.total - this.profileBCombinedGas.consumed;
}
}

// TODO why Math?
protected readonly Math = Math;
}

0 comments on commit 4b2b72b

Please sign in to comment.