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]);
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){
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);
}
);
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);
}
+ 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){
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;
}
/*
export class LiveSearch {
results:EventEmitter = new EventEmitter();
loading:EventEmitter = new EventEmitter();
+
constructor(private el:ElementRef, public http:Http, public search:SearchService) {
.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;
}
}
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 ? '▽' : '△' }} {{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 ? '▾' : '▸' }} {{title}}
- </div>
- <div [hidden]="!visible" class="zippy__content">
- <content></content>
- </div>
-</div>
\ No newline at end of file
import {Component,EventEmitter, View, CORE_DIRECTIVES} from 'angular2/angular2';
+import {Http} from 'angular2/http';
import {LiveSearch} from "./livesearch";
@Component({
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;
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);
+ }
+ }
+
}
<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
.map(res => res.json())
.subscribe(res => this.activeOrgUnit = res)
}
+
+ save(){
+ console.log("YOlo");
+ }
}
html, body {
height: 100%;
padding-top: 70px;
- background-color: #DBDBDB;
+ background-color: #e2e2e2;
margin: 0;
}
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;
.dropdown-menu{
margin-top: -17px;
- margin-left: 648px;
+ margin-left: 649px;
background-color: white;
border-radius: 0px;
.dropdown-menu li{
background-color: white;
+ padding-left: 20px;
+ padding-right: 20px;
+
}
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;
:-ms-input-placeholder {
color: white;
}
-#search_text:focus {
+
+#livesearch:focus {
background: darkgrey;
}
.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;
}
.result{
- width: 357px;
+ width: 500px;
margin-left: 150px;
display: block;
position: absolute;
z-index: 1000;
float: left;
min-width: 160px;
- padding: 5px 0;
+ padding: 1px 0;
font-size: 14px;
text-align: left;
list-style: none;
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;
+}
+
+