Update dashboard according to the new API

This commit is contained in:
R. Richard 2019-08-07 10:28:38 +02:00
parent cc3e44ef8c
commit a254e27fbf
3 changed files with 17 additions and 22 deletions

View File

@ -5,11 +5,11 @@ import { Component, OnDestroy, OnInit, ChangeDetectorRef, ElementRef, ViewChild
import { DeploymentNotificationService } from '../services/deployment-notification.service'; import { DeploymentNotificationService } from '../services/deployment-notification.service';
import { Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
import { WebSocketService } from '../services/websocket.service'; import { WebSocketService } from '../services/websocket.service';
import { WebSocketMessage } from '../message-types/websocket-message';
import { HideMessagesCommand, LayoutCommand, TerminalMenuItemCommand } from '../message-types/dashboard-commands'; import { HideMessagesCommand, LayoutCommand, TerminalMenuItemCommand } from '../message-types/dashboard-commands';
import { config } from '../config'; import { config } from '../config';
import { ProcessLogService } from '../services/processlog.service'; import { ProcessLogService } from '../services/processlog.service';
import { LogMessage } from '../message-types/log-message'; import { LogMessage } from '../message-types/log-message';
import { CommandMessage } from '../message-types/command-message';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { delay, retryWhen, tap } from 'rxjs/operators'; import { delay, retryWhen, tap } from 'rxjs/operators';
@ -35,11 +35,11 @@ export class DashboardComponent implements OnInit, OnDestroy {
iframeReloadSubscription: Subscription; iframeReloadSubscription: Subscription;
command_handlers = { command_handlers = {
'layout': this.layoutHandler.bind(this), 'dashboard.layout': this.layoutHandler.bind(this),
'hideMessages': this.hideMessagesHandler.bind(this), 'dashboard.hideMessages': this.hideMessagesHandler.bind(this),
'terminalMenuItem': this.terminalMenuItemHandler.bind(this), 'dashboard.terminalMenuItem': this.terminalMenuItemHandler.bind(this),
'reloadFrontend': this.reloadFrontendHandlder.bind(this), 'dashboard.reloadFrontend': this.reloadFrontendHandlder.bind(this),
'reloadIframe': this.reloadIframeHandler.bind(this) 'dashboard.reloadIframe': this.reloadIframeHandler.bind(this)
}; };
constructor(private deploymentNotificationService: DeploymentNotificationService, constructor(private deploymentNotificationService: DeploymentNotificationService,
@ -57,8 +57,8 @@ export class DashboardComponent implements OnInit, OnDestroy {
} }
initCommandHandling() { initCommandHandling() {
this.webSocketService.observeKey<CommandMessage>('dashboard').subscribe((event) => { this.webSocketService.observeKey<WebSocketMessage>('dashboard').subscribe((event) => {
this.command_handlers[event.data.command](event.data); this.command_handlers[event.key](event);
this.changeDetectorRef.detectChanges(); this.changeDetectorRef.detectChanges();
}); });
} }
@ -80,11 +80,8 @@ export class DashboardComponent implements OnInit, OnDestroy {
if (config.dashboard.triggerFirstFSMStep) { if (config.dashboard.triggerFirstFSMStep) {
setTimeout(() => { setTimeout(() => {
this.webSocketService.sendJSON({ this.webSocketService.sendJSON({
'key': 'fsm', 'key': 'fsm.step',
'data': { 'trigger': config.dashboard.triggerFirstFSMStep
'command': 'trigger',
'value': config.dashboard.triggerFirstFSMStep
}
}); });
}); });
} }
@ -112,11 +109,11 @@ export class DashboardComponent implements OnInit, OnDestroy {
this.selectTerminalMenuItem(data.value); this.selectTerminalMenuItem(data.value);
} }
reloadFrontendHandlder(data: CommandMessage) { reloadFrontendHandlder(data: WebSocketMessage) {
setTimeout(() => window.location.reload(), 2000); setTimeout(() => window.location.reload(), 2000);
} }
reloadIframeHandler(data: CommandMessage) { reloadIframeHandler(data: WebSocketMessage) {
setTimeout(() => this.reloadIframeNoSubmit(), 200); setTimeout(() => this.reloadIframeNoSubmit(), 200);
} }

View File

@ -1,11 +1,11 @@
// 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 { CommandMessage } from './command-message';
import { SetValueCommand } from './set-value-command'; 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> {}

View File

@ -1,8 +1,6 @@
// 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 { CommandMessage } from './command-message'; export interface SetValueCommand<T> {
export interface SetValueCommand<T> extends CommandMessage {
value: T; value: T;
} }