diff --git a/src/app/services/processcommand.ts b/src/app/services/processcommand.ts index d10a17e..6a8d725 100644 --- a/src/app/services/processcommand.ts +++ b/src/app/services/processcommand.ts @@ -1,5 +1,5 @@ export class ProcessCommand { command: string; process_name: string; - error: boolean + error?: string; } diff --git a/src/app/services/processmanager.service.ts b/src/app/services/processmanager.service.ts index f757b8a..80b8544 100644 --- a/src/app/services/processmanager.service.ts +++ b/src/app/services/processmanager.service.ts @@ -16,9 +16,17 @@ export class ProcessManagerService { this.webSocketService.connect(); } - subscribeCallback(process_name: string, error: boolean, callback: (event: any) => void) { - this.webSocketService.observeKey(this.key) - .pipe(filter(message => message.data.process_name === process_name && message.data.error === error)).subscribe(callback); + subscribeCallback(process_name: string, callback: (event: any) => void) { + this.observeProcessMessage(process_name).subscribe(callback); + } + + subscribeErrorCallback(process_name: string, callback: (event: any) => void) { + this.observeProcessMessage(process_name).pipe(filter(message => 'error' in message.data)).subscribe(callback); + } + + observeProcessMessage(process_name: string) { + return this.webSocketService.observeKey(this.key) + .pipe(filter(message => message.data.process_name === process_name)); } sendCommand(command: string, process_name: string) { diff --git a/src/app/webide/webide.component.ts b/src/app/webide/webide.component.ts index 5def77f..0c41590 100644 --- a/src/app/webide/webide.component.ts +++ b/src/app/webide/webide.component.ts @@ -50,8 +50,8 @@ export class WebideComponent implements OnInit { this.subscribeWS(); this.requestCode(); this.processManagerService.init(); - this.processManagerService.subscribeCallback('login', false, (event) => { this.setDeployButtonState('DEPLOYED'); }); - this.processManagerService.subscribeCallback('login', true, (event) => { this.setDeployButtonState('FAILED'); }); + this.processManagerService.subscribeCallback('login', (event) => { this.setDeployButtonState('DEPLOYED'); }); + this.processManagerService.subscribeErrorCallback('login', (event) => { this.setDeployButtonState('FAILED'); }); this.resetAutoSaveCountdown(); }