mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2025-04-03 11:52:40 +00:00
Remove unnecessary parentheses and refactor bot messages
This commit is contained in:
parent
6e22e7efe9
commit
0b65b9f5f3
@ -57,7 +57,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initCommandHandling() {
|
initCommandHandling() {
|
||||||
this.webSocketService.observeKey<WebSocketMessage>('dashboard').subscribe((message) => {
|
this.webSocketService.observeKey<WebSocketMessage>('dashboard').subscribe(message => {
|
||||||
this.command_handlers[message.key](message);
|
this.command_handlers[message.key](message);
|
||||||
this.changeDetectorRef.detectChanges();
|
this.changeDetectorRef.detectChanges();
|
||||||
});
|
});
|
||||||
|
@ -73,7 +73,7 @@ export class IdeComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
subscribeWS() {
|
subscribeWS() {
|
||||||
this.webSocketService.observeKey<WebSocketMessage>('ide').subscribe((message) => {
|
this.webSocketService.observeKey<WebSocketMessage>('ide').subscribe(message => {
|
||||||
this.command_handlers[message.key](message);
|
this.command_handlers[message.key](message);
|
||||||
this.changeDetectorRef.detectChanges();
|
this.changeDetectorRef.detectChanges();
|
||||||
});
|
});
|
||||||
@ -89,7 +89,7 @@ export class IdeComponent implements OnInit {
|
|||||||
this.processManagerService.init();
|
this.processManagerService.init();
|
||||||
this.processManagerService.subscribeCallback(
|
this.processManagerService.subscribeCallback(
|
||||||
config.ide.deployProcessName,
|
config.ide.deployProcessName,
|
||||||
(message) => {
|
message => {
|
||||||
this.deploymentNotificationService.deploying.next(false);
|
this.deploymentNotificationService.deploying.next(false);
|
||||||
this.newLogs.emit({
|
this.newLogs.emit({
|
||||||
stdout: message.stdout,
|
stdout: message.stdout,
|
||||||
@ -100,7 +100,7 @@ export class IdeComponent implements OnInit {
|
|||||||
|
|
||||||
this.processManagerService.subscribeSuccessCallback(
|
this.processManagerService.subscribeSuccessCallback(
|
||||||
config.ide.deployProcessName,
|
config.ide.deployProcessName,
|
||||||
(message) => this.setDeployButtonState(DeployButtonState.DEPLOYED)
|
message => this.setDeployButtonState(DeployButtonState.DEPLOYED)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.processManagerService.subscribeErrorCallback(
|
this.processManagerService.subscribeErrorCallback(
|
||||||
|
@ -23,6 +23,12 @@ export class MessagesComponent implements OnInit {
|
|||||||
messages: MessageData[] = [];
|
messages: MessageData[] = [];
|
||||||
messageQueueAttender: MessageQueueAttender;
|
messageQueueAttender: MessageQueueAttender;
|
||||||
|
|
||||||
|
command_handlers = {
|
||||||
|
'message.queue': this.handleQueueMessage.bind(this),
|
||||||
|
'message.config': this.configureMessages.bind(this),
|
||||||
|
'message.send': () => {}
|
||||||
|
};
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private markdownService: MarkdownService,
|
private markdownService: MarkdownService,
|
||||||
private websocketService: WebSocketService,
|
private websocketService: WebSocketService,
|
||||||
@ -33,7 +39,7 @@ export class MessagesComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.newMessage.subscribe(
|
this.newMessage.subscribe(
|
||||||
(message) => {
|
message => {
|
||||||
this.writeMessage(message);
|
this.writeMessage(message);
|
||||||
this.newMessageEvent.emit();
|
this.newMessageEvent.emit();
|
||||||
});
|
});
|
||||||
@ -43,13 +49,10 @@ export class MessagesComponent implements OnInit {
|
|||||||
|
|
||||||
this.websocketService.connect();
|
this.websocketService.connect();
|
||||||
this.websocketService.observeKey<Message>('message.send').subscribe(
|
this.websocketService.observeKey<Message>('message.send').subscribe(
|
||||||
(message) => this.newMessage.next(message)
|
message => this.newMessage.next(message)
|
||||||
);
|
);
|
||||||
this.websocketService.observeKey<MessageQueue>('message.queue').subscribe(
|
this.websocketService.observeKey<MessageQueue>('message').subscribe(
|
||||||
(message) => this.handleQueueMessage(message)
|
message => this.command_handlers[message.key](message)
|
||||||
);
|
|
||||||
this.websocketService.observeKey<MessageConfig>('message.config').subscribe(
|
|
||||||
(message) => this.configureMessages(message)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ export class FSMUpdateService {
|
|||||||
constructor(private websocketService: WebSocketService) {}
|
constructor(private websocketService: WebSocketService) {}
|
||||||
|
|
||||||
public init(): void {
|
public init(): void {
|
||||||
this.websocketService.observeKey<FSMUpdateMessage>('fsm.update').subscribe((message) => {
|
this.websocketService.observeKey<FSMUpdateMessage>('fsm.update').subscribe(message => {
|
||||||
this.current_state = message.current_state;
|
this.current_state = message.current_state;
|
||||||
this.valid_transitions = message.valid_transitions;
|
this.valid_transitions = message.valid_transitions;
|
||||||
});
|
});
|
||||||
|
@ -16,7 +16,7 @@ export class ProcessLogService {
|
|||||||
constructor(private webSocketService: WebSocketService) {
|
constructor(private webSocketService: WebSocketService) {
|
||||||
this.webSocketService.connect();
|
this.webSocketService.connect();
|
||||||
this.webSocketService.observeKey<ProcessLogMessage>('process.log.new').subscribe(
|
this.webSocketService.observeKey<ProcessLogMessage>('process.log.new').subscribe(
|
||||||
(message) => this.newLogsHandler(message)
|
message => this.newLogsHandler(message)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user