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=1c91367f76e6e255365a92d892f9e5d20e89a1bb;hpb=82ede02a56e12026b2dfb1baeacabfbd564006b1;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 1c91367..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,6 +1,6 @@ /** * @license -* Copyright (C) 2017 "IoT.bzh" +* Copyright (C) 2017-2018 "IoT.bzh" * Author Sebastien Douheret * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,45 +18,45 @@ 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); } + } }