mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2024-11-15 02:37:17 +00:00
Introduce separate event handler for deploying
This commit is contained in:
parent
24c994c41e
commit
aa465955ed
@ -2,7 +2,7 @@ import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
|||||||
import { WebSocketService } from '../services/websocket.service';
|
import { WebSocketService } from '../services/websocket.service';
|
||||||
import { WebSocketMessage } from '../message-types/websocket-message';
|
import { WebSocketMessage } from '../message-types/websocket-message';
|
||||||
import { IDEMessage } from '../message-types/ide-message';
|
import { IDEMessage } from '../message-types/ide-message';
|
||||||
import { ProcessManagerService } from '../services/processmanager.service';
|
import { DeployMessage } from '../message-types/deploy-message';
|
||||||
import { DeploymentNotificationService } from '../services/deployment-notification.service';
|
import { DeploymentNotificationService } from '../services/deployment-notification.service';
|
||||||
import { config } from '../config';
|
import { config } from '../config';
|
||||||
import { LanguageMap } from './language-map';
|
import { LanguageMap } from './language-map';
|
||||||
@ -54,7 +54,6 @@ export class IdeComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(private webSocketService: WebSocketService,
|
constructor(private webSocketService: WebSocketService,
|
||||||
private changeDetectorRef: ChangeDetectorRef,
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
private processManagerService: ProcessManagerService,
|
|
||||||
private deploymentNotificationService: DeploymentNotificationService) { }
|
private deploymentNotificationService: DeploymentNotificationService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -62,7 +61,6 @@ export class IdeComponent implements OnInit {
|
|||||||
this.subscribeWS();
|
this.subscribeWS();
|
||||||
this.subscribeFirstLanguageDetection();
|
this.subscribeFirstLanguageDetection();
|
||||||
this.requestCode();
|
this.requestCode();
|
||||||
this.initProcessManagerService();
|
|
||||||
this.resetAutoSaveCountdown();
|
this.resetAutoSaveCountdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,6 +69,10 @@ export class IdeComponent implements OnInit {
|
|||||||
this.command_handlers[message.key](message);
|
this.command_handlers[message.key](message);
|
||||||
this.changeDetectorRef.detectChanges();
|
this.changeDetectorRef.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.webSocketService.observeKey<DeployMessage>('deploy.finish').subscribe(
|
||||||
|
message => this.deployHandler(message)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
subscribeFirstLanguageDetection() {
|
subscribeFirstLanguageDetection() {
|
||||||
@ -79,24 +81,6 @@ export class IdeComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
initProcessManagerService() {
|
|
||||||
this.processManagerService.init();
|
|
||||||
this.processManagerService.subscribeCallback(
|
|
||||||
config.ide.deployProcessName,
|
|
||||||
() => this.deploymentNotificationService.deploying.next(false)
|
|
||||||
);
|
|
||||||
|
|
||||||
this.processManagerService.subscribeSuccessCallback(
|
|
||||||
config.ide.deployProcessName,
|
|
||||||
message => this.setDeployButtonState(DeployButtonState.DEPLOYED)
|
|
||||||
);
|
|
||||||
|
|
||||||
this.processManagerService.subscribeErrorCallback(
|
|
||||||
config.ide.deployProcessName,
|
|
||||||
() => this.setDeployButtonState(DeployButtonState.FAILED)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
reloadHandler(message: WebSocketMessage) {
|
reloadHandler(message: WebSocketMessage) {
|
||||||
this.requestCode();
|
this.requestCode();
|
||||||
}
|
}
|
||||||
@ -115,6 +99,15 @@ export class IdeComponent implements OnInit {
|
|||||||
this.setCodeState(CodeState.SAVED);
|
this.setCodeState(CodeState.SAVED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deployHandler(message: WebSocketMessage) {
|
||||||
|
if (message['status'] === 'success') {
|
||||||
|
this.setDeployButtonState(DeployButtonState.DEPLOYED);
|
||||||
|
} else if (message['status'] === 'error') {
|
||||||
|
this.setDeployButtonState(DeployButtonState.FAILED);
|
||||||
|
}
|
||||||
|
this.deploymentNotificationService.deploying.next(false);
|
||||||
|
}
|
||||||
|
|
||||||
autoDetectEditorLanguageIfEnabled(filename: string) {
|
autoDetectEditorLanguageIfEnabled(filename: string) {
|
||||||
if (!config.ide.autoDetectFileLanguage) {
|
if (!config.ide.autoDetectFileLanguage) {
|
||||||
return;
|
return;
|
||||||
@ -167,7 +160,7 @@ export class IdeComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deployCode() {
|
deployCode() {
|
||||||
this.processManagerService.restartProcess(config.ide.deployProcessName);
|
this.webSocketService.send({'key': 'deploy.start'});
|
||||||
this.setDeployButtonState(DeployButtonState.DEPLOYING);
|
this.setDeployButtonState(DeployButtonState.DEPLOYING);
|
||||||
this.deploymentNotificationService.deploying.next(true);
|
this.deploymentNotificationService.deploying.next(true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user