diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-05-18 15:36:21 +0200 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-05-18 15:36:21 +0200 |
commit | db2c02a9bfd709c662872fccc86d011136e9d8d1 (patch) | |
tree | 5f8e6481e8555372b56b155f2038fdbf726e550c | |
parent | 2ad72d9ee3aafb2426b28a86b505da9d24f3e768 (diff) |
Fix SDKs init when no sdk found in Webapp.
-rw-r--r-- | webapp/src/app/common/sdk.service.ts | 4 | ||||
-rw-r--r-- | webapp/src/app/sdks/sdkSelectDropdown.component.ts | 12 |
2 files changed, 12 insertions, 4 deletions
diff --git a/webapp/src/app/common/sdk.service.ts b/webapp/src/app/common/sdk.service.ts index 3f2f32a..19c49d9 100644 --- a/webapp/src/app/common/sdk.service.ts +++ b/webapp/src/app/common/sdk.service.ts @@ -34,6 +34,10 @@ export class SdkService { this.current = s; } + public getCurrent(): ISdk { + return this.current; + } + public getCurrentId(): string { if (this.current && this.current.id) { return this.current.id; diff --git a/webapp/src/app/sdks/sdkSelectDropdown.component.ts b/webapp/src/app/sdks/sdkSelectDropdown.component.ts index 5122cd2..f213db0 100644 --- a/webapp/src/app/sdks/sdkSelectDropdown.component.ts +++ b/webapp/src/app/sdks/sdkSelectDropdown.component.ts @@ -29,15 +29,19 @@ export class SdkSelectDropdownComponent { constructor(private sdkSvr: SdkService) { } ngOnInit() { + this.curSdk = this.sdkSvr.getCurrent(); this.sdkSvr.Sdks$.subscribe((s) => { - this.sdks = s; - this.curSdk = this.sdks.length ? this.sdks[0] : null; - this.sdkSvr.setCurrent(this.curSdk); + 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); + this.sdkSvr.setCurrent(this.curSdk = s); } } |