web-remote/src/app/components/search/search.component.ts

40 lines
1.2 KiB
TypeScript
Raw Normal View History

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