Change battery icon to an alert if we lose connection for 2 minutes
This commit is contained in:
parent
709c00bfe2
commit
5a57843d27
@ -10,13 +10,14 @@ export class BatteryService {
|
|||||||
batteries = [];
|
batteries = [];
|
||||||
charge: number;
|
charge: number;
|
||||||
lastCharge: number;
|
lastCharge: number;
|
||||||
|
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 < this.charge; }
|
||||||
|
|
||||||
get icon() {
|
get icon() {
|
||||||
if (!this.batteries.length) return 'battery_alert';
|
if (new Date().getTime() - this.lastUpdate > 120000) return 'battery_alert';
|
||||||
|
|
||||||
return 'battery_full';
|
return 'battery_full';
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ export class BatteryService {
|
|||||||
this.firestore = firebaseApp.firestore();
|
this.firestore = firebaseApp.firestore();
|
||||||
this.firestore.settings({timestampsInSnapshots: true});
|
this.firestore.settings({timestampsInSnapshots: true});
|
||||||
this.firestore.collection('Battery').doc('170614D').onSnapshot(snap => {
|
this.firestore.collection('Battery').doc('170614D').onSnapshot(snap => {
|
||||||
|
this.lastUpdate = new Date().getTime();
|
||||||
let data = snap.data();
|
let data = snap.data();
|
||||||
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 => {
|
||||||
|
Loading…
Reference in New Issue
Block a user