Fixed webapp build and error message.
[src/xds/xds-agent.git] / webapp / src / app / pages / build / settings / sdk-select-dropdown.component.ts
1 import { Component, OnInit, Input } from '@angular/core';
2
3 import { ISdk, SdkService } from '../../../@core-xds/services/sdk.service';
4
5 @Component({
6     selector: 'xds-sdk-select-dropdown',
7     template: `
8       <div class="form-group">
9       <label>SDK</label>
10       <select class="form-control">
11         <option *ngFor="let sdk of sdks" (click)="select(sdk)">{{sdk.name}}</option>
12       </select>
13     </div>
14     `,
15 })
16 export class SdkSelectDropdownComponent implements OnInit {
17
18     // FIXME investigate to understand why not working with sdks as input
19     // <xds-sdk-select-dropdown [sdks]="(sdks$ | async)"></xds-sdk-select-dropdown>
20     // @Input() sdks: ISdk[];
21     sdks: ISdk[];
22
23     curSdk: ISdk;
24
25     constructor(private sdkSvr: SdkService) { }
26
27     ngOnInit() {
28         this.curSdk = this.sdkSvr.getCurrent();
29         this.sdkSvr.Sdks$.subscribe((s) => {
30             if (s) {
31                 this.sdks = s;
32                 if (this.curSdk === null || s.indexOf(this.curSdk) === -1) {
33                     this.sdkSvr.setCurrent(this.curSdk = s.length ? s[0] : null);
34                 }
35             }
36         });
37     }
38
39     select(s) {
40         this.sdkSvr.setCurrent(this.curSdk = s);
41     }
42 }
43
44