]> git.uio.no Git - u/erikhf/frm.git/commitdiff
merged AddorgUnit into ExpandLevels
authorJulie Hill Roa <julie.hill.roa@gmail.com>
Thu, 26 Nov 2015 14:07:34 +0000 (15:07 +0100)
committerJulie Hill Roa <julie.hill.roa@gmail.com>
Thu, 26 Nov 2015 14:07:34 +0000 (15:07 +0100)
src/components/app.ts
src/components/map/map.ts
src/components/navbar/navbar.css
src/components/search/livesearch.ts
src/components/search/search.html
src/components/search/search.ts
src/components/sidebar/sidebar.html
src/components/sidebar/sidebar.ts
src/css/map.css

index f8d69d070e8bc9fbf7e3e9c513cb543ae0ae0320..183b23b2c7f7ea805d14ec6a224f97ddb07cadef 100644 (file)
@@ -1,16 +1,23 @@
 import {HTTP_PROVIDERS} from 'angular2/http';
 import {Component, View, bootstrap, provide, ELEMENT_PROBE_PROVIDERS} from 'angular2/angular2';
 import {Map} from './map/map';
-import {Navbar} from "./navbar/navbar";
+import {Search} from "./search/search";
 import {Sidebar} from "./sidebar/sidebar";
+import {Navbar} from "./navbar/navbar";
+
 
 declare var System:any;
 
-@Component({
-    selector: 'mou-app',
-    templateUrl: './components/app.html',
-    directives: [Map, Navbar, Sidebar]
-})
-class App {}
+@Component(
+    {
+        selector: 'mou-app',
+        templateUrl: './components/app.html',
+        directives:[Navbar, Map, Search, Sidebar]
+    })
+
+
+class App {
+
+}
 
