2018-08-19 20:37:53 +00:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2018-08-22 20:04:41 +00:00
|
|
|
import { OpenLPService } from '../../openlp.service';
|
|
|
|
import { PluginDescription } from '../../responses';
|
2018-08-19 20:37:53 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'openlp-remote-search',
|
2018-08-22 20:04:41 +00:00
|
|
|
templateUrl: './search.component.html',
|
|
|
|
styleUrls: ['./search.component.scss'],
|
2018-08-19 20:37:53 +00:00
|
|
|
providers: [OpenLPService]
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
export class OpenLPSearchComponent implements OnInit {
|
|
|
|
|
2018-08-20 00:00:32 +00:00
|
|
|
public searchPlugins: PluginDescription[] = [];
|
2018-08-19 20:37:53 +00:00
|
|
|
public searchText = null;
|
|
|
|
public searchResults = null;
|
2018-08-20 12:30:23 +00:00
|
|
|
public selectedPlugin: string = "songs";
|
2018-08-19 20:37:53 +00:00
|
|
|
public currentPlugin: string;
|
|
|
|
|
|
|
|
constructor(private openlpService: OpenLPService) {}
|
|
|
|
|
|
|
|
onSubmit() {
|
|
|
|
this.currentPlugin = this.selectedPlugin;
|
2018-08-20 00:00:32 +00:00
|
|
|
this.currentPlugin = "songs";
|
|
|
|
this.openlpService.search(this.currentPlugin, this.searchText).subscribe(items => this.searchResults = items);
|
2018-08-19 20:37:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sendLive(id) {
|
2018-08-20 13:25:28 +00:00
|
|
|
this.openlpService.sendItemLive(this.currentPlugin, id).subscribe(res => console.log(res));
|
2018-08-19 20:37:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
addToService(id) {
|
2018-08-20 13:25:28 +00:00
|
|
|
this.openlpService.addItemToService(this.currentPlugin, id).subscribe(res => console.log(res));
|
2018-08-19 20:37:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2018-08-20 00:00:32 +00:00
|
|
|
this.openlpService.getSearchablePlugins().subscribe(items => this.searchPlugins = items);
|
2018-08-19 20:37:53 +00:00
|
|
|
}
|
2018-08-20 00:00:32 +00:00
|
|
|
}
|