Revert "[apiService] created a service for getting the API URL"
authorErik Haider Forsén <erik@forsen.not>
Sat, 14 Nov 2015 14:27:56 +0000 (15:27 +0100)
committerErik Haider Forsén <erik@forsen.not>
Sat, 14 Nov 2015 14:27:56 +0000 (15:27 +0100)
This reverts commit aca80f6a97807505358ebe0d62d58e3de67252c3.

src/components/app.ts
src/components/dhisapi/dhisapiService.ts [deleted file]
src/components/filter/filter.ts
src/index.html

index a3d4fd3..cb9479e 100644 (file)
@@ -3,7 +3,6 @@ import {Component, View, bootstrap, provide} from 'angular2/angular2';
 import {Map} from './map/map';
 import {Search} from "./search/search";
 import {Filter} from "./filter/filter";
-import {DhisapiService} from "./dhisapi/dhisapiService";
 
 declare var System:any;
 
@@ -11,18 +10,12 @@ declare var System:any;
     {
         selector: 'mou-app',
         templateUrl: './components/app.html',
-        directives:[Filter, Map, Search],
-        providers: [DhisapiService]
+        directives:[Filter, Map, Search]
     })
 
 
 class App {
-    constructor(dhis: DhisapiService){
-        dhis.getApiURL(function(uri){
-            console.log(uri);
-        })
-    }
 
 }
 
-bootstrap(App,[HTTP_PROVIDERS,DhisapiService]);
+bootstrap(App,[HTTP_PROVIDERS]);
\ No newline at end of file
diff --git a/src/components/dhisapi/dhisapiService.ts b/src/components/dhisapi/dhisapiService.ts
deleted file mode 100644 (file)
index 38f9c4b..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-import {Injectable} from 'angular2/angular2';
-import {Http} from 'angular2/http';
-
-@Injectable()
-export class DhisapiService {
-    private http: Http;
-
-    constructor(http: Http){
-        this.http = http;
-    }
-
-    getApiURL = function(callback){
-        this.http.get('../manifest.webapp')
-            .map(res => res.json())
-            .map(res => res.activities.dhis.href)
-            .subscribe( res => callback(res));
-    }
-}
index 9181b79..a3a63b7 100644 (file)
@@ -1,18 +1,15 @@
 import {Component, View, CORE_DIRECTIVES} from 'angular2/angular2';
 import {Headers, Http} from 'angular2/http';
-import {DhisapiService} from "../dhisapi/dhisapiService";
 
 @Component({
     selector: 'mou-filter',
     directives: [CORE_DIRECTIVES],
-    templateUrl: './components/filter/filter.html',
-    providers: [DhisapiService]
+    templateUrl: './components/filter/filter.html'
 })
 
 export class Filter {
     result: Object;
 
-    dhis: DhisapiService;
     // Example HTTP request
 
     /*
@@ -34,15 +31,4 @@ export class Filter {
     }
 
     */
-
-    constructor(dhis: DhisapiService){
-        this.dhis = dhis;
-    }
-
-    onInit(){
-        this.dhis.getApiURL(function(uri){
-            console.log("Dette er uri: " + uri);
-        })
-    }
-
 }
index 3b1e667..c712323 100644 (file)
@@ -3,7 +3,13 @@
 <head>
     <meta charset="UTF-8">
     <title>Sample App</title>
-
+    <script>
+        var xhReq = new XMLHttpRequest();
+        xhReq.open("GET", "../manifest.webapp", false);
+        xhReq.send(null);
+        var serverResponse = JSON.parse(xhReq.responseText);
+        var dhisAPI = serverResponse.activities.dhis.href;
+    </script>
     <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDlgw6kZAQvD8ex_md-6wb_NcnVlZWkbE4"></script>
     <script src="../node_modules/systemjs/dist/system.src.js"></script>
     <script src="../node_modules/angular2/bundles/angular2.dev.js"></script>