diff --git a/src/services/search/search.service.ts b/src/services/search/search.service.ts index 2391639..31043ce 100644 --- a/src/services/search/search.service.ts +++ b/src/services/search/search.service.ts @@ -4,6 +4,7 @@ import { Observable } from 'rxjs/Observable'; import 'rxjs/add/operator/catch'; import 'rxjs/add/operator/map'; import { Task } from '../../models/task'; +import { FaqSummary } from '../../models/faqSummary'; @Injectable() export class SearchService { @@ -11,6 +12,21 @@ export class SearchService { constructor(private http: Http) {} + searchFaqSummaries(searchTerms: string[]): Observable { + const headers = new Headers({ 'X-API-Key': '57f533ed-cafa-494b-8d41-6ef68ef955bb' }); + const queryString = new URLSearchParams(); + queryString.paramsMap = new Map(); + queryString.paramsMap.set('tag', searchTerms); + + const options = new RequestOptions({ + headers: headers, + search: queryString, + }); + + return this.http.get(this.apiUrl + 'storyweb/faq', options) + .map(response => response.json().contents); + } + searchTasks(searchTerms: string[]): Observable { const headers = new Headers({ 'X-API-Key': '57f533ed-cafa-494b-8d41-6ef68ef955bb' }); const queryString = new URLSearchParams(); diff --git a/src/views/faq/faq.component.html b/src/views/faq/faq.component.html index 3bf9bdb..47e8e66 100644 --- a/src/views/faq/faq.component.html +++ b/src/views/faq/faq.component.html @@ -9,47 +9,54 @@

Automated FAQ

+
+ Error while searching: {{searchError}}. +
Please try again. +
+
+ + + + + + + + + + + + + + +
+ timelapse + timelapse + +

{{faq.faqType === 'PAIN'? 'WTF?!' : 'YAY!'}}: {{faq.eventDescription}}

+

{{faq.faqAnnotation}}

+

{{faq.position | date: 'MMM dd yyyy'}} + + + + + + +

- - - - - - - - - - - - - - - - - - -
- timelapse - timelapse - -

{{faq.faqType === 'PAIN'? 'WTF?!' : 'YAY!'}}: {{faq.eventDescription}}

-

{{faq.faqAnnotation}}

-

{{faq.position | date: 'MMM dd yyyy'}} - - - - - - -

+
{{faq.taskPainInSeconds | amDuration:'seconds'}}{{faq.taskPainInSeconds | amDuration:'seconds'}}{{faq.journeyPainInSeconds | amDuration:'seconds' }}
+
{{faq.journeyPainInSeconds | amDuration:'seconds' }}
+
- + \ No newline at end of file diff --git a/src/views/faq/faq.component.ts b/src/views/faq/faq.component.ts index 9dbba87..9fa193c 100644 --- a/src/views/faq/faq.component.ts +++ b/src/views/faq/faq.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, ViewEncapsulation } from '@angular/core'; import { FaqSummary } from '../../models/faqSummary'; -import { FaqService } from '../../services'; +import { FaqService, SearchService } from '../../services'; import {Router} from "@angular/router"; @@ -15,8 +15,11 @@ export class FaqComponent implements OnInit { private faqs: FaqSummary[]; private errorMessage: string; - constructor( private faqService: FaqService, public router: Router ) { + private query: string; + private searchError: string; + constructor(private faqService: FaqService, private searchService: SearchService, + public router: Router) { } ngOnInit() { @@ -40,4 +43,12 @@ export class FaqComponent implements OnInit { } } + search(query: string) { + this.searchService.searchFaqSummaries(query.split(' ')) + .subscribe( + faqs => this.faqs = faqs, + error => this.searchError = error, + ); + } + }