mirror of
https://github.com/ckaczor/HomeMonitor.git
synced 2026-01-18 09:35:40 -05:00
Data model simplification
This commit is contained in:
@@ -106,7 +106,7 @@ export class PowerChartsComponent implements OnInit {
|
||||
|
||||
data[1].forEach(dataElement => {
|
||||
const date = Date.parse(dataElement.bucket);
|
||||
seriesData[2].data.push([date, dataElement.averageValue * 100]);
|
||||
seriesData[2].data.push([date, dataElement.averageValue]);
|
||||
});
|
||||
|
||||
const title = this.selectedTimeSpan === TimeSpan.Last24Hours ? this.timeSpanItems[TimeSpan.Last24Hours] : this.getSelectedDateDisplayString();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { WeatherReading } from 'src/app/models/weather/weather-reading';
|
||||
import { WeatherUpdate } from 'src/app/models/weather/weather-update';
|
||||
import { WeatherService } from 'src/app/services/weather/weather.service';
|
||||
import { first } from 'rxjs/operators';
|
||||
|
||||
@@ -14,7 +14,7 @@ import 'moment-duration-format';
|
||||
})
|
||||
export class AlmanacComponent implements OnInit {
|
||||
public loaded = false;
|
||||
public latestReading: WeatherReading;
|
||||
public latestReading: WeatherUpdate;
|
||||
public sunTimes: SunCalc.GetTimesResult;
|
||||
public moonTimes: SunCalc.GetMoonTimes;
|
||||
public moon: SunCalc.GetMoonIlluminationResult;
|
||||
|
||||
@@ -118,10 +118,10 @@ export class WeatherChartsComponent implements OnInit {
|
||||
|
||||
data.forEach(dataElement => {
|
||||
const date = Date.parse(dataElement.bucket);
|
||||
seriesData[0].data.push([date, dataElement.averagePressureTemperature]);
|
||||
seriesData[0].data.push([date, dataElement.averageTemperature]);
|
||||
seriesData[1].data.push([date, dataElement.averagePressure / 33.864 / 100]);
|
||||
seriesData[2].data.push([date, dataElement.averageHumidity]);
|
||||
seriesData[3].data.push([date, dataElement.averageLightLevel * 100]);
|
||||
seriesData[3].data.push([date, dataElement.averageLightLevel]);
|
||||
seriesData[4].data.push([date, dataElement.rainTotal]);
|
||||
});
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
Temperature
|
||||
</td>
|
||||
<td>
|
||||
{{ latestReading.PressureTemperature.toFixed(2) }}°F
|
||||
{{ latestReading.Temperature.toFixed(2) }}°F
|
||||
</td>
|
||||
</tr>
|
||||
<tr *ngIf="latestReading.HeatIndex">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { WeatherReading } from 'src/app/models/weather/weather-reading';
|
||||
import { WeatherUpdate } from 'src/app/models/weather/weather-update';
|
||||
import { WeatherService } from 'src/app/services/weather/weather.service';
|
||||
|
||||
@Component({
|
||||
@@ -8,7 +8,7 @@ import { WeatherService } from 'src/app/services/weather/weather.service';
|
||||
styleUrls: ['./weather-current.component.scss']
|
||||
})
|
||||
export class WeatherCurrentComponent implements OnInit {
|
||||
public latestReading: WeatherReading;
|
||||
public latestReading: WeatherUpdate;
|
||||
|
||||
constructor(private weatherService: WeatherService) { }
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
export class WeatherReadingGrouped {
|
||||
bucket: string;
|
||||
averagePressureTemperature: number;
|
||||
averageTemperature: number;
|
||||
averagePressure: number;
|
||||
averageLightLevel: number;
|
||||
averageHumidity: number;
|
||||
averageHumidityTemperature: number;
|
||||
rainTotal: number;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { WeatherReading } from './weather-reading';
|
||||
import { WeatherUpdate } from './weather-update';
|
||||
|
||||
describe('WeatherReading', () => {
|
||||
describe('WeatherUpdate', () => {
|
||||
it('should create an instance', () => {
|
||||
expect(new WeatherReading()).toBeTruthy();
|
||||
expect(new WeatherUpdate()).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
export class WeatherReading {
|
||||
export class WeatherUpdate {
|
||||
Type: string;
|
||||
Message: null;
|
||||
Timestamp: Date;
|
||||
WindDirection: string;
|
||||
WindSpeed: number;
|
||||
Humidity: number;
|
||||
HumidityTemperature: number;
|
||||
Rain: number;
|
||||
Pressure: number;
|
||||
PressureTemperature: number;
|
||||
Temperature: number;
|
||||
BatteryLevel: number;
|
||||
LightLevel: number;
|
||||
Latitude: number;
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, BehaviorSubject } from 'rxjs';
|
||||
import { HubConnectionBuilder, HubConnection } from '@aspnet/signalr';
|
||||
import { WeatherReading } from 'src/app/models/weather/weather-reading';
|
||||
import { WeatherUpdate } from 'src/app/models/weather/weather-update';
|
||||
import { WeatherValue } from 'src/app/models/weather/weather-value';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
|
||||
@@ -13,7 +13,7 @@ import { WeatherValueType } from 'src/app/models/weather/weather-value-type';
|
||||
})
|
||||
export class WeatherService {
|
||||
private connection: HubConnection;
|
||||
private latestReading: BehaviorSubject<WeatherReading> = new BehaviorSubject<WeatherReading>(null);
|
||||
private latestReading: BehaviorSubject<WeatherUpdate> = new BehaviorSubject<WeatherUpdate>(null);
|
||||
|
||||
constructor(private httpClient: HttpClient) {
|
||||
this.connection = new HubConnectionBuilder()
|
||||
@@ -27,7 +27,7 @@ export class WeatherService {
|
||||
this.connection.start();
|
||||
}
|
||||
|
||||
getLatestReading(): Observable<WeatherReading> {
|
||||
getLatestReading(): Observable<WeatherUpdate> {
|
||||
return this.latestReading.asObservable();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user