2018-08-19 20:37:53 +00:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
|
import { Router } from '@angular/router'
|
|
|
|
|
|
|
|
import { OpenLPService } from './openlp.service';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'openlp-remote-service',
|
|
|
|
template: `
|
|
|
|
<h3>Service items:</h3>
|
|
|
|
<div>
|
|
|
|
<mat-nav-list>
|
|
|
|
<a mat-list-item *ngFor="let item of items;let counter = index;" (click)="onItemSelected(counter)" [class.selected]="item.selected">
|
|
|
|
<p mat-line>{{item.title}}<p>
|
|
|
|
</a>
|
|
|
|
</mat-nav-list>
|
|
|
|
</div>
|
|
|
|
`,
|
|
|
|
providers: [OpenLPService]
|
|
|
|
})
|
|
|
|
|
|
|
|
export class OpenLPServiceComponent implements OnInit {
|
2018-08-22 19:29:20 +00:00
|
|
|
items = [];
|
2018-08-19 20:37:53 +00:00
|
|
|
ngOnInit() {
|
|
|
|
this.getServiceItems();
|
|
|
|
}
|
|
|
|
|
|
|
|
onItemSelected(item) {
|
2018-08-20 13:25:28 +00:00
|
|
|
this.openlpService.setServiceItem(item).subscribe(res => console.log(res));
|
2018-08-19 20:37:53 +00:00
|
|
|
this.router.navigate(['slides']);
|
|
|
|
}
|
|
|
|
|
|
|
|
getServiceItems() {
|
2018-08-20 12:12:30 +00:00
|
|
|
this.openlpService.getServiceItems().subscribe(items => this.items = items);
|
2018-08-19 20:37:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
constructor(private openlpService: OpenLPService, private router: Router) {
|
|
|
|
openlpService.stateChanged$.subscribe(item => this.getServiceItems());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|