aboutsummaryrefslogtreecommitdiffstats
path: root/webapp/src/app/@core-xds/services/sdk.service.ts
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2018-01-05 00:17:45 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2018-01-05 00:17:45 +0100
commitbbef877fbb1c32981e86e407afd095e24d10232a (patch)
tree19e1ac24b32f4f3d080cd73c92936d4a6a2db1cb /webapp/src/app/@core-xds/services/sdk.service.ts
parentf1083a8259b3d2f560b5f3ccb8b47c94e297d7fa (diff)
Webapp: Fixed SDKs installation
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'webapp/src/app/@core-xds/services/sdk.service.ts')
-rw-r--r--webapp/src/app/@core-xds/services/sdk.service.ts30
1 files changed, 27 insertions, 3 deletions
diff --git a/webapp/src/app/@core-xds/services/sdk.service.ts b/webapp/src/app/@core-xds/services/sdk.service.ts
index 8fa6ad2..181ad6f 100644
--- a/webapp/src/app/@core-xds/services/sdk.service.ts
+++ b/webapp/src/app/@core-xds/services/sdk.service.ts
@@ -24,6 +24,24 @@ import { XDSAgentService } from '../services/xdsagent.service';
import 'rxjs/add/observable/throw';
+/* FIXME: syntax only compatible with TS>2.4.0
+export enum StatusType {
+ DISABLE = 'Disable',
+ NOT_INSTALLED = 'Not Installed',
+ INSTALLING = 'Installing',
+ UNINSTALLING = 'Un-installing',
+ INSTALLED = 'Installed'
+}
+*/
+export type StatusTypeEnum = 'Disable' | 'Not Installed' | 'Installing' | 'Un-installing' | 'Installed';
+export const StatusType = {
+ DISABLE: 'Disable',
+ NOT_INSTALLED: 'Not Installed',
+ INSTALLING: 'Installing',
+ UNINSTALLING: 'Un-installing',
+ INSTALLED: 'Installed',
+};
+
export interface ISdk {
id: string;
name: string;
@@ -97,7 +115,7 @@ export class SdkService {
this._addSdk(evMgt.sdk);
});
this.xdsSvr.onSdkRemove().subscribe(evMgt => {
- if (evMgt.sdk.status !== 'Not Installed') {
+ if (evMgt.sdk.status !== StatusType.NOT_INSTALLED) {
/* tslint:disable:no-console */
console.log('Error: received event:sdk-remove with invalid status: evMgt=', evMgt);
return;
@@ -142,8 +160,14 @@ export class SdkService {
private _addSdk(sdk: ISdk, noNext?: boolean): ISdk {
- // add new sdk
- this._sdksList.push(sdk);
+ // check if sdk already exists
+ const idx = this._sdksList.findIndex(s => s.id === sdk.id);
+ if (idx >= 0) {
+ this._sdksList[idx] = sdk;
+ } else {
+ // add new sdk
+ this._sdksList.push(sdk);
+ }
// sort sdk array
this._sdksList.sort((a, b) => {