Modified to query the api with the search string
authorErik Haider Forsén <erik@forsen.not>
Sat, 14 Nov 2015 11:04:09 +0000 (12:04 +0100)
committerErik Haider Forsén <erik@forsen.not>
Sat, 14 Nov 2015 11:04:09 +0000 (12:04 +0100)
src/components/search/SearchService.ts
src/components/search/livesearch.ts

index 5c77024..cc56f5a 100644 (file)
@@ -4,32 +4,16 @@ import * as Rx from '@reactivex/rxjs/dist/cjs/Rx';
 
 @Injectable()
 export class SearchService {
-/*
-    data: Rx.Observable<any[]>;
-
-    constructor(http: Http){
-        this.data = http.get('testData.json')
-            .map(res => res.json())
-            .map(res => res.items);
-    }
-*/
 
     constructor(public http: Http){
 
     }
     search(query: string): Rx.Observable<any[]>{
-        return this.http.get('testData.json')
+        return this.http.get(dhisAPI + "/organisationUnits?paging=false&query=" + query)
             .map(res=>res.json())
             .map(res => res.organisationUnits)
-            .filter(function(name:string){
-                return name.toLowerCase().indexOf(query.toLowerCase());
-            });
+            .filter(orgunits => orgunits);
 
-            //.map(res => res.json())
-            //.map(res => res.organizationUnits);
-    //.filter(function(name){
-    //        return name.indexOf(query);
-    //    })
     }
 }
 
index 2b31954..96e7e7a 100644 (file)
@@ -32,8 +32,9 @@ export class LiveSearch {
             .do(zone.bind(() => this.loading.next(false)))
             .subscribe(
                 zone.bind( orgunits => {
-                    //this.results.next(orgunits);
+                    console.log("orgunits: ");
                     console.log(orgunits);
+                    //this.results.next(orgunits);
                     this.results.next(orgunits);
                 }),
                 zone.bind(err => {