-bootstrap(App, [HTTP_PROVIDERS, ELEMENT_PROBE_PROVIDERS]);
+bootstrap(App,[HTTP_PROVIDERS, ELEMENT_PROBE_PROVIDERS]);
index 8b6103eeda0750ec4b308ab1f26290f206079491..f4856177f1063f5885d6883c4790f36d7a367395 100644 (file)
@@ -16,15 +16,36 @@ export class Map {
     http: Http;
     LEVEL: number;
     runned: boolean;
+    parent: Object;
+    currentPos = Object;
 
     constructor(http:Http) {
         this.newactive = new EventEmitter();
+        this.newOrg = new EventEmitter();
         this.map = new google.maps.Map(document.getElementById("map"),{center: {lat:0,lng:0}, zoom:12});
         this.init();
         this.http = http;
         this.LEVEL = 2;
         this.runned = false;
         this.getData('?paging=false&level=2',this);
+        this.parent =null ;
+        this.currentPos = null;
+
+    }
+
+    setcurrentPos(latlng){
+        this.currentPos = latlng;
+    }
+     getcurrentPos(){
+         return this.currentPos;
+     }
+
+    setParent(id){
+        this.parent=id;
+    }
+    getParent(){
+        return this.parent;
+
     }
 
     setRunned(value){
@@ -38,32 +59,47 @@ export class Map {
     init() {
 
         let initMap = this.initMap;
+        let instance = this;
         let map = this.map;
-        if (navigator.geolocation) {
-            navigator.geolocation.getCurrentPosition(function (position) {
-                    //let pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
-                let pos = {lat:10,lng:39}
-                    initMap(pos,map);
-                }, function () {
-                //handleNoGeoLocation()
-                }
-            );
-        } else {
-            alert("You do not support geolocation");
-        }
 
+        let pos = {lat: 9.1, lng: -10.6};
+        initMap(pos,map,instance);
 
     }
 
 
-    initMap(location,map){
+    initMap(location,map,instance){
 
-        map.setCenter(location,3);
 
+        map.setCenter(location,2);
+
+        let infowindow = new google.maps.InfoWindow({
+            //TODO: Style this
+            content:'<div>Du you want to add a new OrgUnit here ?    <button onclick="instance.myFunction()">Yes</button></div>'
+        });
+        map.addListener('click', function (e) {
+            instance.setcurrentPos(e.latLng);
+
+            instance.myFunction();
+            var marker = new google.maps.Marker({
+                position: e.latLng,
+                map: map,
+                title: 'newOrg',
+                icon: {
+                    path: google.maps.SymbolPath.CIRCLE,
+                    scale: 5
+                }
+
+            });
+            marker.setMap(map);
+
+            infowindow.open(map, marker);
+
+                 infowindow.addListener('closeclick', function (e) {
+                     marker.setMap(null);
+             });
 
 
-        map.addListener('click', function (event) {
-                console.log(event.latlng);
             }
         );
 
@@ -149,8 +185,10 @@ export class Map {
                     instance.setRunned(true);
 
 
-                    let id = event.feature.O.id;
-                    console.log(id);
+                let id = event.feature.O.id;
+                instance.setParent(id);
+                console.log(id);
+
 
                     instance.map.data.forEach(function(feature) {
                         instance.map.data.remove(feature);
@@ -169,9 +207,19 @@ export class Map {
 
     }
 
+    addUnit(){
+        console.log("Inne i Add funksjonen");
+        let parent = this.getParent();
+        let pos = this.getcurrentPos();
+        let event =  {pos,parent};
+        this.newOrg.next(event);
+
+    }
+
+    myFunction(){
+        console.log("Inne i myfunksjonen");
+      
 
-    createOrgUnit(){
-        console.log('you just added a new organisation unit');
     }
 
     update(event){
index 431daf39d7db671e8aa4257b969245cfa57aee7c..e3e1fbb25f676b690246cc6becd53005393d9fb3 100644 (file)
@@ -2,6 +2,11 @@
     background-color: white;
     height: 85px;
     margin-bottom: 0;
+    border-right: 0 none;
+    border-top: 0 none;
+    border-bottom: 1px solid darkgrey;
+    box-shadow: 0 0 2px darkgrey;
+    border-left: 0 none;
 }
 /*
 
index 2d64f627236480e4dbe6e1cd6686613337ac76ae..40f9249cf9ebf3c7b564023db46c2bc6e3246896 100644 (file)
@@ -16,6 +16,7 @@ declare var zone: Zone;
 export class LiveSearch {
     results:EventEmitter = new EventEmitter();
     loading:EventEmitter = new EventEmitter();
+    
 
     constructor(private el:ElementRef, public http:Http, public search:SearchService) {
 
@@ -53,15 +54,45 @@ export class LiveSearch {
                 .map(res => res.json())
                 .subscribe(
                     zone.bind(orgunits => {
+                        var os = false;
+                        var ls = false;
+                        var ts = false;
                         for (var group in orgunits.organisationUnitGroups){
-                            if(orgunits.organisationUnitGroups[group].name == "Rural"){
+                            if(ownershipSelector.value != ""){
+                                if(orgunits.organisationUnitGroups[group].name == ownershipSelector.value){
+                                    os = true;
+                                }
+                            }
+                            if(ownershipSelector.value == ""){
+                                os = true;
+                            }
+                            if(typeSelector.value != ""){
+                                if(orgunits.organisationUnitGroups[group].name == typeSelector.value){
+                                    ts = true;
+                                }
+                            }
+                            if(typeSelector.value == ""){
+                                ts = true;
+                            }
+                            if(locationSelector.value != ""){
+                                if(orgunits.organisationUnitGroups[group].name == locationSelector.value){
+                                    ls = true;
+                                }
+                            }
+                            if(locationSelector.value == "") {
+                                ls = true;
+                            }
+                            if(os == true && ts == true && ls == true){
                                 filteredOrgunits.push(orgunits);
-                                console.log(filteredOrgunits);
+                                os = false;
+                                ts = false;
+                                ls = false;
                             }
                         }
                     })
                 )
         }
+        console.log(filteredOrgunits);
         return filteredOrgunits;
     }
 }
index 1e9b50d229fb98132ee7f610bb4a03a6367d4c6e..e989414fc1509a30b4a97a537a4a3f22204cc9af 100644 (file)
                class="livesearch"
                name="livesearch"
                id="livesearch"
-
-               placeholder="Search"/>
-    <img [hidden]="!loading"
+               placeholder="Search"
+                />
+    <img class="loadingpic" [hidden]="!loading"
          src="https://www.brown.edu/sites/default/themes/pawtuxet/img/loader-larger.gif">
 
 
-    <div  class="divresult" [hidden]="!orgunits.length">
+    <div  class="divresult" id="divresult" [hidden]="!orgunits.length">
         <ul class="dropdown-menu result"  >
             <li *ng-for="#orgunit of orgunits" (click)="getMoreInfo(orgunit)">
                 <a href="#">{{orgunit.name}}<br/><span>{{orgunit.lastUpdated}}</span></a>
         </ul>
     </div>
 
+
+
 </div>
 
-<button type="button" class="knapp" data-toggle="collapse" data-target="#dropdown-menu"><span class="glyphicon glyphicon-menu-down"></span></button>
+<button type="button" class="knapp" data-toggle="collapse" data-target="#dropdown-menu">
+
+
+    <!--pil opp og ned-->
+
+    <div class="zippy">
+        <div (click)="toggle()" class="zippy__title">
+            {{ visible ? '&xdtri;' : '&xutri;' }} {{title}}
+        </div>
+        <div [hidden]="!visible" class="zippy__content">
+            <content></content>
+        </div>
+    </div>
+
+</button>
 
 <div>
 <ul id="dropdown-menu" class="dropdown-menu">
-
-    <li><a href="#">Another action</a></li>
-    <li><a href="#">Something else here</a></li>
-    <li role="separator" class="divider"></li>
-    <li><a href="#">Separated link</a></li>
+    <li><select class="form-control filtervalg" id="ownershipSelector" (click)="setFilter()">
+        <option value="">-- All Facility Ownerships --</option>
+        <option value="Mission">Mission</option>
+        <option value="NGO">NGO</option>
+        <option value="Private Clinic">Private Clinic</option>
+        <option value="Public facilities">Public facilities</option>
+    </select></li>
+    <li><select class="form-control filtervalg" id="typeSelector" (click)="setFilter()">
+        <option value="">-- All Facility Types --</option>
+        <option value="CHC">CHC</option>
+        <option value="CHP">CHP</option>
+        <option value="Clinic">Clinic</option>
+        <option value="Hospital">Hospital</option>
+        <option value="MCHP">MCHP</option>
+    </select></li>
+    <li><select class="form-control filtervalg" id="locationSelector" (click)="setFilter()">
+        <option value="">-- All locations --</option>
+        <option value="Rural">Rural</option>
+        <option value="Urban">Urban</option>
+    </select></li>
 </ul>
 
 </div>
 
-
-<!--tester pil oppned-->
-<div class="zippy">
-    <div (click)="toggle()" class="zippy__title">
-        {{ visible ? '&blacktriangledown;' : '&blacktriangleright;' }} {{title}}
-    </div>
-    <div [hidden]="!visible" class="zippy__content">
-        <content></content>
-    </div>
-</div>
\ No newline at end of file
index 703911410ea0d7726bebb4bc7b18d81cb1832478..ac7a7c11647bef8e26591020d8c85b139164d793 100644 (file)
@@ -1,4 +1,5 @@
 import {Component,EventEmitter, View, CORE_DIRECTIVES} from 'angular2/angular2';
+import {Http} from 'angular2/http';
 import {LiveSearch} from "./livesearch";
 
 @Component({
@@ -11,8 +12,12 @@ import {LiveSearch} from "./livesearch";
 export class Search {
     orgunits: Array<any> = [];
     loading: boolean = false;
+    facilityType: Array<any> = [];
+    facilityOwnership: Array<any> = [];
+    facilityLocation: Array<any> = [];
 
-    constructor() {
+
+    constructor(public http:Http) {
         this.newsearch = new EventEmitter();
         this.visible = true;
 
@@ -23,12 +28,52 @@ export class Search {
         this.newsearch.next(orgunit.id);
     }
 
-    //tester pil oppned
+    //pil opp og ned
 
     toggle() {
         this.visible = !this.visible;
     }
 
+    /*getFilterTypes(){
+        this.http.get(dhis + "/api/organisationUnitGroups/")
+            .map(res => res.json())
+            .map(res => res.organisationUnitGroups)
+            .subscribe(
+                zone.bind(res => {
+                   for(var i = 0; i < res.length; i++){
+                       this.http.get(res[i].href)
+                        .map(result => result.json())
+                        .map(result => result.organisationUnitGroupSet)
+                        .subscribe(
+                            zone.bind(result => {
+                                if(result.name == "Location Rural/Urban"){
+                                    this.facilityLocation.push(res[i].name);
+                                }
+                                else if(result.name == "Facility Type"){
+                                    this.facilityType.push(res[i].name);
+                                }
+                                else if(result.name == "")
+                            })
+                        )
+                   }
+
+                })
+            )
+    }
+
+    setFilterTypes(){
+
+    }*/
+
+    setFilter(){
+        var text = livesearch.value;
+        livesearch.value = "";
+        console.log(text);
+        for(var i = 0; i < text.length; i++){
+            livesearch.value += text.charAt(i);
+        }
+    }
+
 }
 
 
index 875e2c21dafc75669d5ab2e106e5c0b56db0ae7b..f91ea6b4f075f707c01c3dcce82057b1b5f708fa 100644 (file)
@@ -1,19 +1,77 @@
 <div>
     <div *ng-if="activeOrgUnit">
-        <div class="form-group">
-            <label>Name</label>
-            <input class="form-control" type="text" [(ng-model)]="activeOrgUnit.name" [disabled]="!editmode">
-        </div>
-        <div class="form-group">
-            <label>Shortname</label>
-            <input class="form-control" type="text" [(ng-model)]="activeOrgUnit.shortName" [disabled]="!editmode">
-        </div>
-        <fieldset class="form-group">
-            <legend>Group(s)</legend>
-            <div *ng-for="#group of activeOrgUnit.organisationUnitGroups">
-                <input class="form-control" type="text" [(ng-model)]="group.name" [disabled]="!editmode">
+        <form *ng-if="editmode">
+            <div class="form-group">
+                <label>Name</label>
+                <input class="form-control" type="text" [(ng-model)]="activeOrgUnit.name">
             </div>
-        </fieldset>
-        <button class="btn btn-default" (click)="editmode = !editmode">Edit</button>
+            <div class="form-group">
+                <label>Short Name</label>
+                <input class="form-control" type="text" [(ng-model)]="activeOrgUnit.shortName">
+            </div>
+            <div class="form-group">
+                <label>Description</label>
+                <textarea class="form-control" [(ng-model)]="activeOrgUnit.description" rows="3"></textarea>
+            </div>
+            <div class="form-group">
+                <label>Code</label>
+                <input class="form-control" type="text" [(ng-model)]="activeOrgUnit.code">
+            </div>
+            <div class="form-group">
+                <label>Opening Date</label>
+                <input class="form-control" type="date" [(ng-model)]="activeOrgUnit.openingDate">
+            </div>
+            <div class="form-group">
+                <label>Closed Date</label>
+                <input class="form-control" type="date" [(ng-model)]="activeOrgUnit.closedDate">
+            </div>
+            <div class="form-group">
+                <label>URL</label>
+                <input class="form-control" type="url" [(ng-model)]="activeOrgUnit.closedDate">
+            </div>
+            <fieldset class="form-group">
+                <legend>Group(s)</legend>
+                <div *ng-for="#group of activeOrgUnit.organisationUnitGroups">
+                    <input class="form-control" type="text" [(ng-model)]="group.name">
+                </div>
+            </fieldset>
+        </form>
+        <section *ng-if="!editmode">
+            <label for="actOrgUnitName">Name</label>
+
+            <p id="actOrgUnitName">{{(activeOrgUnit.name) || "[None]"}}</p>
+
+            <label for="actOrgUnitShortName">Short Name</label>
+
+            <p id="actOrgUnitShortName">{{(activeOrgUnit.shortName)||["None"]}}</p>
+
+            <label for="actOrgUnitDescription">Description</label>
+
+            <p id="actOrgUnitDescription">{{(activeOrgUnit.description)||"None"}}</p>
+
+            <label for="actOrgUnitCode">Code</label>
+
+            <p id="actOrgUnitCode">{{(activeOrgUnit.code)||["None"]}}</p>
+
+            <label for="actOrgUnitOpeningDate">Opening Date</label>
+
+            <p id="actOrgUnitOpeningDate">{{activeOrgUnit.openingDate||["None"]}}</p>
+
+            <label for="actOrgUnitClosingDate">Closed Date</label>
+
+            <p id="actOrgUnitClosingDate">{{activeOrgUnit.closingDate||["None"]}}</p>
+
+            <label for="actOrgUnitURL">Url</label>
+
+            <p id="actOrgUnitURL">{{(activeOrgUnit.url) ||["None"]}}</p>
+
+            <label>Group(s)</label>
+            <ul *ng-for="#group of activeOrgUnit.organisationUnitGroups">
+                <li>{{group.name}}</li>
+            </ul>
+        </section>
+        <button class="btn btn-default" (click)="editmode = !editmode">{{editmode ? "Cancel" : "Edit"}}</button>
+        <button *ng-if="editmode" class="btn btn-default" (click)="save()">Save</button>
+
     </div>
 </div>
\ No newline at end of file
index e0232613e1770b4f091e7a3beee67c7748d41d41..736b599f6fc5d023e39711dd711f914a461fdf74 100644 (file)
@@ -23,5 +23,9 @@ export class Sidebar {
             .map(res => res.json())
             .subscribe(res => this.activeOrgUnit = res)
     }
+
+    save(){
+        console.log("YOlo");
+    }
 }
 
index 265c945f603ab2dce74386d813ec2ea36a6a62f3..3e6a6d974d3d0ce62c2303cd8aeb4ba9ad376412 100644 (file)
@@ -1,7 +1,7 @@
 html, body {
     height: 100%;
     padding-top: 70px;
-    background-color: #DBDBDB;
+    background-color: #e2e2e2;
     margin: 0;
 }
 
@@ -12,16 +12,17 @@ html, body {
     width: 100%;
 
 }
+
+
 /*
 .search div{
     position: relative;
 }*/
 
 .results > li > a{
-    margin-top: 20px;
-
+    margin-top: 10px;
     display: block;
-    padding: 3px 20px;
+    padding: 3px 5px;
     clear: both;
     font-weight: 400;
     line-height: 1.42857143;
@@ -39,7 +40,7 @@ html, body {
 
 .dropdown-menu{
     margin-top: -17px;
-    margin-left: 648px;
+    margin-left: 649px;
     background-color: white;
     border-radius: 0px;
 
@@ -48,6 +49,9 @@ html, body {
 
 .dropdown-menu li{
     background-color: white;
+    padding-left: 20px;
+    padding-right: 20px;
+
 
 }
 
@@ -57,17 +61,22 @@ html, body {
     margin-left: 150px;
 }
 
+
 #livesearch{
+    box-shadow: 0 0 1px darkgrey;
     width: 500px;
-    padding: 15px 0 15px 20px;
+    padding: 5px 0 5px 20px;
     font-size: 16px;
     font-family: Montserrat, sans-serif;
-    border: 0 none;
+    border-left: 1px solid darkgrey;
+    border-top:1px solid darkgrey;
+    border-bottom: 1px solid darkgrey;
+    border-right: 0 none;
     height: 52px;
     margin-right: 0;
     color: white;
     outline: none;
-    background: #DBDBDB;
+    background: #e2e2e2;
     float: left;
     box-sizing: border-box;
     transition: all 0.15s;
@@ -85,7 +94,8 @@ html, body {
 :-ms-input-placeholder {
     color: white;
 }
-#search_text:focus {
+
+#livesearch:focus {
     background: darkgrey;
 }
 
@@ -104,7 +114,11 @@ html, body {
 
 .knapp
 {
-    border: 0 none;
+    box-shadow: 0 0 1px darkgrey;
+    border-right: 1px solid darkgrey;
+    border-top:1px solid darkgrey;
+    border-bottom: 1px solid darkgrey;
+    border-left: 0 none;
     background: #BAB8B8;
     width: 60px;
     float: left;
@@ -122,7 +136,7 @@ html, body {
 }
 
 .result{
-    width: 357px;
+    width: 500px;
     margin-left: 150px;
     display: block;
     position: absolute;
@@ -131,7 +145,7 @@ html, body {
     z-index: 1000;
     float: left;
     min-width: 160px;
-    padding: 5px 0;
+    padding: 1px 0;
     font-size: 14px;
     text-align: left;
     list-style: none;
@@ -152,4 +166,27 @@ html, body {
     margin-left: 20px;
     padding: 0.5em 0.5em 0.5em 0;
     float: none;
-}
\ No newline at end of file
+}
+
+.loadingpic{
+    width: 50px;
+    height: 50px;
+}
+
+.filtervalg{
+    box-shadow: 0 0 1px darkgrey;
+    margin-top: 10px;
+    margin-bottom: 10px;
+    width: 200px;
+    height: 20px;
+    font-size: 12px;
+    font-family: Montserrat, sans-serif;
+    border: 1px solid darkgrey;
+    color: black;
+    outline: none;
+    background: white;
+    box-sizing: border-box;
+    transition: all 0.15s;
+}
+
+