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

41 lines
1.1 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-search',
templateUrl: './search.component.html',
styleUrls: ['./search.component.scss'],
providers: [OpenLPService]
})
export class SearchComponent implements OnInit {
2018-08-20 00:00:32 +00:00
public searchPlugins: PluginDescription[] = [];
public searchText = null;
public searchResults = null;
public selectedPlugin = 'songs';
public currentPlugin: string;
constructor(private openlpService: OpenLPService) {}
onSubmit() {
this.currentPlugin = this.selectedPlugin;
this.currentPlugin = 'songs';
2018-08-20 00:00:32 +00:00
this.openlpService.search(this.currentPlugin, this.searchText).subscribe(items => this.searchResults = items);
}
sendLive(id) {
2019-10-08 05:43:49 +00:00
this.openlpService.sendItemLive(this.currentPlugin, id).subscribe(res => {});
}
addToService(id) {
2019-10-08 05:43:49 +00:00
this.openlpService.addItemToService(this.currentPlugin, id).subscribe(res => {});
}
ngOnInit() {
2018-08-20 00:00:32 +00:00
this.openlpService.getSearchablePlugins().subscribe(items => this.searchPlugins = items);
}
}