Add dashboard pressure trend arrow

This commit is contained in:
2019-10-06 19:59:13 -04:00
parent d593c0095f
commit 7c062dbc04
13 changed files with 148 additions and 7 deletions

View File

@@ -1,7 +1,12 @@
import { Injectable } from '@angular/core';
import { Observable, BehaviorSubject } from 'rxjs';
import { HubConnectionBuilder, HubConnection } from '@aspnet/signalr';
import { WeatherReading } from '../../models/weather/weather-reading';
import { WeatherReading } from 'src/app/models/weather/weather-reading';
import { WeatherValue } from 'src/app/models/weather/weather-value';
import { HttpClient } from '@angular/common/http';
import * as moment from 'moment';
import { WeatherValueType } from 'src/app/models/weather/weather-value-type';
@Injectable({
providedIn: 'root'
@@ -10,7 +15,7 @@ export class WeatherService {
private connection: HubConnection;
private latestReading: BehaviorSubject<WeatherReading> = new BehaviorSubject<WeatherReading>(null);
constructor() {
constructor(private httpClient: HttpClient) {
this.connection = new HubConnectionBuilder()
.withUrl('/api/hub/weather')
.build();
@@ -25,4 +30,13 @@ export class WeatherService {
getLatestReading(): Observable<WeatherReading> {
return this.latestReading.asObservable();
}
async getReadingValueHistory(valueType: WeatherValueType, start: moment.Moment, end: moment.Moment): Promise<WeatherValue[]> {
const startString = start.toISOString();
const endString = end.toISOString();
const data = await this.httpClient.get<WeatherValue[]>(`/api/weather/readings/value-history?weatherValueType=${valueType}&start=${startString}&end=${endString}`).toPromise();
return data;
}
}