diff --git a/Display/src/app/components/dashboard/dashboard.component.html b/Display/src/app/components/dashboard/dashboard.component.html index 4873d2e..d47b66d 100644 --- a/Display/src/app/components/dashboard/dashboard.component.html +++ b/Display/src/app/components/dashboard/dashboard.component.html @@ -10,7 +10,7 @@ - +
Weather @@ -20,7 +20,7 @@
- +
Laundry @@ -30,7 +30,7 @@
- +
Almanac @@ -40,7 +40,7 @@
- +
Power diff --git a/Display/src/app/components/dashboard/dashboard.component.ts b/Display/src/app/components/dashboard/dashboard.component.ts index 6e3d4a2..d017165 100644 --- a/Display/src/app/components/dashboard/dashboard.component.ts +++ b/Display/src/app/components/dashboard/dashboard.component.ts @@ -8,8 +8,8 @@ import { DashboardLayout } from 'src/app/models/dashboard/dashboard-layout'; styleUrls: ['./dashboard.component.scss'] }) export class DashboardComponent implements OnInit { - public options: GridsterConfig; - public dashboardLayout: DashboardLayout; + public options: GridsterConfig | undefined; + public dashboardLayout: DashboardLayout | undefined; public locked = true; private defaultLayout: DashboardLayout = { @@ -46,14 +46,14 @@ export class DashboardComponent implements OnInit { } changedOptions() { - this.options.api.optionsChanged(); + this.options!.api!.optionsChanged!(); } toggleLocked() { this.locked = !this.locked; - this.options.resizable.enabled = !this.locked; - this.options.draggable.enabled = !this.locked; + this.options!.resizable!.enabled = !this.locked; + this.options!.draggable!.enabled = !this.locked; this.changedOptions(); } diff --git a/Display/src/app/components/laundry/laundry.component.html b/Display/src/app/components/laundry/laundry.component.html index cebf271..325b116 100644 --- a/Display/src/app/components/laundry/laundry.component.html +++ b/Display/src/app/components/laundry/laundry.component.html @@ -8,16 +8,16 @@ Washer - - {{ latestStatus.washer ? 'On' : 'Off' }} + + {{ latestStatus!.washer ? 'On' : 'Off' }} Dryer - - {{ latestStatus.dryer ? 'On' : 'Off' }} + + {{ latestStatus!.dryer ? 'On' : 'Off' }} diff --git a/Display/src/app/components/laundry/laundry.component.ts b/Display/src/app/components/laundry/laundry.component.ts index 66c9eb1..a9999e7 100644 --- a/Display/src/app/components/laundry/laundry.component.ts +++ b/Display/src/app/components/laundry/laundry.component.ts @@ -8,7 +8,7 @@ import { LaundryStatus } from '../../models/laundry/laundry-status'; styleUrls: ['./laundry.component.scss'] }) export class LaundryComponent implements OnInit { - public latestStatus: LaundryStatus; + public latestStatus: LaundryStatus | undefined; constructor(private laundryService: LaundryService) { } ngOnInit() { diff --git a/Display/src/app/components/nav/nav.component.ts b/Display/src/app/components/nav/nav.component.ts index 0c3fe21..13655e2 100644 --- a/Display/src/app/components/nav/nav.component.ts +++ b/Display/src/app/components/nav/nav.component.ts @@ -10,7 +10,7 @@ import { MatSidenav } from '@angular/material/sidenav'; styleUrls: ['./nav.component.scss'] }) export class NavComponent { - @ViewChild('sidenav', {}) sidenav: MatSidenav; + @ViewChild('sidenav', {}) sidenav: MatSidenav | undefined; isHandset$: Observable = this.breakpointObserver.observe([ Breakpoints.HandsetLandscape, @@ -30,7 +30,7 @@ export class NavComponent { public toggleSidenav() { this.isHandset$.subscribe(isHandset => { if (isHandset) { - this.sidenav.toggle(); + this.sidenav!.toggle(); } }); } diff --git a/Display/src/app/components/power/charts/power-charts.component.ts b/Display/src/app/components/power/charts/power-charts.component.ts index bcf477d..3299db0 100644 --- a/Display/src/app/components/power/charts/power-charts.component.ts +++ b/Display/src/app/components/power/charts/power-charts.component.ts @@ -21,7 +21,7 @@ HC_exporting(Highcharts); }) export class PowerChartsComponent implements OnInit { - public chart: Chart; + public chart: Chart | undefined; public loading = true; private timeSpanValue: TimeSpan = TimeSpan.Last24Hours; @@ -71,19 +71,19 @@ export class PowerChartsComponent implements OnInit { ]).subscribe(data => { const seriesData: Array = []; - seriesData.push({ name: 'Generation', data: [], yAxis: 0, marker: { enabled: false }, tooltip: { valueSuffix: ' W' } } as SeriesLineOptions); - seriesData.push({ name: 'Consumption', data: [], yAxis: 0, marker: { enabled: false }, tooltip: { valueSuffix: ' W' } } as SeriesLineOptions); - seriesData.push({ name: 'Light', data: [], yAxis: 1, marker: { enabled: false }, tooltip: { valueSuffix: ' lx' } } as SeriesLineOptions); + seriesData.push({ type: 'line', name: 'Generation', data: [], yAxis: 0, marker: { enabled: false }, tooltip: { valueSuffix: ' W' } } as SeriesLineOptions); + seriesData.push({ type: 'line', name: 'Consumption', data: [], yAxis: 0, marker: { enabled: false }, tooltip: { valueSuffix: ' W' } } as SeriesLineOptions); + seriesData.push({ type: 'line', name: 'Light', data: [], yAxis: 1, marker: { enabled: false }, tooltip: { valueSuffix: ' lx' } } as SeriesLineOptions); data[0].forEach(dataElement => { - const date = Date.parse(dataElement.bucket); - seriesData[0].data.push([date, dataElement.averageGeneration < 0 ? 0 : dataElement.averageGeneration]); - seriesData[1].data.push([date, dataElement.averageConsumption < 0 ? 0 : dataElement.averageConsumption]); + const date = Date.parse(dataElement.bucket!); + seriesData[0].data!.push([date, dataElement.averageGeneration! < 0 ? 0 : dataElement.averageGeneration]); + seriesData[1].data!.push([date, dataElement.averageConsumption! < 0 ? 0 : dataElement.averageConsumption]); }); data[1].forEach(dataElement => { - const date = Date.parse(dataElement.bucket); - seriesData[2].data.push([date, dataElement.averageValue]); + const date = Date.parse(dataElement.bucket!); + seriesData[2].data!.push([date, dataElement.averageValue]); }); this.chart = new Chart({ diff --git a/Display/src/app/components/power/current/power.component.html b/Display/src/app/components/power/current/power.component.html index 79c8dc9..82939d5 100644 --- a/Display/src/app/components/power/current/power.component.html +++ b/Display/src/app/components/power/current/power.component.html @@ -9,7 +9,7 @@ Generation - {{ latestStatus.Generation < 0 ? 0 : latestStatus.Generation }} W + {{ latestStatus!.Generation < 0 ? 0 : latestStatus!.Generation }} W @@ -17,7 +17,7 @@ Consumption - {{ latestStatus.Consumption < 0 ? 0 : latestStatus.Consumption }} W + {{ latestStatus!.Consumption < 0 ? 0 : latestStatus!.Consumption }} W diff --git a/Display/src/app/components/power/current/power.component.ts b/Display/src/app/components/power/current/power.component.ts index 424b6ff..471b8cb 100644 --- a/Display/src/app/components/power/current/power.component.ts +++ b/Display/src/app/components/power/current/power.component.ts @@ -8,7 +8,7 @@ import { PowerStatus } from 'src/app/models/power/power-status'; styleUrls: ['./power.component.scss'] }) export class PowerComponent implements OnInit { - public latestStatus: PowerStatus; + public latestStatus: PowerStatus | undefined | null; constructor(private powerService: PowerService) { } ngOnInit() { diff --git a/Display/src/app/components/time-range/time-range.component.ts b/Display/src/app/components/time-range/time-range.component.ts index 42ef3d5..366501e 100644 --- a/Display/src/app/components/time-range/time-range.component.ts +++ b/Display/src/app/components/time-range/time-range.component.ts @@ -1,7 +1,7 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { TimeSpan } from 'src/app/models/time-span'; -import * as moment from 'moment'; +import moment from 'moment'; @Component({ selector: 'app-time-range', @@ -11,12 +11,12 @@ import * as moment from 'moment'; export class TimeRangeComponent implements OnInit { @Input() - public loading: boolean; + public loading: boolean | undefined; - private timeSpanValue: TimeSpan; + private timeSpanValue: TimeSpan | undefined; @Input() - public set timeSpan(val: TimeSpan) { + public set timeSpan(val: TimeSpan | undefined) { this.timeSpanChange.emit(val); this.timeSpanValue = val; } @@ -28,10 +28,10 @@ export class TimeRangeComponent implements OnInit { @Output() public timeSpanChange: EventEmitter = new EventEmitter(); - private dateValue: moment.Moment; + private dateValue: moment.Moment | undefined; @Input() - public set date(val: moment.Moment) { + public set date(val: moment.Moment | undefined) { this.dateChange.emit(val); this.dateValue = val; } diff --git a/Display/src/app/components/weather/almanac/almanac.component.html b/Display/src/app/components/weather/almanac/almanac.component.html index 1dc51f6..b023917 100644 --- a/Display/src/app/components/weather/almanac/almanac.component.html +++ b/Display/src/app/components/weather/almanac/almanac.component.html @@ -9,7 +9,7 @@ Sunrise - {{ sunTimes.sunrise | amLocal | amDateFormat: 'hh:mm:ss A' }} + {{ sunTimes!.sunrise | amLocal | amDateFormat: 'hh:mm:ss A' }} @@ -17,7 +17,7 @@ Sunset - {{ sunTimes.sunset | amLocal | amDateFormat: 'hh:mm:ss A' }} + {{ sunTimes!.sunset | amLocal | amDateFormat: 'hh:mm:ss A' }} @@ -33,7 +33,7 @@ Moonrise - {{ moonTimes.rise | amLocal | amDateFormat: 'hh:mm:ss A' }} + {{ moonTimes!.rise | amLocal | amDateFormat: 'hh:mm:ss A' }} @@ -41,7 +41,7 @@ Moonset - {{ moonTimes.set | amLocal | amDateFormat: 'hh:mm:ss A' }} + {{ moonTimes!.set | amLocal | amDateFormat: 'hh:mm:ss A' }} @@ -49,13 +49,13 @@ Moon - {{ moonPhaseName(moon.phase) }} + {{ moonPhaseName(moon!.phase) }}
- {{ (moon.fraction * 100).toFixed(1) }}% illuminated + {{ (moon!.fraction * 100).toFixed(1) }}% illuminated
- {{ moonPhaseLetter(moon.phase) }} + {{ moonPhaseLetter(moon!.phase) }}
diff --git a/Display/src/app/components/weather/almanac/almanac.component.ts b/Display/src/app/components/weather/almanac/almanac.component.ts index ced21ee..994b4db 100644 --- a/Display/src/app/components/weather/almanac/almanac.component.ts +++ b/Display/src/app/components/weather/almanac/almanac.component.ts @@ -14,10 +14,10 @@ import 'moment-duration-format'; }) export class AlmanacComponent implements OnInit { public loaded = false; - public latestReading: WeatherUpdate; - public sunTimes: SunCalc.GetTimesResult; - public moonTimes: SunCalc.GetMoonTimes; - public moon: SunCalc.GetMoonIlluminationResult; + public latestReading: WeatherUpdate | undefined | null; + public sunTimes: SunCalc.GetTimesResult | undefined | null; + public moonTimes: SunCalc.GetMoonTimes | undefined | null; + public moon: SunCalc.GetMoonIlluminationResult | undefined | null; constructor(private weatherService: WeatherService) { } @@ -33,8 +33,8 @@ export class AlmanacComponent implements OnInit { const date = new Date(); - this.sunTimes = SunCalc.getTimes(date, this.latestReading.Latitude, this.latestReading.Longitude); - this.moonTimes = SunCalc.getMoonTimes(date, this.latestReading.Latitude, this.latestReading.Longitude); + this.sunTimes = SunCalc.getTimes(date, this.latestReading?.Latitude!, this.latestReading?.Longitude!); + this.moonTimes = SunCalc.getMoonTimes(date, this.latestReading?.Latitude!, this.latestReading?.Longitude!); this.moon = SunCalc.getMoonIllumination(date); this.loaded = true; @@ -59,6 +59,8 @@ export class AlmanacComponent implements OnInit { } else if (phase < 1.0) { return 'Waning Crescent'; } + + return ''; } moonPhaseLetter(phase: number): string { @@ -79,10 +81,12 @@ export class AlmanacComponent implements OnInit { } else if (phase < 1.0) { return 'W'; } + + return ''; } dayLength(): string { - const duration = moment.duration((this.sunTimes.sunset.valueOf() - this.sunTimes.sunrise.valueOf())); + const duration = moment.duration((this.sunTimes!.sunset.valueOf() - this.sunTimes!.sunrise.valueOf())); return duration.format('hh [hours] mm [minutes]'); } } diff --git a/Display/src/app/components/weather/charts/weather-charts.component.ts b/Display/src/app/components/weather/charts/weather-charts.component.ts index 2e36448..8a52a1d 100644 --- a/Display/src/app/components/weather/charts/weather-charts.component.ts +++ b/Display/src/app/components/weather/charts/weather-charts.component.ts @@ -26,7 +26,7 @@ enum ChartType { }) export class WeatherChartsComponent implements OnInit { - public chart: Chart; + public chart: Chart | undefined; public loading = true; public selectedChartType: ChartType = ChartType.Weather; @@ -91,12 +91,12 @@ export class WeatherChartsComponent implements OnInit { seriesData.push({ type: 'column', name: 'Rain', data: [], yAxis: 3, marker: { enabled: false }, tooltip: { valueSuffix: '"' } } as SeriesColumnOptions); data.forEach(dataElement => { - const date = Date.parse(dataElement.bucket); - 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]); - seriesData[4].data.push([date, dataElement.rainTotal]); + const date = Date.parse(dataElement.bucket!); + 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]); + seriesData[4].data!.push([date, dataElement.rainTotal]); }); this.chart = new Chart({ @@ -219,11 +219,11 @@ export class WeatherChartsComponent implements OnInit { seriesData.push({ type: 'windbarb', name: 'Direction', data: [], marker: { enabled: false }, tooltip: { valueSuffix: ' MPH' } } as SeriesWindbarbOptions); data.forEach(dataElement => { - const date = Date.parse(dataElement.bucket); - seriesData[0].data.push([date, dataElement.minimumSpeed]); - seriesData[1].data.push([date, dataElement.averageSpeed]); - seriesData[2].data.push([date, dataElement.maximumSpeed]); - seriesData[3].data.push([date, dataElement.averageSpeed, dataElement.averageDirection]); + const date = Date.parse(dataElement.bucket!); + seriesData[0].data!.push([date, dataElement.minimumSpeed]); + seriesData[1].data!.push([date, dataElement.averageSpeed]); + seriesData[2].data!.push([date, dataElement.maximumSpeed]); + seriesData[3].data!.push([date, dataElement.averageSpeed, dataElement.averageDirection]); }); this.chart = new Chart({ diff --git a/Display/src/app/components/weather/current/weather-current.component.html b/Display/src/app/components/weather/current/weather-current.component.html index c4f7ae9..c47b631 100644 --- a/Display/src/app/components/weather/current/weather-current.component.html +++ b/Display/src/app/components/weather/current/weather-current.component.html @@ -10,23 +10,23 @@ Temperature - {{ latestReading.Temperature.toFixed(2) }}°F + {{ latestReading!.Temperature?.toFixed(2) }}°F - + Heat index - {{ latestReading.HeatIndex.toFixed(2) }}°F + {{ latestReading!.HeatIndex?.toFixed(2) }}°F - + Wind chill - {{ latestReading.WindChill.toFixed(2) }}°F + {{ latestReading!.WindChill?.toFixed(2) }}°F @@ -34,7 +34,7 @@ Humidity - {{ latestReading.Humidity.toFixed(2) }}% + {{ latestReading!.Humidity?.toFixed(2) }}% @@ -42,7 +42,7 @@ Dew point - {{ latestReading.DewPoint.toFixed(2) }}°F + {{ latestReading!.DewPoint?.toFixed(2) }}°F @@ -50,9 +50,9 @@ Pressure - {{ (latestReading.Pressure / 33.864 / 100).toFixed(2) }}" + {{ latestReading!.Pressure && (latestReading!.Pressure / 33.864 / 100)?.toFixed(2) }}" - + @@ -60,7 +60,7 @@ Wind - {{ latestReading.WindSpeed.toFixed(2) }} mph {{ latestReading.WindDirection }} + {{ latestReading!.WindSpeed?.toFixed(2) }} mph {{ latestReading!.WindDirection }} @@ -68,7 +68,7 @@ Rain - {{ latestReading.RainLastHour.toFixed(2) }}" (last hour) + {{ latestReading!.RainLastHour?.toFixed(2) }}" (last hour) @@ -76,7 +76,7 @@ Light - {{ latestReading.LightLevel.toFixed(2) }} lx + {{ latestReading!.LightLevel?.toFixed(2) }} lx diff --git a/Display/src/app/components/weather/current/weather-current.component.ts b/Display/src/app/components/weather/current/weather-current.component.ts index 6384b7f..8c7148c 100644 --- a/Display/src/app/components/weather/current/weather-current.component.ts +++ b/Display/src/app/components/weather/current/weather-current.component.ts @@ -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: WeatherUpdate; + public latestReading: WeatherUpdate | null | undefined; constructor(private weatherService: WeatherService) { } @@ -17,7 +17,7 @@ export class WeatherCurrentComponent implements OnInit { } rotationClass(): string { - const pressureDifference = this.latestReading.PressureDifferenceThreeHour; + const pressureDifference = this.latestReading?.PressureDifferenceThreeHour; if (!pressureDifference) { return ''; @@ -32,5 +32,7 @@ export class WeatherCurrentComponent implements OnInit { } else if (pressureDifference < -2.0) { return 'down-high'; } + + return ''; } } diff --git a/Display/src/app/components/weather/summary/weather-summary.component.html b/Display/src/app/components/weather/summary/weather-summary.component.html index 042c14c..58d22b6 100644 --- a/Display/src/app/components/weather/summary/weather-summary.component.html +++ b/Display/src/app/components/weather/summary/weather-summary.component.html @@ -39,13 +39,13 @@ Temperature - {{ weatherAggregates.temperature.min.toFixed(2) }}°F + {{ weatherAggregates!.temperature.min.toFixed(2) }}°F - {{ weatherAggregates.temperature.average.toFixed(2) }}°F + {{ weatherAggregates!.temperature.average.toFixed(2) }}°F - {{ weatherAggregates.temperature.max.toFixed(2) }}°F + {{ weatherAggregates!.temperature.max.toFixed(2) }}°F @@ -53,13 +53,13 @@ Humidity - {{ weatherAggregates.humidity.min.toFixed(2) }}% + {{ weatherAggregates!.humidity.min.toFixed(2) }}% - {{ weatherAggregates.humidity.average.toFixed(2) }}% + {{ weatherAggregates!.humidity.average.toFixed(2) }}% - {{ weatherAggregates.humidity.max.toFixed(2) }}% + {{ weatherAggregates!.humidity.max.toFixed(2) }}% @@ -67,13 +67,13 @@ Pressure - {{ (weatherAggregates.pressure.min / 33.864 / 100).toFixed(2) }}" + {{ (weatherAggregates!.pressure.min / 33.864 / 100).toFixed(2) }}" - {{ (weatherAggregates.pressure.average / 33.864 / 100).toFixed(2) }}" + {{ (weatherAggregates!.pressure.average / 33.864 / 100).toFixed(2) }}" - {{ (weatherAggregates.pressure.max / 33.864 / 100).toFixed(2) }}" + {{ (weatherAggregates!.pressure.max / 33.864 / 100).toFixed(2) }}" @@ -81,13 +81,13 @@ Light - {{ weatherAggregates.light.min.toFixed(2) }} lx + {{ weatherAggregates!.light.min.toFixed(2) }} lx - {{ weatherAggregates.light.average.toFixed(2) }} lx + {{ weatherAggregates!.light.average.toFixed(2) }} lx - {{ weatherAggregates.light.max.toFixed(2) }} lx + {{ weatherAggregates!.light.max.toFixed(2) }} lx @@ -95,13 +95,13 @@ Wind Speed - {{ weatherAggregates.windSpeed.min.toFixed(2) }} mph + {{ weatherAggregates!.windSpeed.min.toFixed(2) }} mph - {{ weatherAggregates.windSpeed.average.toFixed(2) }} mph + {{ weatherAggregates!.windSpeed.average.toFixed(2) }} mph - {{ weatherAggregates.windSpeed.max.toFixed(2) }} mph + {{ weatherAggregates!.windSpeed.max.toFixed(2) }} mph @@ -111,7 +111,7 @@ - {{ weatherAggregates.windDirectionAverage }} + {{ weatherAggregates!.windDirectionAverage }} @@ -125,7 +125,7 @@ - {{ weatherAggregates.rainTotal.toFixed(2) }}" + {{ weatherAggregates!.rainTotal.toFixed(2) }}" diff --git a/Display/src/app/components/weather/summary/weather-summary.component.ts b/Display/src/app/components/weather/summary/weather-summary.component.ts index 29a1e55..77cb266 100644 --- a/Display/src/app/components/weather/summary/weather-summary.component.ts +++ b/Display/src/app/components/weather/summary/weather-summary.component.ts @@ -3,7 +3,7 @@ import { TimeSpan } from 'src/app/models/time-span'; import { WeatherService } from 'src/app/services/weather/weather.service'; import { WeatherAggregates } from 'src/app/models/weather/weather-aggregates'; -import * as moment from 'moment'; +import moment from 'moment'; @Component({ selector: 'app-weather-summary', @@ -13,7 +13,7 @@ import * as moment from 'moment'; export class WeatherSummaryComponent implements OnInit { public loading = true; - public weatherAggregates: WeatherAggregates = null; + public weatherAggregates: WeatherAggregates | undefined | null = null; private timeSpanValue: TimeSpan = TimeSpan.Last24Hours; private dateValue: moment.Moment = moment().startOf('day'); diff --git a/Display/src/app/models/dashboard/dashboard-layout.ts b/Display/src/app/models/dashboard/dashboard-layout.ts index bd29ba5..4bb8fe5 100644 --- a/Display/src/app/models/dashboard/dashboard-layout.ts +++ b/Display/src/app/models/dashboard/dashboard-layout.ts @@ -1,6 +1,6 @@ import { GridsterItem } from 'angular-gridster2'; export class DashboardLayout { - version: number; - layout: Array; + version: number | undefined; + layout: Array | undefined; } diff --git a/Display/src/app/models/laundry/laundry-status.ts b/Display/src/app/models/laundry/laundry-status.ts index 81ae98f..a41081e 100644 --- a/Display/src/app/models/laundry/laundry-status.ts +++ b/Display/src/app/models/laundry/laundry-status.ts @@ -1,4 +1,4 @@ export class LaundryStatus { - washer = false; - dryer = false; + washer: boolean | undefined = false; + dryer: boolean | undefined = false; } diff --git a/Display/src/app/models/power/power-status-grouped.ts b/Display/src/app/models/power/power-status-grouped.ts index d091bb3..03b96cd 100644 --- a/Display/src/app/models/power/power-status-grouped.ts +++ b/Display/src/app/models/power/power-status-grouped.ts @@ -1,5 +1,5 @@ export class PowerStatusGrouped { - bucket: string; - averageGeneration: number; - averageConsumption: number; + bucket: string | undefined; + averageGeneration: number | undefined; + averageConsumption: number | undefined; } diff --git a/Display/src/app/models/weather/weather-reading-grouped.ts b/Display/src/app/models/weather/weather-reading-grouped.ts index 6d61fed..e2d635a 100644 --- a/Display/src/app/models/weather/weather-reading-grouped.ts +++ b/Display/src/app/models/weather/weather-reading-grouped.ts @@ -1,8 +1,8 @@ export class WeatherReadingGrouped { - bucket: string; - averageTemperature: number; - averagePressure: number; - averageLightLevel: number; - averageHumidity: number; - rainTotal: number; + bucket: string | undefined; + averageTemperature: number | undefined; + averagePressure: number | undefined; + averageLightLevel: number | undefined; + averageHumidity: number | undefined; + rainTotal: number | undefined; } diff --git a/Display/src/app/models/weather/weather-update.ts b/Display/src/app/models/weather/weather-update.ts index ccf4adc..2c8080e 100644 --- a/Display/src/app/models/weather/weather-update.ts +++ b/Display/src/app/models/weather/weather-update.ts @@ -1,25 +1,25 @@ export class WeatherUpdate { - Type: string; - Message: null; - Timestamp: Date; - WindDirection: string; - WindSpeed: number; - Humidity: number; - Rain: number; - Pressure: number; - Temperature: number; - BatteryLevel: number; - LightLevel: number; - Latitude: number; - Longitude: number; - Altitude: number; - SatelliteCount: number; - GpsTimestamp: Date; - WindChill: number; - HeatIndex: number; - DewPoint: number; - PressureDifferenceThreeHour: number; - PressureSlope: number; - PressureAngle: number; - RainLastHour: number; + Type: string | undefined; + Message: null | undefined; + Timestamp: Date | undefined; + WindDirection: string | undefined; + WindSpeed: number | undefined; + Humidity: number | undefined; + Rain: number | undefined; + Pressure: number | undefined; + Temperature: number | undefined; + BatteryLevel: number | undefined; + LightLevel: number | undefined; + Latitude: number | undefined; + Longitude: number | undefined; + Altitude: number | undefined; + SatelliteCount: number | undefined; + GpsTimestamp: Date | undefined; + WindChill: number | undefined; + HeatIndex: number | undefined; + DewPoint: number | undefined; + PressureDifferenceThreeHour: number | undefined; + PressureSlope: number | undefined; + PressureAngle: number | undefined; + RainLastHour: number | undefined; } diff --git a/Display/src/app/models/weather/weather-value-grouped.ts b/Display/src/app/models/weather/weather-value-grouped.ts index b4c1e0f..ab2a39c 100644 --- a/Display/src/app/models/weather/weather-value-grouped.ts +++ b/Display/src/app/models/weather/weather-value-grouped.ts @@ -1,4 +1,4 @@ export class WeatherValueGrouped { - bucket: string; - averageValue: number; + bucket: string | undefined; + averageValue: number | undefined; } diff --git a/Display/src/app/models/weather/weather-value.ts b/Display/src/app/models/weather/weather-value.ts index b71ea18..0ed3633 100644 --- a/Display/src/app/models/weather/weather-value.ts +++ b/Display/src/app/models/weather/weather-value.ts @@ -1,4 +1,4 @@ export class WeatherValue { - timestamp: string; - value: number; + timestamp: string | undefined; + value: number | undefined; } diff --git a/Display/src/app/models/weather/wind-history-grouped.ts b/Display/src/app/models/weather/wind-history-grouped.ts index 6eda87a..51b58f8 100644 --- a/Display/src/app/models/weather/wind-history-grouped.ts +++ b/Display/src/app/models/weather/wind-history-grouped.ts @@ -1,8 +1,8 @@ export class WindHistoryGrouped { - bucket: string; - minimumSpeed: number; - averageSpeed: number; - maximumSpeed: number; - averageDirection: number; + bucket: string | undefined; + minimumSpeed: number | undefined; + averageSpeed: number | undefined; + maximumSpeed: number | undefined; + averageDirection: number | undefined; } diff --git a/Display/src/app/services/laundry/laundry.service.ts b/Display/src/app/services/laundry/laundry.service.ts index b2a8572..03cfabd 100644 --- a/Display/src/app/services/laundry/laundry.service.ts +++ b/Display/src/app/services/laundry/laundry.service.ts @@ -1,12 +1,12 @@ import { Injectable } from '@angular/core'; -import { Observable, BehaviorSubject } from 'rxjs'; +import { Observable, BehaviorSubject, firstValueFrom } from 'rxjs'; import { HubConnectionBuilder, HubConnection } from '@aspnet/signalr'; import { LaundryStatus } from '../../models/laundry/laundry-status'; import { HttpClient } from '@angular/common/http'; class DeviceMessage { - name: string; - status: boolean; + name: string | undefined; + status: boolean | undefined; } @Injectable({ @@ -48,7 +48,7 @@ export class LaundryService { } private async loadLatestStatus() { - const data = await this.httpClient.get(`/api/device-status/status/recent`).toPromise(); + const data = await firstValueFrom(this.httpClient.get(`/api/device-status/status/recent`)); const newStatus = new LaundryStatus(); diff --git a/Display/src/app/services/power/power.service.ts b/Display/src/app/services/power/power.service.ts index 1e10069..a2372da 100644 --- a/Display/src/app/services/power/power.service.ts +++ b/Display/src/app/services/power/power.service.ts @@ -8,7 +8,7 @@ import { PowerStatus } from 'src/app/models/power/power-status'; }) export class PowerService { private connection: HubConnection; - private latestStatus: BehaviorSubject = new BehaviorSubject(null); + private latestStatus: BehaviorSubject = new BehaviorSubject(null); constructor() { this.connection = new HubConnectionBuilder() @@ -22,7 +22,7 @@ export class PowerService { this.connection.start(); } - getLatestStatus(): Observable { + getLatestStatus(): Observable { return this.latestStatus.asObservable(); } } diff --git a/Display/src/app/services/weather/weather.service.ts b/Display/src/app/services/weather/weather.service.ts index 750268a..438acd7 100644 --- a/Display/src/app/services/weather/weather.service.ts +++ b/Display/src/app/services/weather/weather.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { Observable, BehaviorSubject } from 'rxjs'; +import { Observable, BehaviorSubject, firstValueFrom } from 'rxjs'; import { HubConnectionBuilder, HubConnection } from '@aspnet/signalr'; import { WeatherUpdate } from 'src/app/models/weather/weather-update'; import { WeatherValue } from 'src/app/models/weather/weather-value'; @@ -7,14 +7,14 @@ import { HttpClient } from '@angular/common/http'; import { WeatherValueType } from 'src/app/models/weather/weather-value-type'; import { WeatherAggregates } from 'src/app/models/weather/weather-aggregates'; -import * as moment from 'moment'; +import moment from 'moment'; @Injectable({ providedIn: 'root' }) export class WeatherService { private connection: HubConnection; - private latestReading: BehaviorSubject = new BehaviorSubject(null); + private latestReading: BehaviorSubject = new BehaviorSubject(null); constructor(private httpClient: HttpClient) { this.connection = new HubConnectionBuilder() @@ -28,24 +28,24 @@ export class WeatherService { this.connection.start(); } - getLatestReading(): Observable { + getLatestReading(): Observable { return this.latestReading.asObservable(); } - async getReadingValueHistory(valueType: WeatherValueType, start: moment.Moment, end: moment.Moment): Promise { + async getReadingValueHistory(valueType: WeatherValueType, start: moment.Moment, end: moment.Moment): Promise { const startString = start.toISOString(); const endString = end.toISOString(); - const data = await this.httpClient.get(`/api/weather/readings/value-history?weatherValueType=${valueType}&start=${startString}&end=${endString}`).toPromise(); + const data = await firstValueFrom(this.httpClient.get(`/api/weather/readings/value-history?weatherValueType=${valueType}&start=${startString}&end=${endString}`)); return data; } - async getReadingAggregate(start: moment.Moment, end: moment.Moment): Promise { + async getReadingAggregate(start: moment.Moment, end: moment.Moment): Promise { const startString = start.toISOString(); const endString = end.toISOString(); - const data = await this.httpClient.get(`/api/weather/readings/aggregate?start=${startString}&end=${endString}`).toPromise(); + const data = await firstValueFrom(this.httpClient.get(`/api/weather/readings/aggregate?start=${startString}&end=${endString}`)); return data; } diff --git a/Display/tsconfig.json b/Display/tsconfig.json index 7a9aceb..b9ddb52 100644 --- a/Display/tsconfig.json +++ b/Display/tsconfig.json @@ -8,7 +8,7 @@ "downlevelIteration": true, "experimentalDecorators": true, "forceConsistentCasingInFileNames": true, - "strict": false, + "strict": true, "allowSyntheticDefaultImports": true, "module": "esnext", "moduleResolution": "node",