Improve handling of deployment failures

This commit is contained in:
Kristóf Tóth 2018-03-07 16:30:25 +01:00
parent f318f94f4d
commit 955ddac7c6
3 changed files with 14 additions and 6 deletions

View File

@ -1,5 +1,5 @@
export class ProcessCommand { export class ProcessCommand {
command: string; command: string;
process_name: string; process_name: string;
error: boolean error?: string;
} }

View File

@ -16,9 +16,17 @@ export class ProcessManagerService {
this.webSocketService.connect(); this.webSocketService.connect();
} }
subscribeCallback(process_name: string, error: boolean, callback: (event: any) => void) { subscribeCallback(process_name: string, callback: (event: any) => void) {
this.webSocketService.observeKey<ProcessCommand>(this.key) this.observeProcessMessage(process_name).subscribe(callback);
.pipe(filter(message => message.data.process_name === process_name && message.data.error === error)).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<ProcessCommand>(this.key)
.pipe(filter(message => message.data.process_name === process_name));
} }
sendCommand(command: string, process_name: string) { sendCommand(command: string, process_name: string) {

View File

@ -50,8 +50,8 @@ export class WebideComponent implements OnInit {
this.subscribeWS(); this.subscribeWS();
this.requestCode(); this.requestCode();
this.processManagerService.init(); this.processManagerService.init();
this.processManagerService.subscribeCallback('login', false, (event) => { this.setDeployButtonState('DEPLOYED'); }); this.processManagerService.subscribeCallback('login', (event) => { this.setDeployButtonState('DEPLOYED'); });
this.processManagerService.subscribeCallback('login', true, (event) => { this.setDeployButtonState('FAILED'); }); this.processManagerService.subscribeErrorCallback('login', (event) => { this.setDeployButtonState('FAILED'); });
this.resetAutoSaveCountdown(); this.resetAutoSaveCountdown();
} }