|
|
@@ -1,8 +1,6 @@
|
|
|
import { Component, OnDestroy, OnInit } from '@angular/core';
|
|
|
import { ActivatedRoute } from '@angular/router';
|
|
|
import * as moment from 'moment-timezone';
|
|
|
-// import { AnalyticsService } from '../../shared/api/endpoints/services/analytics.service';
|
|
|
-// import { AggregationModel } from '../../shared/models/aggregationModel';
|
|
|
import { GraphLoader } from '../../shared/graph-loading/graphloader';
|
|
|
import { ObservationService } from '../../shared/api/endpoints/services/observation.service';
|
|
|
import { HttpResponse } from '@angular/common/http';
|
|
|
@@ -24,10 +22,7 @@ export class SensorComponent implements OnInit, OnDestroy {
|
|
|
data = [];
|
|
|
time = [];
|
|
|
from: Date = moment().hour(0).minutes(0).subtract(7, 'days').toDate();
|
|
|
- to: Date = moment().toDate();
|
|
|
- //showAggregation = false;
|
|
|
- //aggregationFunction: AggregationModel[];
|
|
|
- //selectedAggregationFunction = 'HOUR';
|
|
|
+ to: Date = moment().toDate();
|
|
|
sensor: Sensor;
|
|
|
dateChanged = false;
|
|
|
unitDescription: string;
|
|
|
@@ -35,8 +30,7 @@ export class SensorComponent implements OnInit, OnDestroy {
|
|
|
subscription: Subscription[] = [];
|
|
|
|
|
|
constructor(
|
|
|
- private activatedRoute: ActivatedRoute,
|
|
|
- //private analyticsService: AnalyticsService,
|
|
|
+ private activatedRoute: ActivatedRoute,
|
|
|
private observationService: ObservationService,
|
|
|
private toastService: ToastService,
|
|
|
private sensorsService: SensorsService,
|
|
|
@@ -61,13 +55,7 @@ export class SensorComponent implements OnInit, OnDestroy {
|
|
|
}
|
|
|
});
|
|
|
this.sensorId = parseInt(this.activatedRoute.snapshot.paramMap.get('sensorId'), 10);
|
|
|
- this.unitId = parseInt(this.activatedRoute.snapshot.paramMap.get('unitId'), 10);
|
|
|
- // this.aggregationFunction = [
|
|
|
- // { name: 'Hour', code: 'HOUR' },
|
|
|
- // { name: 'Day', code: 'DAY' },
|
|
|
- // { name: 'Month', code: 'MONTH' },
|
|
|
- // { name: 'Year', code: 'YEAR' }
|
|
|
- // ];
|
|
|
+ this.unitId = parseInt(this.activatedRoute.snapshot.paramMap.get('unitId'), 10);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -93,37 +81,7 @@ export class SensorComponent implements OnInit, OnDestroy {
|
|
|
showGraph() {
|
|
|
const range: Date[] = [this.from, this.to];
|
|
|
this.getObservations(range);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Get data from analytics endpoint
|
|
|
- * @param range from and to interval
|
|
|
- */
|
|
|
- // getAnalytics(range: Date[]) {
|
|
|
- // this.analyticsService.getAnalytics$Response({
|
|
|
- // unit_id: this.unitId, sensor_id: this.sensorId,
|
|
|
- // from: moment(range[0]).format('yyyy-MM-DD HH:mm:ssZ').slice(0, -3),
|
|
|
- // to: moment(range[1]).format('yyyy-MM-DD HH:mm:ssZ').slice(0, -3), interval: this.selectedAggregationFunction
|
|
|
- // }).pipe(
|
|
|
- // map((response: HttpResponse<any>) => {
|
|
|
- // if (response.status === 200) {
|
|
|
- // return response.body;
|
|
|
- // } else if (response.status === 204) {
|
|
|
- // this.toastService.showWarningNoData();
|
|
|
- // return response.body;
|
|
|
- // } else {
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- // })
|
|
|
- // ).subscribe(
|
|
|
- // observations => {
|
|
|
- // if (observations) {
|
|
|
- // GraphLoader.getGraphWithInterval(this.sensorId, observations[this.sensorId].data, observations[this.sensorId].interval * 1000, this.sensor, '#view', true);
|
|
|
- // } else {
|
|
|
- // GraphLoader.getGraph(null, null, null, '#view', null);
|
|
|
- // }
|
|
|
- // }, err => this.toastService.showError(err.error.message));
|
|
|
- // }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* Get data from observation endpoint
|