diff --git a/src/app/openlp.service.ts b/src/app/openlp.service.ts index c0986af..3f683c0 100644 --- a/src/app/openlp.service.ts +++ b/src/app/openlp.service.ts @@ -7,7 +7,7 @@ import { Slide } from './slide'; import { ServiceItem } from './service_item'; import { Observable } from 'rxjs'; import { map, take } from 'rxjs/operators'; -import { SlideOuterResponse } from './responses'; +import { SlideOuterResponse, PluginDescription } from './responses'; let deserialize = (json, cls) => { var inst = new cls(); @@ -92,11 +92,10 @@ export class OpenLPService { sendItemLive(plugin, id) {} showAlert(text) {} - search(plugin, text) {} addItemToService(plugin, id) {} - getSearchablePlugins() { - return this.http.get(`${this.apiURL}/plugin/search`); + getSearchablePlugins(): Observable { + return this.http.get(`${this.apiURL}/plugin/search`); } // getSearchablePlugins() { @@ -187,7 +186,12 @@ export class OpenLPService { .then(response => console.log(response.json().results)) .catch(this.dropError); } + */ + search(plugin, text) { + return this.http.get(`${this.apiURL}/${plugin}/search`); + } + /* search(plugin, text) { return this.http.get('http://localhost:4316/' + plugin + '/search', buildTextParams(text)) .toPromise() diff --git a/src/app/responses.ts b/src/app/responses.ts index 582010e..bb61051 100644 --- a/src/app/responses.ts +++ b/src/app/responses.ts @@ -7,4 +7,9 @@ interface SlideResponse { export interface SlideOuterResponse { results: SlideResponse; +} + +export interface PluginDescription { + key: string; + name: string; } \ No newline at end of file diff --git a/src/app/search.component.ts b/src/app/search.component.ts index 590499a..2a38077 100644 --- a/src/app/search.component.ts +++ b/src/app/search.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { OpenLPService } from './openlp.service'; +import { PluginDescription } from './responses'; @Component({ selector: 'openlp-remote-search', @@ -7,11 +8,13 @@ template: `

Search

+ - + {{plugin.name}} +
@@ -36,7 +39,7 @@ providers: [OpenLPService] export class OpenLPSearchComponent implements OnInit { - public searchPlugins: OpenLPPlugin[] = null; + public searchPlugins: PluginDescription[] = []; public searchText = null; public searchResults = null; public selectedPlugin: string; @@ -46,7 +49,8 @@ export class OpenLPSearchComponent implements OnInit { onSubmit() { this.currentPlugin = this.selectedPlugin; - // this.openlpService.search(this.currentPlugin, this.searchText).then(items => this.searchResults = items); + this.currentPlugin = "songs"; + this.openlpService.search(this.currentPlugin, this.searchText).subscribe(items => this.searchResults = items); } sendLive(id) { @@ -58,20 +62,6 @@ export class OpenLPSearchComponent implements OnInit { } ngOnInit() { - this.getSearchablePlugins(); + this.openlpService.getSearchablePlugins().subscribe(items => this.searchPlugins = items); } - - getSearchablePlugins() { - // this.openlpService.getSearchablePlugins().then(items => { - // this.searchPlugins = []; - // for (var i = items.length - 1; i >= 0; i--) { - // this.searchPlugins.push({id: items[i][0], name: items[i][1]}) - // } - // }); - } -} - -interface OpenLPPlugin { - id: string; - name: string; -} +} \ No newline at end of file