Make log messages typed

This commit is contained in:
Kristóf Tóth 2018-05-30 14:19:19 +02:00
parent b635993656
commit 4b92f5552b
4 changed files with 15 additions and 5 deletions

View File

@ -6,6 +6,7 @@ import { WebSocketService } from '../services/websocket.service';
import { ConsoleCommand } from './console-command'; import { ConsoleCommand } from './console-command';
import { config } from '../config'; import { config } from '../config';
import { ProcessLogService } from '../services/processlog.service'; import { ProcessLogService } from '../services/processlog.service';
import { LogMessage } from '../services/log.message';
@Component({ @Component({
selector: 'app-console', selector: 'app-console',
@ -42,7 +43,7 @@ export class ConsoleComponent implements OnInit {
this.sendContent(this.console_content); this.sendContent(this.console_content);
} }
newLogsHandler(logs: any) { newLogsHandler(logs: LogMessage) {
if (this.rewriteContentWithProcessLogsOnDeploy !== '') { if (this.rewriteContentWithProcessLogsOnDeploy !== '') {
const log = logs[this.rewriteContentWithProcessLogsOnDeploy]; const log = logs[this.rewriteContentWithProcessLogsOnDeploy];
if (log) { if (log) {

View File

@ -8,6 +8,7 @@ import { WebSocketService } from '../services/websocket.service';
import { LayoutCommand } from './layout-command'; import { LayoutCommand } from './layout-command';
import { config } from '../config'; import { config } from '../config';
import { ProcessLogService } from '../services/processlog.service'; import { ProcessLogService } from '../services/processlog.service';
import { LogMessage } from '../services/log.message';
@Component({ @Component({
selector: 'app-dashboard', selector: 'app-dashboard',
@ -102,7 +103,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
this.selectedTerminalMenuItem = item; this.selectedTerminalMenuItem = item;
} }
setConsoleContentIfNoLiveLogs(logs: any) { setConsoleContentIfNoLiveLogs(logs: LogMessage) {
this.processLogService.emitNewLogsIfNoLiveLogs(logs); this.processLogService.emitNewLogsIfNoLiveLogs(logs);
if (config.ide.showConsoleOnDeploy) { if (config.ide.showConsoleOnDeploy) {
this.selectTerminalMenuItem('console'); this.selectTerminalMenuItem('console');

View File

@ -0,0 +1,7 @@
// Copyright (C) 2018 Avatao.com Innovative Learning Kft.
// All Rights Reserved. See LICENSE file for details.
export interface LogMessage {
stdout: string;
stderr: string;
}

View File

@ -6,10 +6,11 @@ import { WebSocketService } from './websocket.service';
import { ProcessLogCommand } from './processlog-command'; import { ProcessLogCommand } from './processlog-command';
import { config } from '../config'; import { config } from '../config';
import { BehaviorSubject } from 'rxjs/BehaviorSubject'; import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { LogMessage } from './log.message';
@Injectable() @Injectable()
export class ProcessLogService { export class ProcessLogService {
newLogs = new BehaviorSubject<any>(config.console.defaultLogs); newLogs = new BehaviorSubject<LogMessage>(config.console.defaultLogs);
showLiveLogs = config.console.showLiveLogs; showLiveLogs = config.console.showLiveLogs;
command_handlers = { command_handlers = {
@ -23,9 +24,9 @@ export class ProcessLogService {
); );
} }
emitNewLogsIfNoLiveLogs(log: any) { emitNewLogsIfNoLiveLogs(logs: LogMessage) {
if (!config.console.showLiveLogs) { if (!config.console.showLiveLogs) {
this.newLogs.next(log); this.newLogs.next(logs);
} }
} }