X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=webapp%2Fsrc%2Fapp%2Fpages%2Fbuild%2Fsettings%2Fproject-select-dropdown.component.ts;h=996fa0d794a60617a5de5456ea18ed31195b6962;hb=a2cc38902ff7528870822110c4f04329a3918564;hp=da3580a42659641d755cdc79651319caa01c7999;hpb=38c0c21a969e621c725245ce91c78e77076c5ce7;p=src%2Fxds%2Fxds-agent.git diff --git a/webapp/src/app/pages/build/settings/project-select-dropdown.component.ts b/webapp/src/app/pages/build/settings/project-select-dropdown.component.ts index da3580a..996fa0d 100644 --- a/webapp/src/app/pages/build/settings/project-select-dropdown.component.ts +++ b/webapp/src/app/pages/build/settings/project-select-dropdown.component.ts @@ -1,4 +1,23 @@ +/** +* @license +* Copyright (C) 2017-2018 "IoT.bzh" +* Author Sebastien Douheret +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + import { Component, OnInit, Input } from '@angular/core'; +import { Observable } from 'rxjs/Observable'; import { IProject, ProjectService } from '../../../@core-xds/services/project.service'; @@ -7,33 +26,29 @@ import { IProject, ProjectService } from '../../../@core-xds/services/project.se template: `
- +
`, }) export class ProjectSelectDropdownComponent implements OnInit { - projects: IProject[]; + projects$: Observable; curPrj: IProject; - constructor(private prjSvr: ProjectService) { } + constructor(private projectSvr: ProjectService) { } ngOnInit() { - this.curPrj = this.prjSvr.getCurrent(); - this.prjSvr.Projects$.subscribe((s) => { - if (s) { - this.projects = s; - if (this.curPrj === null || s.indexOf(this.curPrj) === -1) { - this.prjSvr.setCurrent(this.curPrj = s.length ? s[0] : null); - } - } - }); + this.curPrj = this.projectSvr.getCurrent(); + this.projects$ = this.projectSvr.projects$; + this.projectSvr.curProject$.subscribe(p => this.curPrj = p); } - select(s) { - this.prjSvr.setCurrent(this.curPrj = s); + select() { + if (this.curPrj) { + this.projectSvr.setCurrentById(this.curPrj.id); + } } }