xufenglei
2018-08-03 bc6b17d35a318b36349da43ea4edff552ec550fe
src/app/routes/raise-dust/real-time/real-time.component.ts
@@ -1,5 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { _HttpClient } from '@delon/theme';
import {environment} from '../../../../environments/environment';
import {Component, OnInit} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {zip} from 'rxjs/observable/zip';
@Component({
  selector: 'app-real-time',
@@ -7,11 +9,37 @@
})
export class RealTimeComponent implements OnInit {
    constructor(
        private http: _HttpClient
    ) { }
  [x: string]: any;
  public monitorPointOptions = [];
  public monitorPoint = 0;
    ngOnInit() {
    }
  public avgs = {e1: '', e2: '', e3: '', e13: ''};
  public levels = [35, 115, 200];
  public devices = [];
  constructor(
    private http: HttpClient
  ) {}
  ngOnInit() {
    this.http.get(environment.SERVER_BASH_URL + 'monitor-point/list/region', {params: {name: 'areaCode', value: '320583'}}).subscribe((res: any) => {
      this.monitorPointOptions = res.data;
    });
  }
  monitorPointChange(id) {
    this.avgs = {e1: '', e2: '', e3: '', e13: ''};
    this.devices = [];
    zip(
      this.http.get(environment.SERVER_BASH_URL + 'demo/avg', {params: {monitorPointId: id}}),
      this.http.get(environment.SERVER_BASH_URL + 'device/professionId', {params: {monitorPointId: id}})
    ).subscribe(
      ([avgs, devices]) => {
        if (!!avgs) {
          this.avgs = <any>avgs;
        }
        if (!!devices['data']) {
          this.devices = devices['data'];
        }
      });
  }
}