Move live log checking logic to ProcessLogService

This commit is contained in:
Kristóf Tóth 2018-05-30 11:14:48 +02:00
parent fc10db6cac
commit c889de0b05
5 changed files with 17 additions and 13 deletions

View File

@ -29,7 +29,7 @@ export class ConsoleComponent implements OnInit {
this.webSocketService.observeKey<ConsoleCommand>('console').subscribe(
(event) => this.command_handlers[event.data.command](event.data)
);
this.processLogService.newLog.subscribe((data) => this.newLogHandler(data));
this.processLogService.newLogs.subscribe((data) => this.newLogsHandler(data));
}
writeHandler(data: ConsoleCommand) {
@ -40,7 +40,7 @@ export class ConsoleComponent implements OnInit {
this.sendContent(this.console_content);
}
newLogHandler(logs: any) {
newLogsHandler(logs: any) {
if (this.rewriteContentWithProcessLogs !== '') {
const log = logs[this.rewriteContentWithProcessLogs];
if (log) {

View File

@ -20,7 +20,7 @@
</div>
</div>
<div class="tfw-ide">
<app-ide (newLog)="setConsoleContent($event)"></app-ide>
<app-ide (newLogs)="setConsoleContentIfNoLiveLogs($event)"></app-ide>
</div>
<div class="tfw-terminal">
<div class="btn-group btn-group-sm flex-wrap tao-grid-center-left tfw-console-terminal-menu">

View File

@ -102,10 +102,8 @@ export class DashboardComponent implements OnInit, OnDestroy {
this.selectedTerminalMenuItem = item;
}
setConsoleContent(logs: any) {
if (!config.console.showLiveLogs) {
this.processLogService.newLog.next(logs);
}
setConsoleContentIfNoLiveLogs(logs: any) {
this.processLogService.emitNewLogsIfNoLiveLogs(logs);
if (config.ide.showConsoleOnDeploy) {
this.selectTerminalMenuItem('console');
}

View File

@ -63,7 +63,7 @@ export class IdeComponent implements OnInit {
language: string = config.ide.defaultLanguage;
theme = 'cobalt';
@Output() newLog = new EventEmitter<any>();
@Output() newLogs = new EventEmitter<any>();
options: any = {enableBasicAutocompletion: true,
enableSnippets: true,
@ -101,7 +101,7 @@ export class IdeComponent implements OnInit {
config.ide.deployProcessName,
(event) => {
this.deploymentNotificationService.deploying.next(false);
this.newLog.emit({
this.newLogs.emit({
stdout: event.data.stdout,
stderr: event.data.stderr
});

View File

@ -9,11 +9,11 @@ import { BehaviorSubject } from 'rxjs/BehaviorSubject';
@Injectable()
export class ProcessLogService {
newLog = new BehaviorSubject<any>(config.console.defaultLogs);
newLogs = new BehaviorSubject<any>(config.console.defaultLogs);
showLiveLogs = config.console.showLiveLogs;
command_handlers = {
'new_log': this.newLogHandler.bind(this)
'new_log': this.newLogsHandler.bind(this)
};
constructor(private webSocketService: WebSocketService) {
@ -23,9 +23,15 @@ export class ProcessLogService {
);
}
newLogHandler(data: ProcessLogCommand) {
emitNewLogsIfNoLiveLogs(log: any) {
if (!config.console.showLiveLogs) {
this.newLogs.next(log);
}
}
newLogsHandler(data: ProcessLogCommand) {
if (this.showLiveLogs) {
this.newLog.next({
this.newLogs.next({
stdout: data.stdout,
stderr: data.stderr
});