1
|
import {Component, Inject, Injectable, 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
|
import {MatDialog, MatDialogConfig} from "@angular/material/dialog";
|
12
|
import {DialogComponent} from "../../dialog/component/dialog.component";
|
13
|
import {Router} from "@angular/router";
|
14
|
|
15
|
|
16
|
@Component({
|
17
|
selector: 'app-dashboard',
|
18
|
templateUrl: './dashboard.component.html',
|
19
|
styleUrls: ['./dashboard.component.scss']
|
20
|
})
|
21
|
export class DashboardComponent implements OnInit {
|
22
|
|
23
|
groups: Group[];
|
24
|
units: Array<{ drivers?: Drivers; generalInfo?: GeneralInfo; holder?: any; lastpos?: Lastpos; sensors?: Array<Sensor>; unit?: Unit }>;
|
25
|
items = [
|
26
|
{
|
27
|
label: 'Units',
|
28
|
items: [
|
29
|
[
|
30
|
{
|
31
|
label: 'units 1',
|
32
|
items: [{label: 'sensor 1.1'}, {label: 'sensor 1.2'}]
|
33
|
},
|
34
|
{
|
35
|
label: 'units 2',
|
36
|
items: [{label: 'sensor 2.1'}, {label: 'sensor 2.2'}]
|
37
|
}
|
38
|
],
|
39
|
[
|
40
|
{
|
41
|
label: 'units 3',
|
42
|
items: [{label: 'sensor 3.1'}, {label: 'sensor 3.2'}]
|
43
|
},
|
44
|
{
|
45
|
label: 'units 4',
|
46
|
items: [{label: 'sensor 4.1'}, {label: 'sensor 4.2'}]
|
47
|
}
|
48
|
]
|
49
|
]
|
50
|
},
|
51
|
{
|
52
|
label: 'Menu Item',
|
53
|
items: [
|
54
|
[
|
55
|
{
|
56
|
label: 'Event 1',
|
57
|
items: [{label: 'Event 1.1'}, {label: 'Event 1.2'}]
|
58
|
},
|
59
|
{
|
60
|
label: 'Event 2',
|
61
|
items: [{label: 'Event 2.1'}, {label: 'Event 2.2'}]
|
62
|
}
|
63
|
],
|
64
|
[
|
65
|
{
|
66
|
label: 'Event 3',
|
67
|
items: [{label: 'Event 3.1'}, {label: 'Event 3.2'}]
|
68
|
},
|
69
|
{
|
70
|
label: 'Event 4',
|
71
|
items: [{label: 'Event 4.1'}, {label: 'Event 4.2'}]
|
72
|
}
|
73
|
]
|
74
|
]
|
75
|
},
|
76
|
{
|
77
|
label: 'Settings', icon: 'pi pi-fw pi-cog', command: () => this.openSetting()
|
78
|
}
|
79
|
]
|
80
|
|
81
|
constructor(
|
82
|
private groupService: GroupService,
|
83
|
private dataService: DataService,
|
84
|
private router: Router
|
85
|
) {
|
86
|
}
|
87
|
|
88
|
ngOnInit(): void {
|
89
|
this.getUnits();
|
90
|
}
|
91
|
|
92
|
getGroups() {
|
93
|
console.log('Get Groups');
|
94
|
this.groupService.getGroups({Operation: 'GetGroups'}).pipe(
|
95
|
tap(data => this.groups = data)
|
96
|
).toPromise();
|
97
|
}
|
98
|
|
99
|
getUnits() {
|
100
|
this.dataService.getData().pipe(
|
101
|
tap(data => this.units = data)
|
102
|
).toPromise()
|
103
|
}
|
104
|
|
105
|
openSetting() {
|
106
|
this.router.navigate(['/setting']);
|
107
|
}
|
108
|
}
|