X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=webapp%2Fsrc%2Fapp%2Fpages%2Fbuild%2Fsettings%2Fsdk-select-dropdown.component.ts;h=64de039b1842fa9f5ce5556f3000aa80fe67fcc5;hb=319bdec474f655f415609c76a8e3b50b1d0b9aa4;hp=562386d1840dd4d2e74ba6996a630407bdfa4e78;hpb=38c0c21a969e621c725245ce91c78e77076c5ce7;p=src%2Fxds%2Fxds-agent.git diff --git a/webapp/src/app/pages/build/settings/sdk-select-dropdown.component.ts b/webapp/src/app/pages/build/settings/sdk-select-dropdown.component.ts index 562386d..64de039 100644 --- a/webapp/src/app/pages/build/settings/sdk-select-dropdown.component.ts +++ b/webapp/src/app/pages/build/settings/sdk-select-dropdown.component.ts @@ -1,44 +1,62 @@ +/** +* @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 { ISdk, SdkService } from '../../../@core-xds/services/sdk.service'; +import { ISdk, SdkService, StatusType } from '../../../@core-xds/services/sdk.service'; @Component({ - selector: 'xds-sdk-select-dropdown', - template: ` + selector: 'xds-sdk-select-dropdown', + template: `
- +
`, }) export class SdkSelectDropdownComponent implements OnInit { - // FIXME investigate to understand why not working with sdks as input - // - // @Input() sdks: ISdk[]; - sdks: ISdk[]; - - curSdk: ISdk; - - constructor(private sdkSvr: SdkService) { } - - ngOnInit() { - this.curSdk = this.sdkSvr.getCurrent(); - this.sdkSvr.Sdks$.subscribe((s) => { - if (s) { - this.sdks = s; - if (this.curSdk === null || s.indexOf(this.curSdk) === -1) { - this.sdkSvr.setCurrent(this.curSdk = s.length ? s[0] : null); - } - } - }); - } - - select(s) { - this.sdkSvr.setCurrent(this.curSdk = s); + sdks: ISdk[]; + curSdk: ISdk; + + constructor(private sdkSvr: SdkService) { } + + ngOnInit() { + this.curSdk = this.sdkSvr.getCurrent(); + this.sdkSvr.Sdks$.subscribe((s) => { + if (s) { + // Only list installed SDKs + this.sdks = s.filter(ss => ss.status === StatusType.INSTALLED); + if (this.curSdk === null || s.indexOf(this.curSdk) === -1) { + this.sdkSvr.setCurrent(this.curSdk = this.sdks.length ? this.sdks[0] : null); + this.curSdk = this.sdkSvr.getCurrent(); + } + } + }); + } + + select(s) { + if (this.curSdk) { + this.sdkSvr.setCurrent(this.curSdk); } + } }