diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2018-01-26 17:20:51 +0100 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2018-01-26 17:20:51 +0100 |
commit | 594fbccc2f2b649fb3daf207462edf192b4fba4c (patch) | |
tree | c3ec522e20ba512128fe2196436b55ad3b130a54 | |
parent | 6865cb1795a44e56c04fab9404dc60b8db7d6103 (diff) |
Prevent browser freeze on WS data flooding.
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
-rw-r--r-- | webapp/src/app/pages/sdks/sdk-management/sdk-install.component.ts | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/webapp/src/app/pages/sdks/sdk-management/sdk-install.component.ts b/webapp/src/app/pages/sdks/sdk-management/sdk-install.component.ts index e2e334a..1957c8b 100644 --- a/webapp/src/app/pages/sdks/sdk-management/sdk-install.component.ts +++ b/webapp/src/app/pages/sdks/sdk-management/sdk-install.component.ts @@ -23,6 +23,8 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { AlertService } from '../../../@core-xds/services/alert.service'; import { SdkService, ISdk } from '../../../@core-xds/services/sdk.service'; +import 'rxjs/add/operator/bufferTime'; + @Component({ selector: 'xds-sdk-install-modal', template: ` @@ -84,32 +86,40 @@ export class SdkInstallComponent implements OnInit { ngOnInit() { this.instStatus = 'in progress...'; - this.onInstallSub = this.sdkSvr.onInstall().subscribe(ev => { - if (ev.exited) { - this.btnName = 'OK'; - this.instStatus = '<font color="green"> Done. </font>'; + this.onInstallSub = this.sdkSvr.onInstall() + .bufferTime(500) // prevent browser freeze + .subscribe(evts => { + let out = ''; + evts.forEach(ev => { + if (ev.exited) { + this.btnName = 'OK'; + this.instStatus = '<font color="green"> Done. </font>'; + + if (ev.code === 0) { + this.alert.info('SDK ' + ev.sdk.name + ' successfully installed.'); - if (ev.code === 0) { - this.alert.info('SDK ' + ev.sdk.name + ' successfully installed.'); + } else { + if (ev.sdk.lastError !== '') { + this.alert.error(ev.sdk.lastError); + } else { + this.alert.error('SDK ' + ev.sdk.name + ' installation failed. ' + ev.error); + } + } - } else { - if (ev.sdk.lastError !== '') { - this.alert.error(ev.sdk.lastError); } else { - this.alert.error('SDK ' + ev.sdk.name + ' installation failed. ' + ev.error); + if (ev.stdout !== '') { + out += ev.stdout; + } + if (ev.stderr !== '') { + out += ev.stderr; + } } + }); + if (out !== '') { + this.installOutput += out; + this._scrollToBottom(); } - - } else { - if (ev.stdout !== '') { - this.installOutput += ev.stdout; - } - if (ev.stderr !== '') { - this.installOutput += ev.stderr; - } - this._scrollToBottom(); - } - }); + }); } onBtnClick(): void { |