diff --git a/src/main/angular/src/app/location/energy/location-energy.html b/src/main/angular/src/app/location/energy/location-energy.html index 4871577..423a9a2 100644 --- a/src/main/angular/src/app/location/energy/location-energy.html +++ b/src/main/angular/src/app/location/energy/location-energy.html @@ -12,7 +12,7 @@ Bezug
- {{ purchase.toValueString(interval ? null : now) }} + {{ purchase.toValueString(null) }}
@@ -21,7 +21,7 @@ Solar
- {{ produce.toValueString(interval ? null : now) }} + {{ produce.toValueString(null) }}
@@ -30,7 +30,7 @@ Verbrauch
- {{ consume.toValueString(interval ? null : now) }} + {{ consume.toValueString(null) }}
@@ -39,7 +39,7 @@ Einspeisung
- {{ deliver.toValueString(interval ? null : now) }} + {{ deliver.toValueString(null) }}
diff --git a/src/main/angular/src/app/location/energy/plot/energy-plot.ts b/src/main/angular/src/app/location/energy/plot/energy-plot.ts index fef812f..02b494e 100644 --- a/src/main/angular/src/app/location/energy/plot/energy-plot.ts +++ b/src/main/angular/src/app/location/energy/plot/energy-plot.ts @@ -1,10 +1,11 @@ -import {AfterViewInit, Component, Input} from '@angular/core'; +import {AfterViewInit, Component, Input, OnDestroy, OnInit} from '@angular/core'; import {Location} from '../../Location'; import {Interval} from '../../../series/Interval'; import {PointService} from '../../../point/point-service'; import {PointResponse} from '../../../point/PointResponse'; import {PointSeries} from '../../../point/PointSeries'; import {EnergyPoint} from './EnergyPoint'; +import {Subscription, timer} from 'rxjs'; @Component({ selector: 'app-energy-plot', @@ -12,7 +13,7 @@ import {EnergyPoint} from './EnergyPoint'; templateUrl: './energy-plot.html', styleUrl: './energy-plot.less', }) -export class EnergyPlot implements AfterViewInit { +export class EnergyPlot implements OnInit, OnDestroy, AfterViewInit { readonly widthPx = 800; @@ -44,12 +45,22 @@ export class EnergyPlot implements AfterViewInit { protected xWidthPx: number = 0; + private readonly subs: Subscription[] = []; + constructor( readonly pointService: PointService, ) { // } + ngOnInit(): void { + this.subs.push(timer(60000, 60000).subscribe(() => this.ngAfterViewInit())); + } + + ngOnDestroy(): void { + this.subs.forEach(sub => sub.unsubscribe()); + } + ngAfterViewInit(): void { if (!this._location.energyPurchase) { return; @@ -132,4 +143,5 @@ export class EnergyPlot implements AfterViewInit { this._count = value; this.ngAfterViewInit(); } + }