mirror of
				https://github.com/avatao-content/frontend-tutorial-framework
				synced 2025-11-04 12:12:55 +00:00 
			
		
		
		
	Update dashboard according to the new API
This commit is contained in:
		@@ -5,11 +5,11 @@ import { Component, OnDestroy, OnInit, ChangeDetectorRef, ElementRef, ViewChild
 | 
			
		||||
import { DeploymentNotificationService } from '../services/deployment-notification.service';
 | 
			
		||||
import { Subscription } from 'rxjs';
 | 
			
		||||
import { WebSocketService } from '../services/websocket.service';
 | 
			
		||||
import { WebSocketMessage } from '../message-types/websocket-message';
 | 
			
		||||
import { HideMessagesCommand, LayoutCommand, TerminalMenuItemCommand } from '../message-types/dashboard-commands';
 | 
			
		||||
import { config } from '../config';
 | 
			
		||||
import { ProcessLogService } from '../services/processlog.service';
 | 
			
		||||
import { LogMessage } from '../message-types/log-message';
 | 
			
		||||
import { CommandMessage } from '../message-types/command-message';
 | 
			
		||||
import { HttpClient } from '@angular/common/http';
 | 
			
		||||
import { delay, retryWhen, tap } from 'rxjs/operators';
 | 
			
		||||
 | 
			
		||||
@@ -35,11 +35,11 @@ export class DashboardComponent implements OnInit, OnDestroy {
 | 
			
		||||
  iframeReloadSubscription: Subscription;
 | 
			
		||||
 | 
			
		||||
  command_handlers = {
 | 
			
		||||
    'layout':           this.layoutHandler.bind(this),
 | 
			
		||||
    'hideMessages':     this.hideMessagesHandler.bind(this),
 | 
			
		||||
    'terminalMenuItem': this.terminalMenuItemHandler.bind(this),
 | 
			
		||||
    'reloadFrontend':   this.reloadFrontendHandlder.bind(this),
 | 
			
		||||
    'reloadIframe':     this.reloadIframeHandler.bind(this)
 | 
			
		||||
    'dashboard.layout':           this.layoutHandler.bind(this),
 | 
			
		||||
    'dashboard.hideMessages':     this.hideMessagesHandler.bind(this),
 | 
			
		||||
    'dashboard.terminalMenuItem': this.terminalMenuItemHandler.bind(this),
 | 
			
		||||
    'dashboard.reloadFrontend':   this.reloadFrontendHandlder.bind(this),
 | 
			
		||||
    'dashboard.reloadIframe':     this.reloadIframeHandler.bind(this)
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  constructor(private deploymentNotificationService: DeploymentNotificationService,
 | 
			
		||||
@@ -57,8 +57,8 @@ export class DashboardComponent implements OnInit, OnDestroy {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  initCommandHandling() {
 | 
			
		||||
    this.webSocketService.observeKey<CommandMessage>('dashboard').subscribe((event) => {
 | 
			
		||||
      this.command_handlers[event.data.command](event.data);
 | 
			
		||||
    this.webSocketService.observeKey<WebSocketMessage>('dashboard').subscribe((event) => {
 | 
			
		||||
      this.command_handlers[event.key](event);
 | 
			
		||||
      this.changeDetectorRef.detectChanges();
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
@@ -80,11 +80,8 @@ export class DashboardComponent implements OnInit, OnDestroy {
 | 
			
		||||
    if (config.dashboard.triggerFirstFSMStep) {
 | 
			
		||||
      setTimeout(() => {
 | 
			
		||||
        this.webSocketService.sendJSON({
 | 
			
		||||
          'key': 'fsm',
 | 
			
		||||
          'data': {
 | 
			
		||||
            'command': 'trigger',
 | 
			
		||||
            'value': config.dashboard.triggerFirstFSMStep
 | 
			
		||||
          }
 | 
			
		||||
          'key': 'fsm.step',
 | 
			
		||||
          'trigger': config.dashboard.triggerFirstFSMStep
 | 
			
		||||
        });
 | 
			
		||||
      });
 | 
			
		||||
    }
 | 
			
		||||
@@ -112,11 +109,11 @@ export class DashboardComponent implements OnInit, OnDestroy {
 | 
			
		||||
    this.selectTerminalMenuItem(data.value);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  reloadFrontendHandlder(data: CommandMessage) {
 | 
			
		||||
  reloadFrontendHandlder(data: WebSocketMessage) {
 | 
			
		||||
    setTimeout(() => window.location.reload(), 2000);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  reloadIframeHandler(data: CommandMessage) {
 | 
			
		||||
  reloadIframeHandler(data: WebSocketMessage) {
 | 
			
		||||
    setTimeout(() => this.reloadIframeNoSubmit(), 200);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,11 @@
 | 
			
		||||
// Copyright (C) 2018 Avatao.com Innovative Learning Kft.
 | 
			
		||||
// All Rights Reserved. See LICENSE file for details.
 | 
			
		||||
 | 
			
		||||
import { CommandMessage } from './command-message';
 | 
			
		||||
import { SetValueCommand } from './set-value-command';
 | 
			
		||||
import { WebSocketMessage } from './websocket-message';
 | 
			
		||||
 | 
			
		||||
export interface LayoutCommand extends CommandMessage, SetValueCommand<string> {}
 | 
			
		||||
export interface LayoutCommand extends WebSocketMessage, SetValueCommand<string> {}
 | 
			
		||||
 | 
			
		||||
export interface HideMessagesCommand extends CommandMessage, SetValueCommand<boolean> {}
 | 
			
		||||
export interface HideMessagesCommand extends WebSocketMessage, SetValueCommand<boolean> {}
 | 
			
		||||
 | 
			
		||||
export interface TerminalMenuItemCommand extends CommandMessage, SetValueCommand<string> {}
 | 
			
		||||
export interface TerminalMenuItemCommand extends WebSocketMessage, SetValueCommand<string> {}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,6 @@
 | 
			
		||||
// Copyright (C) 2018 Avatao.com Innovative Learning Kft.
 | 
			
		||||
// All Rights Reserved. See LICENSE file for details.
 | 
			
		||||
 | 
			
		||||
import { CommandMessage } from './command-message';
 | 
			
		||||
 | 
			
		||||
export interface SetValueCommand<T> extends CommandMessage {
 | 
			
		||||
export interface SetValueCommand<T> {
 | 
			
		||||
  value: T;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user