[search][map] Sending ID of clicked search result to map component
authorErik Haider Forsén <erikhf@ifi.uio.no>
Thu, 19 Nov 2015 17:01:35 +0000 (18:01 +0100)
committerErik Haider Forsén <erikhf@ifi.uio.no>
Thu, 19 Nov 2015 17:01:35 +0000 (18:01 +0100)
src/components/app.html
src/components/map/map.ts
src/components/search/search.ts

index 265e722..9ef7c51 100644 (file)
@@ -1,11 +1,11 @@
 <div class="container">
     <div class="nav">
         Navbar
-        <mou-search></mou-search>
+        <mou-search (newsearch)="map.update($event)"></mou-search>
         <mou-filter></mou-filter>
     </div>
 
-    <mou-map></mou-map>
+    <mou-map #map></mou-map>
 
 </div>
 
index 8bed45f..5c9e9bf 100644 (file)
@@ -1,5 +1,5 @@
 import {Component, CORE_DIRECTIVES,} from 'angular2/angular2';
-import {Headers, Http} from 'angular2/http';
+import {Http} from 'angular2/http';
 
 
 @Component({
@@ -17,19 +17,8 @@ export class Map {
 
     constructor(http:Http) {
         this.initMap();
-
-        var authHeader = new Headers();
-        authHeader.append('Authorization', 'Basic YWRtaW46ZGlzdHJpY3Q=');
-        this.result = {organisationUnits: []};
-        // http.get(dhisAPI+'/api/organisationUnits?paging=false', {headers: authHeader})
-        http.get('http://mydhis.com:8082/api/organisationUnits?paging=false', {headers: authHeader})
-            .map(res => res.json()).subscribe(
-            res => this.result = res,
-            error => this.logError(error)
-        );
     }
 
-
     initMap() {
 
         if (navigator.geolocation) {
@@ -62,6 +51,10 @@ export class Map {
 
     }
 
+    update(orgUnitId){
+        console.log("Her kan jeg lage et http kall og hente inn informasjon om " + orgUnitId);
+    }
+
 
     //Other map functions
    // addMarker(lat, lng) {
@@ -75,7 +68,6 @@ export class Map {
 
     logError(error) {
         console.error(error);
-
     }
 
 }
index d9d90ae..2c2a6ae 100644 (file)
@@ -1,20 +1,24 @@
-import {Component, View, CORE_DIRECTIVES} from 'angular2/angular2';
+import {Component,EventEmitter, View, CORE_DIRECTIVES} from 'angular2/angular2';
 import {LiveSearch} from "./livesearch";
 
 @Component({
     selector: 'mou-search',
     directives: [CORE_DIRECTIVES, LiveSearch],
+    events: ['newsearch'],
     templateUrl: './components/search/search.html',
     styleUrls: ['./components/search/search.css']
 })
 export class Search {
-    orgunits: Array<any> = [];
-    loading: boolean = false;
+    orgunits:Array<any> = [];
+    loading:boolean = false;
 
-    getMoreInfo(orgunit){
-        console.log(orgunit.id);
+    constructor() {
+        this.newsearch = new EventEmitter();
     }
 
+    getMoreInfo(orgunit) {
+        this.newsearch.next(orgunit.id);
+    }
 
 }