mirror of
				https://github.com/avatao-content/frontend-tutorial-framework
				synced 2025-11-04 13:52:55 +00:00 
			
		
		
		
	Implement optional writing of the latest process log to console
This commit is contained in:
		@@ -37,7 +37,8 @@ export const config = {
 | 
			
		||||
    showNextButton: true
 | 
			
		||||
  },
 | 
			
		||||
  console: {
 | 
			
		||||
    defaultContent: ''
 | 
			
		||||
    defaultContent: '',
 | 
			
		||||
    rewriteContentWithNewLogs: true
 | 
			
		||||
  },
 | 
			
		||||
  testmessenger: {
 | 
			
		||||
    route: 'testmessenger'
 | 
			
		||||
 
 | 
			
		||||
@@ -29,13 +29,23 @@ export class ConsoleComponent implements OnInit {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  writeHandler(data: ConsoleCommand) {
 | 
			
		||||
    this.console_content = data.content;
 | 
			
		||||
    this.setContent(data.content);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  readHandler(data: ConsoleCommand) {
 | 
			
		||||
    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) {
 | 
			
		||||
    this.webSocketService.send('console', {
 | 
			
		||||
      'command': 'read',
 | 
			
		||||
 
 | 
			
		||||
@@ -20,7 +20,7 @@
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="tfw-ide">
 | 
			
		||||
      <app-ide></app-ide>
 | 
			
		||||
      <app-ide (newLog)="setConsoleContent($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">
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,7 @@ import { Subscription } from 'rxjs';
 | 
			
		||||
import { WebSocketService } from '../services/websocket.service';
 | 
			
		||||
import { LayoutCommand } from './layout-command';
 | 
			
		||||
import { config } from '../config';
 | 
			
		||||
import { ConsoleComponent } from '../console/console.component';
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-dashboard',
 | 
			
		||||
@@ -20,6 +21,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
 | 
			
		||||
  hide_messages: boolean = config.dashboard.hide_messages;
 | 
			
		||||
  iframeUrl: string = config.dashboard.iframeUrl;
 | 
			
		||||
  @ViewChild('webiframe') webiframe: ElementRef;
 | 
			
		||||
  @ViewChild(ConsoleComponent) childConsole: ConsoleComponent;
 | 
			
		||||
  selectedTerminalMenuItem = config.dashboard.terminalOrConsole;
 | 
			
		||||
 | 
			
		||||
  command_handlers = {'layout':          this.layoutHandler.bind(this),
 | 
			
		||||
@@ -99,4 +101,8 @@ export class DashboardComponent implements OnInit, OnDestroy {
 | 
			
		||||
    }
 | 
			
		||||
    this.selectedTerminalMenuItem = item;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  setConsoleContent(content: string) {
 | 
			
		||||
    this.childConsole.newLogHandler(content);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
// Copyright (C) 2018 Avatao.com Innovative Learning Kft.
 | 
			
		||||
// 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 'brace/ext/modelist';
 | 
			
		||||
@@ -62,6 +62,9 @@ export class IdeComponent implements OnInit {
 | 
			
		||||
 | 
			
		||||
  language: string = config.ide.defaultLanguage;
 | 
			
		||||
  theme = 'cobalt';
 | 
			
		||||
 | 
			
		||||
  @Output() newLog = new EventEmitter<string>();
 | 
			
		||||
 | 
			
		||||
  options: any = {enableBasicAutocompletion: true,
 | 
			
		||||
                  enableSnippets: true,
 | 
			
		||||
                  enableLiveAutocompletion: true};
 | 
			
		||||
@@ -96,7 +99,10 @@ export class IdeComponent implements OnInit {
 | 
			
		||||
    this.processManagerService.init();
 | 
			
		||||
    this.processManagerService.subscribeCallback(
 | 
			
		||||
      config.ide.deployProcessName,
 | 
			
		||||
      (event) => this.deploymentNotificationService.deploying.next(false)
 | 
			
		||||
      (event) => {
 | 
			
		||||
        this.deploymentNotificationService.deploying.next(false);
 | 
			
		||||
        this.newLog.emit(event.data.log);
 | 
			
		||||
      }
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    this.processManagerService.subscribeSuccessCallback(
 | 
			
		||||
 
 | 
			
		||||
@@ -5,4 +5,5 @@ export class ProcessCommand {
 | 
			
		||||
  command: string;
 | 
			
		||||
  process_name: string;
 | 
			
		||||
  error?: string;
 | 
			
		||||
  log: string;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user