Fixed listed sdk in build panel (only installed sdks) v1.0.1
authorSebastien Douheret <sebastien.douheret@iot.bzh>
Tue, 9 Jan 2018 17:35:15 +0000 (18:35 +0100)
committerSebastien Douheret <sebastien.douheret@iot.bzh>
Tue, 9 Jan 2018 17:35:15 +0000 (18:35 +0100)
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
webapp/src/app/pages/build/settings/sdk-select-dropdown.component.ts

index 22ac29d..a9eafe7 100644 (file)
 
 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: `
       <div class="form-group">
       <label>SDK</label>
       <select class="form-control">
@@ -33,30 +33,31 @@ import { ISdk, SdkService } from '../../../@core-xds/services/sdk.service';
 })
 export class SdkSelectDropdownComponent implements OnInit {
 
-    // FIXME investigate to understand why not working with sdks as input
-    // <xds-sdk-select-dropdown [sdks]="(sdks$ | async)"></xds-sdk-select-dropdown>
-    // @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);
-    }
+  // FIXME investigate to understand why not working with sdks as input
+  // <xds-sdk-select-dropdown [sdks]="(sdks$ | async)"></xds-sdk-select-dropdown>
+  // @Input() sdks: ISdk[];
+  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);
+        }
+      }
+    });
+  }
+
+  select(s) {
+    this.sdkSvr.setCurrent(this.curSdk = s);
+  }
 }