Change battery icon to an alert if we lose connection for 2 minutes

This commit is contained in:
Zakary Timson 2019-01-03 14:59:05 -05:00
parent 709c00bfe2
commit 5a57843d27

View File

@ -10,13 +10,14 @@ export class BatteryService {
batteries = [];
charge: number;
lastCharge: number;
lastUpdate = new Date().getTime();
relayMode: string = 'null';
temp: number = 0;
get charging() { return this.lastCharge < this.charge; }
get icon() {
if (!this.batteries.length) return 'battery_alert';
if (new Date().getTime() - this.lastUpdate > 120000) return 'battery_alert';
return 'battery_full';
@ -46,6 +47,7 @@ export class BatteryService {
this.firestore = firebaseApp.firestore();
this.firestore.settings({timestampsInSnapshots: true});
this.firestore.collection('Battery').doc('170614D').onSnapshot(snap => {
this.lastUpdate = new Date().getTime();
let data = snap.data();
this.relayMode = data.config.relayMode ? data.config.relayMode.toString() : 'null';
this.batteries = Object.keys(data.modules).map(key => {