-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.component.ts
46 lines (37 loc) · 1.15 KB
/
home.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { Component, OnInit } from '@angular/core';
import { RemootioAngularService, IGateState } from 'dist/remootio-angular';
import { Subject } from 'rxjs';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit {
private gateImage: string = "{gateImage}";
public gateState$ = new Subject<IGateState>();
public gateImage$ = new Subject<string>();
constructor(private remootioService: RemootioAngularService) {
remootioService.gateState$.subscribe(gateState => {
this.gateState$.next(gateState);
});
this.gateImage$.next(this.gateImage);
}
ngOnInit(): void {
this.remootioService.connect({
deviceIp: '{deviceIp}',
apiSecretKey: '{apiSecretKey}',
apiAuthKey: '{apiAuthKey}',
autoReconnect: true
});
setInterval(() => this.gateImage$.next(`${this.gateImage}?${Date.now()}`), 1000);
}
get isAuthenticated(): boolean {
return this.remootioService.isAuthenticated;
}
closeGate() {
this.remootioService.closeGate();
}
openGate() {
this.remootioService.openGate();
}
}