1 import {Component, NgFor, NgIf, NgModel, CORE_DIRECTIVES,FORM_DIRECTIVES} from 'angular2/angular2';
2 import {Http, Headers} from 'angular2/http';
6 selector: 'mou-sidebar',
7 directives: [CORE_DIRECTIVES, FORM_DIRECTIVES, NgFor, NgModel, NgIf],
8 templateUrl: './components/sidebar/sidebar.html',
11 border-left: 5px solid #42A948; /* green */
14 border-left: 5px solid #a94442; /* red */
18 export class Sidebar {
24 constructor(http:Http) {
26 this.editmode = false;
30 this.http.get(dhisAPI + "/api/organisationUnits/" + orgunitId)
31 .map(res => res.json())
32 .subscribe(res => this.activeOrgUnit = res)
36 this.editmode = false;
38 let headers = new Headers();
39 headers.append('Accept', 'application/json');
40 headers.append('Content-Type', 'application/json');
42 if (this.activeOrgUnit.id) {
43 this.http.put(dhisAPI + "/api/organisationUnits/" + this.activeOrgUnit.id, JSON.stringify(this.activeOrgUnit), {
46 .map(res => res.json())
47 .subscribe(res => console.log(res));
53 this.editmode = false;
54 if(this.activeOrgUnit.id){
55 this.update(this.activeOrgUnit.id);
57 this.activeOrgUnit = null;