3 * Copyright (C) 2017-2018 "IoT.bzh"
4 * Author Sebastien Douheret <sebastien@iot.bzh>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import { Component, OnInit, Input } from '@angular/core';
21 import { ISdk, SdkService, StatusType } from '../../../@core-xds/services/sdk.service';
24 selector: 'xds-sdk-select-dropdown',
26 <div class="form-group">
28 <select class="form-control" [(ngModel)]="curSdk" (click)="select()">
29 <option *ngFor="let sdk of sdks" [ngValue]="sdk">{{sdk.name}}</option>
34 export class SdkSelectDropdownComponent implements OnInit {
39 constructor(private sdkSvr: SdkService) { }
42 this.curSdk = this.sdkSvr.getCurrent();
43 this.sdkSvr.Sdks$.subscribe((s) => {
45 // Only list installed SDKs
46 this.sdks = s.filter(ss => ss.status === StatusType.INSTALLED);
47 if (this.curSdk === null || s.indexOf(this.curSdk) === -1) {
48 this.sdkSvr.setCurrent(this.curSdk = this.sdks.length ? this.sdks[0] : null);
49 this.curSdk = this.sdkSvr.getCurrent();
57 this.sdkSvr.setCurrent(this.curSdk);