Setup proxy, change scaling, and add chart zoom

This commit is contained in:
2019-10-05 20:19:25 -04:00
parent 4f2a0915ad
commit 76e6955a03
6 changed files with 26 additions and 8 deletions

View File

@@ -68,7 +68,8 @@
"serve": { "serve": {
"builder": "@angular-devkit/build-angular:dev-server", "builder": "@angular-devkit/build-angular:dev-server",
"options": { "options": {
"browserTarget": "Display:build" "browserTarget": "Display:build",
"proxyConfig": "proxy.conf.json"
}, },
"configurations": { "configurations": {
"production": { "production": {

16
Display/proxy.conf.json Normal file
View File

@@ -0,0 +1,16 @@
{
"/api/weather": {
"target": "http://172.23.10.3",
"secure": false,
"logLevel": "debug",
"changeOrigin": true
},
"/api/hub": {
"target": "ws://172.23.10.3:80",
"ws": true
},
"/socket.io": {
"target": "http://172.23.10.30:80",
"ws": true
}
}

View File

@@ -20,7 +20,7 @@ import { DashboardComponent } from './components/dashboard/dashboard.component';
import { WeatherChartsComponent } from './components/weather/charts/weather-charts.component'; import { WeatherChartsComponent } from './components/weather/charts/weather-charts.component';
import { WeatherCurrentComponent } from './components/weather/current/weather-current.component'; import { WeatherCurrentComponent } from './components/weather/current/weather-current.component';
const config: SocketIoConfig = { url: 'http://home.kaczorzoo.net:9091', options: {} }; const config: SocketIoConfig = { url: '/api/laundry', options: {} };
@NgModule({ @NgModule({
declarations: [ declarations: [

View File

@@ -114,7 +114,7 @@ export class WeatherChartsComponent implements OnInit {
const startString = start.toISOString(); const startString = start.toISOString();
const endString = end.toISOString(); const endString = end.toISOString();
const request = this.httpClient.get<WeatherReadingGrouped[]>(`http://172.23.10.3/api/weather/readings/history-grouped?start=${startString}&end=${endString}&bucketMinutes=5`); const request = this.httpClient.get<WeatherReadingGrouped[]>(`/api/weather/readings/history-grouped?start=${startString}&end=${endString}&bucketMinutes=5`);
request.subscribe(data => { request.subscribe(data => {
const seriesData: Array<SeriesLineOptions> = []; const seriesData: Array<SeriesLineOptions> = [];
@@ -127,16 +127,17 @@ export class WeatherChartsComponent implements OnInit {
data.forEach(dataElement => { data.forEach(dataElement => {
const date = Date.parse(dataElement.bucket); const date = Date.parse(dataElement.bucket);
seriesData[0].data.push([date, dataElement.averagePressureTemperature]); seriesData[0].data.push([date, dataElement.averagePressureTemperature]);
seriesData[1].data.push([date, dataElement.averagePressure / 33.864]); seriesData[1].data.push([date, dataElement.averagePressure / 33.864 / 100]);
seriesData[2].data.push([date, dataElement.averageHumidity]); seriesData[2].data.push([date, dataElement.averageHumidity]);
seriesData[3].data.push([date, dataElement.averageLightLevel]); seriesData[3].data.push([date, dataElement.averageLightLevel * 100]);
}); });
const title = this.selectedTimeSpan === TimeSpan.Last24Hours ? this.timeSpanItems[TimeSpan.Last24Hours] : this.getSelectedDateDisplayString(); const title = this.selectedTimeSpan === TimeSpan.Last24Hours ? this.timeSpanItems[TimeSpan.Last24Hours] : this.getSelectedDateDisplayString();
this.chart = new Chart({ this.chart = new Chart({
chart: { chart: {
type: 'line' type: 'line',
zoomType: "x"
}, },
title: { title: {
text: title text: title

View File

@@ -50,7 +50,7 @@
Light Light
</td> </td>
<td> <td>
{{ latestReading.LightLevel.toFixed(2) }} {{ ((latestReading.LightLevel / latestReading.BatteryLevel) * 100).toFixed(2) }}%
</td> </td>
</tr> </tr>
</table> </table>

View File

@@ -12,7 +12,7 @@ export class WeatherService {
constructor() { constructor() {
this.connection = new HubConnectionBuilder() this.connection = new HubConnectionBuilder()
.withUrl('http://172.23.10.3:80/api/hub/weather') .withUrl('/api/hub/weather')
.build(); .build();
this.connection.on('LatestReading', (message: string) => { this.connection.on('LatestReading', (message: string) => {