mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2025-04-19 16:58:36 +00:00
Implement optional writing of the latest process log to console
This commit is contained in:
parent
2f3ea52b8e
commit
3565b890c4
@ -37,7 +37,8 @@ export const config = {
|
|||||||
showNextButton: true
|
showNextButton: true
|
||||||
},
|
},
|
||||||
console: {
|
console: {
|
||||||
defaultContent: ''
|
defaultContent: '',
|
||||||
|
rewriteContentWithNewLogs: true
|
||||||
},
|
},
|
||||||
testmessenger: {
|
testmessenger: {
|
||||||
route: 'testmessenger'
|
route: 'testmessenger'
|
||||||
|
@ -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',
|
||||||
|
@ -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">
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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(
|
||||||
|
@ -5,4 +5,5 @@ export class ProcessCommand {
|
|||||||
command: string;
|
command: string;
|
||||||
process_name: string;
|
process_name: string;
|
||||||
error?: string;
|
error?: string;
|
||||||
|
log: string;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user