Implement optional writing of the latest process log to console

This commit is contained in:
Kristóf Tóth 2018-05-27 19:02:18 +02:00
parent 2f3ea52b8e
commit 3565b890c4
6 changed files with 29 additions and 5 deletions

View File

@ -37,7 +37,8 @@ export const config = {
showNextButton: true showNextButton: true
}, },
console: { console: {
defaultContent: '' defaultContent: '',
rewriteContentWithNewLogs: true
}, },
testmessenger: { testmessenger: {
route: 'testmessenger' route: 'testmessenger'

View File

@ -29,13 +29,23 @@ export class ConsoleComponent implements OnInit {
} }
writeHandler(data: ConsoleCommand) { writeHandler(data: ConsoleCommand) {
this.console_content = data.content; this.setContent(data.content);
} }
readHandler(data: ConsoleCommand) { readHandler(data: ConsoleCommand) {
this.sendContent(this.console_content); this.sendContent(this.console_content);
} }
newLogHandler(content: string) {
if (config.console.rewriteContentWithNewLogs) {
this.setContent(content);
}
}
setContent(content: string) {
this.console_content = content;
}
sendContent(content: string) { sendContent(content: string) {
this.webSocketService.send('console', { this.webSocketService.send('console', {
'command': 'read', 'command': 'read',

View File

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

View File

@ -7,6 +7,7 @@ import { Subscription } from 'rxjs';
import { WebSocketService } from '../services/websocket.service'; 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 { ConsoleComponent } from '../console/console.component';
@Component({ @Component({
selector: 'app-dashboard', selector: 'app-dashboard',
@ -20,6 +21,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
hide_messages: boolean = config.dashboard.hide_messages; hide_messages: boolean = config.dashboard.hide_messages;
iframeUrl: string = config.dashboard.iframeUrl; iframeUrl: string = config.dashboard.iframeUrl;
@ViewChild('webiframe') webiframe: ElementRef; @ViewChild('webiframe') webiframe: ElementRef;
@ViewChild(ConsoleComponent) childConsole: ConsoleComponent;
selectedTerminalMenuItem = config.dashboard.terminalOrConsole; selectedTerminalMenuItem = config.dashboard.terminalOrConsole;
command_handlers = {'layout': this.layoutHandler.bind(this), command_handlers = {'layout': this.layoutHandler.bind(this),
@ -99,4 +101,8 @@ export class DashboardComponent implements OnInit, OnDestroy {
} }
this.selectedTerminalMenuItem = item; this.selectedTerminalMenuItem = item;
} }
setConsoleContent(content: string) {
this.childConsole.newLogHandler(content);
}
} }

View File

@ -1,7 +1,7 @@
// Copyright (C) 2018 Avatao.com Innovative Learning Kft. // Copyright (C) 2018 Avatao.com Innovative Learning Kft.
// All Rights Reserved. See LICENSE file for details. // All Rights Reserved. See LICENSE file for details.
import { ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { ChangeDetectorRef, Component, EventEmitter, OnInit, Output } from '@angular/core';
import * as brace from 'brace'; import * as brace from 'brace';
import 'brace/ext/modelist'; import 'brace/ext/modelist';
@ -62,6 +62,9 @@ export class IdeComponent implements OnInit {
language: string = config.ide.defaultLanguage; language: string = config.ide.defaultLanguage;
theme = 'cobalt'; theme = 'cobalt';
@Output() newLog = new EventEmitter<string>();
options: any = {enableBasicAutocompletion: true, options: any = {enableBasicAutocompletion: true,
enableSnippets: true, enableSnippets: true,
enableLiveAutocompletion: true}; enableLiveAutocompletion: true};
@ -96,7 +99,10 @@ export class IdeComponent implements OnInit {
this.processManagerService.init(); this.processManagerService.init();
this.processManagerService.subscribeCallback( this.processManagerService.subscribeCallback(
config.ide.deployProcessName, config.ide.deployProcessName,
(event) => this.deploymentNotificationService.deploying.next(false) (event) => {
this.deploymentNotificationService.deploying.next(false);
this.newLog.emit(event.data.log);
}
); );
this.processManagerService.subscribeSuccessCallback( this.processManagerService.subscribeSuccessCallback(

View File

@ -5,4 +5,5 @@ export class ProcessCommand {
command: string; command: string;
process_name: string; process_name: string;
error?: string; error?: string;
log: string;
} }