diff options
Diffstat (limited to 'webapp/src/app/devel/devel.component.ts')
-rw-r--r-- | webapp/src/app/devel/devel.component.ts | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/webapp/src/app/devel/devel.component.ts b/webapp/src/app/devel/devel.component.ts new file mode 100644 index 0000000..5c8b9f2 --- /dev/null +++ b/webapp/src/app/devel/devel.component.ts @@ -0,0 +1,35 @@ +import { Component } from '@angular/core'; + +import { Observable } from 'rxjs'; + +import { ProjectService, IProject } from "../services/project.service"; + +@Component({ + selector: 'devel', + moduleId: module.id, + templateUrl: './devel.component.html', + styleUrls: ['./devel.component.css'], +}) + +export class DevelComponent { + + curPrj: IProject; + Prjs$: Observable<IProject[]>; + + constructor(private projectSvr: ProjectService) { + } + + ngOnInit() { + this.Prjs$ = this.projectSvr.Projects$; + this.Prjs$.subscribe((prjs) => { + // Select project if no one is selected or no project exists + if (this.curPrj && "id" in this.curPrj) { + this.curPrj = prjs.find(p => p.id === this.curPrj.id) || prjs[0]; + } else if (this.curPrj == null) { + this.curPrj = prjs[0]; + } else { + this.curPrj = null; + } + }); + } +} |