mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2024-12-05 02:31:33 +00:00
Remove console & live process log logic (moved to backend)
This commit is contained in:
parent
0543a36f09
commit
e6783efa49
@ -23,7 +23,6 @@ import { TestmessengerComponent } from './testmessenger/testmessenger.component'
|
||||
import { DeploymentNotificationService } from './services/deployment-notification.service';
|
||||
import { SafePipe } from './pipes/safe.pipe';
|
||||
import { ConsoleComponent } from './console/console.component';
|
||||
import { ProcessLogService } from './services/processlog.service';
|
||||
import { MonacoEditorModule } from 'ngx-monaco-editor';
|
||||
|
||||
|
||||
@ -56,7 +55,6 @@ import { MonacoEditorModule } from 'ngx-monaco-editor';
|
||||
FSMUpdateService,
|
||||
ProcessManagerService,
|
||||
DeploymentNotificationService,
|
||||
ProcessLogService
|
||||
],
|
||||
bootstrap: [
|
||||
AppComponent
|
||||
|
@ -35,7 +35,6 @@ export const config = {
|
||||
},
|
||||
showDeployButton: true,
|
||||
reloadIframeOnDeploy: false,
|
||||
showConsoleOnDeploy: true,
|
||||
autoDetectFileLanguage: true,
|
||||
showMiniMap: false
|
||||
},
|
||||
@ -50,12 +49,6 @@ export const config = {
|
||||
console: {
|
||||
route: 'console',
|
||||
defaultContent: '',
|
||||
rewriteContentWithProcessLogsOnDeploy: 'stdout',
|
||||
showLiveLogs: true,
|
||||
defaultLogs: {
|
||||
stdout: '',
|
||||
stderr: ''
|
||||
}
|
||||
},
|
||||
testmessenger: {
|
||||
route: 'testmessenger'
|
||||
|
@ -1,15 +1,8 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, Output, EventEmitter } from '@angular/core';
|
||||
import { WebSocketService } from '../services/websocket.service';
|
||||
import { WebSocketMessage } from '../message-types/websocket-message';
|
||||
import {
|
||||
ConsoleReadMessage,
|
||||
ConsoleWriteMessage,
|
||||
ConsoleLiveLogsMessage,
|
||||
ConsoleRewriteContentMessage
|
||||
} from '../message-types/console-messages';
|
||||
import { ConsoleReadMessage, ConsoleWriteMessage } from '../message-types/console-messages';
|
||||
import { config } from '../config';
|
||||
import { ProcessLogService } from '../services/processlog.service';
|
||||
import { LogMessage } from '../message-types/log-message';
|
||||
|
||||
@Component({
|
||||
selector: 'app-console',
|
||||
@ -18,24 +11,21 @@ import { LogMessage } from '../message-types/log-message';
|
||||
})
|
||||
export class ConsoleComponent implements OnInit {
|
||||
console_content: string = config.console.defaultContent;
|
||||
rewriteContentWithProcessLogsOnDeploy: string = config.console.rewriteContentWithProcessLogsOnDeploy;
|
||||
|
||||
@Output() contentChanged = new EventEmitter<string>();
|
||||
|
||||
command_handlers = {
|
||||
'console.read': this.readHandler.bind(this),
|
||||
'console.write': this.writeHandler.bind(this),
|
||||
'console.showLiveLogs': this.showLiveLogsHandler.bind(this),
|
||||
'console.rewriteContentWithProcessLogsOnDeploy': this.rewriteContentWithProcessLogsOnDeployHandler.bind(this)
|
||||
};
|
||||
|
||||
constructor(private webSocketService: WebSocketService,
|
||||
private processLogService: ProcessLogService) {}
|
||||
constructor(private webSocketService: WebSocketService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.webSocketService.connect();
|
||||
this.webSocketService.observeKey<WebSocketMessage>('console').subscribe(
|
||||
message => this.command_handlers[message.key](message)
|
||||
);
|
||||
this.processLogService.newLogs.subscribe((data) => this.newLogsHandler(data));
|
||||
}
|
||||
|
||||
readHandler(message: ConsoleReadMessage) {
|
||||
@ -44,23 +34,7 @@ export class ConsoleComponent implements OnInit {
|
||||
|
||||
writeHandler(message: ConsoleWriteMessage) {
|
||||
this.setContent(message.value);
|
||||
}
|
||||
|
||||
newLogsHandler(logs: LogMessage) {
|
||||
if (this.rewriteContentWithProcessLogsOnDeploy !== '') {
|
||||
const log = logs[this.rewriteContentWithProcessLogsOnDeploy];
|
||||
if (log) {
|
||||
this.setContent(log);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
showLiveLogsHandler(message: ConsoleLiveLogsMessage) {
|
||||
this.processLogService.showLiveLogs = message.value;
|
||||
}
|
||||
|
||||
rewriteContentWithProcessLogsOnDeployHandler(message: ConsoleRewriteContentMessage) {
|
||||
this.rewriteContentWithProcessLogsOnDeploy = message.value;
|
||||
this.contentChanged.next(message.value);
|
||||
}
|
||||
|
||||
setContent(content: string) {
|
||||
|
@ -29,7 +29,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="tfw-ide">
|
||||
<app-ide (newLogs)="setConsoleContentIfNoLiveLogs($event)"></app-ide>
|
||||
<app-ide></app-ide>
|
||||
</div>
|
||||
<div class="tfw-terminal">
|
||||
<div class="btn-group btn-group-sm flex-wrap tao-grid-center-left tfw-console-terminal-menu">
|
||||
|
@ -5,7 +5,6 @@ import { WebSocketService } from '../services/websocket.service';
|
||||
import { WebSocketMessage } from '../message-types/websocket-message';
|
||||
import { HideMessagesMessage, LayoutMessage, TerminalMenuItemMessage } from '../message-types/dashboard-messages';
|
||||
import { config } from '../config';
|
||||
import { ProcessLogService } from '../services/processlog.service';
|
||||
import { LogMessage } from '../message-types/log-message';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { delay, retryWhen, tap } from 'rxjs/operators';
|
||||
@ -42,7 +41,6 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
||||
constructor(private deploymentNotificationService: DeploymentNotificationService,
|
||||
private webSocketService: WebSocketService,
|
||||
private changeDetectorRef: ChangeDetectorRef,
|
||||
private processLogService: ProcessLogService,
|
||||
private http: HttpClient) {}
|
||||
|
||||
ngOnInit() {
|
||||
@ -141,13 +139,6 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
||||
this.selectedTerminalMenuItem = item;
|
||||
}
|
||||
|
||||
setConsoleContentIfNoLiveLogs(logs: LogMessage) {
|
||||
this.processLogService.emitNewLogsIfNoLiveLogs(logs);
|
||||
if (config.ide.showConsoleOnDeploy) {
|
||||
this.selectTerminalMenuItem('console');
|
||||
}
|
||||
}
|
||||
|
||||
scrollMessagesToBottom(): void {
|
||||
const element = this.messages.nativeElement;
|
||||
// This must be done in the Angular event loop to avoid messing up
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { ChangeDetectorRef, Component, EventEmitter, OnInit, Output } from '@angular/core';
|
||||
|
||||
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
||||
import { WebSocketService } from '../services/websocket.service';
|
||||
import { WebSocketMessage } from '../message-types/websocket-message';
|
||||
import { IDEMessage } from '../message-types/ide-message';
|
||||
@ -7,7 +6,7 @@ import { ProcessManagerService } from '../services/processmanager.service';
|
||||
import { DeploymentNotificationService } from '../services/deployment-notification.service';
|
||||
import { config } from '../config';
|
||||
import { LanguageMap } from './language-map';
|
||||
import { filter, first } from 'rxjs/operators';
|
||||
import { first } from 'rxjs/operators';
|
||||
|
||||
enum DeployButtonState {
|
||||
DEPLOYED,
|
||||
@ -47,8 +46,6 @@ export class IdeComponent implements OnInit {
|
||||
minimap: {enabled: config.ide.showMiniMap}
|
||||
};
|
||||
|
||||
@Output() newLogs = new EventEmitter<any>();
|
||||
|
||||
command_handlers = {
|
||||
'ide.reload': this.reloadHandler.bind(this),
|
||||
'ide.read': this.readHandler.bind(this),
|
||||
@ -86,13 +83,7 @@ export class IdeComponent implements OnInit {
|
||||
this.processManagerService.init();
|
||||
this.processManagerService.subscribeCallback(
|
||||
config.ide.deployProcessName,
|
||||
message => {
|
||||
this.deploymentNotificationService.deploying.next(false);
|
||||
this.newLogs.emit({
|
||||
stdout: message.stdout,
|
||||
stderr: message.stderr
|
||||
});
|
||||
}
|
||||
() => this.deploymentNotificationService.deploying.next(false)
|
||||
);
|
||||
|
||||
this.processManagerService.subscribeSuccessCallback(
|
||||
|
@ -1,4 +0,0 @@
|
||||
import { LogMessage } from './log-message';
|
||||
import { WebSocketMessage } from './websocket-message';
|
||||
|
||||
export interface ProcessLogMessage extends WebSocketMessage, LogMessage {}
|
@ -1,34 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { WebSocketService } from './websocket.service';
|
||||
import { LogMessage } from '../message-types/log-message';
|
||||
import { ProcessLogMessage } from '../message-types/process-log-message';
|
||||
import { config } from '../config';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
|
||||
@Injectable()
|
||||
export class ProcessLogService {
|
||||
newLogs = new BehaviorSubject<LogMessage>(config.console.defaultLogs);
|
||||
showLiveLogs = config.console.showLiveLogs;
|
||||
|
||||
constructor(private webSocketService: WebSocketService) {
|
||||
this.webSocketService.connect();
|
||||
this.webSocketService.observeKey<ProcessLogMessage>('process.log.new').subscribe(
|
||||
message => this.newLogsHandler(message)
|
||||
);
|
||||
}
|
||||
|
||||
emitNewLogsIfNoLiveLogs(logs: LogMessage) {
|
||||
if (!this.showLiveLogs) {
|
||||
this.newLogs.next(logs);
|
||||
}
|
||||
}
|
||||
|
||||
newLogsHandler(message: ProcessLogMessage) {
|
||||
if (this.showLiveLogs) {
|
||||
this.newLogs.next({
|
||||
stdout: message.stdout,
|
||||
stderr: message.stderr
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user