Projekt

Obecné

Profil

Stáhnout (1.62 KB) Statistiky
| Větev: | Tag: | Revize:
1
import { Component, OnInit } from '@angular/core';
2
import {Group} from '../../shared/api/endpoints/models/group';
3
import {Drivers} from '../../shared/api/endpoints/models/drivers';
4
import {GeneralInfo} from '../../shared/api/endpoints/models/general-info';
5
import {Lastpos} from '../../shared/api/endpoints/models/lastpos';
6
import {Sensor} from '../../shared/api/endpoints/models/sensor';
7
import {Unit} from '../../shared/api/endpoints/models/unit';
8
import {GroupService} from '../../shared/api/endpoints/services/group.service';
9
import {DataService} from '../../shared/api/endpoints/services/data.service';
10
import {tap} from 'rxjs/operators';
11

    
12
@Component({
13
  selector: 'app-dashboard',
14
  templateUrl: './dashboard.component.html',
15
  styleUrls: ['./dashboard.component.scss']
16
})
17
export class DashboardComponent implements OnInit {
18

    
19
  groups: Group[];
20
  units: Array<{ drivers?: Drivers; generalInfo?: GeneralInfo; holder?: any; lastpos?: Lastpos; sensors?: Array<Sensor>; unit?: Unit }>;
21
  showUnitPopup = false;
22
  showSensorPopup = false;
23
  editedUnit: Unit;
24
  editedSensor: Sensor;
25

    
26
  constructor(
27
    private groupService: GroupService,
28
    private dataService: DataService
29
  ) {
30
  }
31

    
32
  ngOnInit(): void {
33
    this.getUnits();
34
  }
35

    
36
  getGroups() {
37
    console.log('Get Groups');
38
    this.groupService.getGroups({Operation: 'GetGroups'}).pipe(
39
      tap(data => this.groups = data)
40
    ).toPromise();
41
  }
42

    
43
  getUnits() {
44
    this.dataService.getData().pipe(
45
      tap(data => this.units = data)
46
    ).toPromise()
47
  }
48

    
49
  editUnit($event: MouseEvent, unit: Unit) {
50
    $event.stopPropagation();
51
    this.editedUnit = unit;
52
    this.showUnitPopup = true;
53
  }
54
}
(3-3/3)