mirror of
				https://github.com/avatao-content/frontend-tutorial-framework
				synced 2025-11-04 12:42:55 +00:00 
			
		
		
		
	Improve handling of deployment failures
This commit is contained in:
		@@ -1,5 +1,5 @@
 | 
			
		||||
export class ProcessCommand {
 | 
			
		||||
  command: string;
 | 
			
		||||
  process_name: string;
 | 
			
		||||
  error: boolean
 | 
			
		||||
  error?: string;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -16,9 +16,17 @@ export class ProcessManagerService {
 | 
			
		||||
    this.webSocketService.connect();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  subscribeCallback(process_name: string, error: boolean, callback: (event: any) => void) {
 | 
			
		||||
    this.webSocketService.observeKey<ProcessCommand>(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<ProcessCommand>(this.key)
 | 
			
		||||
      .pipe(filter(message => message.data.process_name === process_name));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  sendCommand(command: string, process_name: string) {
 | 
			
		||||
 
 | 
			
		||||
@@ -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();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user