Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Removing unnecessary if, introducing optional values in generator state
  • Loading branch information
Evan Langlais committed Apr 16, 2019
1 parent b38a78c commit 78056d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions src/app/generator-object.ts
Expand Up @@ -10,10 +10,10 @@ export interface GeneratorState {
online: boolean;
status: string;
status_code: number;
fault_count: number | null;
fault_codes: Array<string>;
status_count: number;
status_codes: Array<string>;
ip: string;
fault_count?: number;
fault_codes?: Array<string>;
status_count?: number;
status_codes?: Array<string>;
ip?: string;
}

20 changes: 10 additions & 10 deletions src/app/statistics/statistics.component.html
Expand Up @@ -107,61 +107,61 @@
<h3 class = "p-3">Faults</h3>
</div>
<div class = "col-md-6">
<h5 *ngIf = "this.generator.fault_codes.includes('fault.overcrank'); else emptyOvercrank"><span class="badge badge-danger">Overcrank</span></h5>
<h5 *ngIf = "generator.fault_codes.includes('fault.overcrank'); else emptyOvercrank"><span class="badge badge-danger">Overcrank</span></h5>
<ng-template #emptyOvercrank>
<h5><span class="badge badge-secondary">Overcrank</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "this.generator.fault_codes.includes('fault.engine.temp.high'); else emptyEngine"><span class="badge badge-danger">High Engine<br>Temperature</span></h5>
<h5 *ngIf = "generator.fault_codes.includes('fault.engine.temp.high'); else emptyEngine"><span class="badge badge-danger">High Engine<br>Temperature</span></h5>
<ng-template #emptyEngine>
<h5><span class="badge badge-secondary">High Engine<br>Temperature</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "this.generator.fault_codes.includes('fault.oil.pressure.low'); else emptyOil"><span class="badge badge-danger">Low Oil<br>Pressure</span></h5>
<h5 *ngIf = "generator.fault_codes.includes('fault.oil.pressure.low'); else emptyOil"><span class="badge badge-danger">Low Oil<br>Pressure</span></h5>
<ng-template #emptyOil>
<h5><span class="badge badge-secondary">Low Oil<br>Pressure</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "this.generator.fault_codes.includes('fault.overspeed'); else emptyOverspeed"><span class="badge badge-danger">Overspeed</span></h5>
<h5 *ngIf = "generator.fault_codes.includes('fault.overspeed'); else emptyOverspeed"><span class="badge badge-danger">Overspeed</span></h5>
<ng-template #emptyOverspeed>
<h5><span class="badge badge-secondary">Overspeed</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "this.generator.fault_codes.includes('fault.emstop'); else emptyEmergency"><span class="badge badge-danger">Emergency Stop</span></h5>
<h5 *ngIf = "generator.fault_codes.includes('fault.emstop'); else emptyEmergency"><span class="badge badge-danger">Emergency Stop</span></h5>
<ng-template #emptyEmergency>
<h5><span class="badge badge-secondary">Emergency Stop</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "this.generator.fault_codes.includes('fault.fuel.low'); else emptyLowFuel"><span class="badge badge-danger">Low Fuel</span></h5>
<h5 *ngIf = "generator.fault_codes.includes('fault.fuel.low'); else emptyLowFuel"><span class="badge badge-danger">Low Fuel</span></h5>
<ng-template #emptyLowFuel>
<h5><span class="badge badge-secondary">Low Fuel</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "this.generator.fault_codes.includes('fault.coolant.level.low'); else emptyLowCoolant"><span class="badge badge-danger">Low Coolant<br>Level/Aux</span></h5>
<h5 *ngIf = "generator.fault_codes.includes('fault.coolant.level.low'); else emptyLowCoolant"><span class="badge badge-danger">Low Coolant<br>Level/Aux</span></h5>
<ng-template #emptyLowCoolant>
<h5><span class="badge badge-secondary">Low Coolant<br>Level/Aux</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "this.generator.fault_codes.includes('fault.crank.volt.low'); else emptyLowCranking"><span class="badge badge-danger">Low Cranking<br>Voltage</span></h5>
<h5 *ngIf = "generator.fault_codes.includes('fault.crank.volt.low'); else emptyLowCranking"><span class="badge badge-danger">Low Cranking<br>Voltage</span></h5>
<ng-template #emptyLowCranking>
<h5><span class="badge badge-secondary">Low Cranking<br>Voltage</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "this.generator.fault_codes.includes('fault.batt.volt.low') || this.generator.fault_codes.includes('fault.batt.volt.high'); else emptyBatteryVolt"><span class="badge badge-danger">Battery Voltage<br>(Hi/Lo)</span></h5>
<h5 *ngIf = "generator.fault_codes.includes('fault.batt.volt.low') || this.generator.fault_codes.includes('fault.batt.volt.high'); else emptyBatteryVolt"><span class="badge badge-danger">Battery Voltage<br>(Hi/Lo)</span></h5>
<ng-template #emptyBatteryVolt>
<h5><span class="badge badge-secondary">Battery Voltage<br>(Hi/Lo)</span></h5>
</ng-template>
</div>
<div class = "col-md-6">
<h5 *ngIf = "this.generator.fault_codes.includes('fault.common'); else emptyCommon"><span class="badge badge-danger">Common Fault</span></h5>
<h5 *ngIf = "generator.fault_codes.includes('fault.common'); else emptyCommon"><span class="badge badge-danger">Common Fault</span></h5>
<ng-template #emptyCommon>
<h5><span class="badge badge-secondary">Common Fault</span></h5>
</ng-template>
Expand Down

0 comments on commit 78056d9

Please sign in to comment.