Formatting changes
This commit is contained in:
		| @@ -1,11 +1,13 @@ | ||||
| <div class="fill-height p-3" style="background-color: #b52e3c !important;"> | ||||
|     <div style="max-width: 1000px;"> | ||||
|         <h1>Powerwall: {{batteryService.charge | number : '1.1-1'}} V</h1> | ||||
|         <div class="d-flex align-content-center"> | ||||
|             <div *ngIf="locked" class="mr-1"> | ||||
|                 <mat-icon>lock</mat-icon> | ||||
|         <div class="d-flex justify-content-between mb-4"> | ||||
|             <div> | ||||
|                 <h1 class="mb-0">Powerwall: {{batteryService.charge | number : '1.1-1'}} V</h1> | ||||
|                 <h6>Last Updated At: {{batteryService.lastUpdate | date: 'short'}}</h6> | ||||
|             </div> | ||||
|             <div><h5>Cooling Fans</h5></div> | ||||
|             <div class="d-flex flex-column align-content-center"> | ||||
|                 <div> | ||||
|                     <h5><mat-icon *ngIf="locked" class="mr-1">lock</mat-icon>Cooling Fans</h5> | ||||
|                 </div> | ||||
|                 <mat-button-toggle-group class="mb-3" [ngModel]="batteryService.relayMode" | ||||
|                                          (change)="batteryService.setRelayMode($event.value)" [disabled]="locked"> | ||||
| @@ -13,6 +15,8 @@ | ||||
|                     <mat-button-toggle value="true">On</mat-button-toggle> | ||||
|                     <mat-button-toggle value="false">Off</mat-button-toggle> | ||||
|                 </mat-button-toggle-group> | ||||
|             </div> | ||||
|         </div> | ||||
|         <mat-card class="mt-2" *ngFor="let battery of batteryService.batteries; let i = index"> | ||||
|             <div class="d-flex"> | ||||
|                 <div class="d-flex flex-grow-1 align-items-center"> | ||||
|   | ||||
| @@ -7,12 +7,12 @@ import {AngularFirestore} from '@angular/fire/firestore'; | ||||
| export class BatteryService { | ||||
|     batteries = []; | ||||
|     charge: number; | ||||
|     lastCharge: number; | ||||
|     lastCharge: number[] = []; | ||||
|     lastUpdate = new Date().getTime(); | ||||
|     relayMode: string = 'null'; | ||||
|     temp: number = 0; | ||||
|  | ||||
|     get charging() { return this.lastCharge < this.charge; } | ||||
|     get charging() { return this.lastCharge.reduce((acc, v) => acc + v, 0) / this.lastCharge.length < this.charge; } | ||||
|  | ||||
|     get icon() { | ||||
|         if (new Date().getTime() - this.lastUpdate > 120000) return 'battery_alert'; | ||||
| @@ -48,16 +48,18 @@ export class BatteryService { | ||||
|             this.relayMode = data.config.relayMode ? data.config.relayMode.toString() : 'null'; | ||||
|             this.batteries = Object.keys(data.modules).map(key => { | ||||
|                 let last = data.modules[key].length - 1; | ||||
|                 console.log(data.modules[key][last]); | ||||
|                 return { | ||||
|                     charge: data.modules[key][last].charge, | ||||
|                     chargeHistory: data.modules[key].map((val, i) => ({name: val.timestamp.toDate(), value: val.charge})), | ||||
|                     chargeHistory: data.modules[key].map(val => ({name: val.timestamp.toDate(), value: val.charge})), | ||||
|                     lastUpdate: data.modules[key][last].timestamp.toDate(), | ||||
|                     name: key, | ||||
|                     temp: data.modules[key][last].temp, | ||||
|                     tempHistory: data.modules[key].map((val, i) => ({name: val.timestamp.toDate(), value: val.temp})) | ||||
|                     tempHistory: data.modules[key].map(val => ({name: val.timestamp.toDate(), value: val.temp})) | ||||
|                 } | ||||
|             }); | ||||
|             this.lastCharge = this.charge; | ||||
|             this.lastCharge.push(this.charge); | ||||
|             this.lastCharge.splice(0, this.lastCharge.length - 5); | ||||
|             this.lastUpdate = this.batteries.reduce((acc, battery) => acc > battery.lastUpdate ? acc : battery.lastUpdate, 0); | ||||
|             this.charge = this.batteries.reduce((acc, battery) => acc + battery.charge, 0) / 2; | ||||
|             this.temp = this.batteries.reduce((acc, battery) => acc + battery.temp, 0) / 4; | ||||
|         }); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user