1 |
675bbb8c
|
hlavja
|
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 |
bb7795cd
|
hlavja
|
showUnitPopup = false;
|
22 |
|
|
editedUnit: Unit;
|
23 |
675bbb8c
|
hlavja
|
|
24 |
|
|
constructor(
|
25 |
|
|
private groupService: GroupService,
|
26 |
|
|
private dataService: DataService
|
27 |
|
|
) {
|
28 |
|
|
}
|
29 |
|
|
|
30 |
|
|
ngOnInit(): void {
|
31 |
8c28e5ab
|
hlavja
|
this.getUnits();
|
32 |
675bbb8c
|
hlavja
|
}
|
33 |
|
|
|
34 |
|
|
getGroups() {
|
35 |
2c5da396
|
hlavja
|
console.log('Get Groups');
|
36 |
675bbb8c
|
hlavja
|
this.groupService.getGroups({Operation: 'GetGroups'}).pipe(
|
37 |
|
|
tap(data => this.groups = data)
|
38 |
|
|
).toPromise();
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
getUnits() {
|
42 |
|
|
this.dataService.getData().pipe(
|
43 |
|
|
tap(data => this.units = data)
|
44 |
|
|
).toPromise()
|
45 |
|
|
}
|
46 |
|
|
|
47 |
bb7795cd
|
hlavja
|
editUnit($event: MouseEvent, unit: Unit) {
|
48 |
|
|
$event.stopPropagation();
|
49 |
|
|
this.editedUnit = unit;
|
50 |
|
|
this.showUnitPopup = true;
|
51 |
|
|
}
|
52 |
675bbb8c
|
hlavja
|
}
|