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