Refactor console message types and API

This commit is contained in:
Kristóf Tóth 2018-05-31 12:11:35 +02:00
parent 887a81ab8e
commit 279a121538
3 changed files with 22 additions and 11 deletions

View File

@ -3,7 +3,7 @@
import { Component, OnInit } from '@angular/core';
import { WebSocketService } from '../services/websocket.service';
import { ConsoleCommand } from '../message.types/console.command';
import { ConsoleContentCommand, RewriteContentCommand, ShowLiveLogsCommand } from '../message.types/console.commands';
import { config } from '../config';
import { ProcessLogService } from '../services/processlog.service';
import { LogMessage } from '../message.types/log.message';
@ -36,11 +36,11 @@ export class ConsoleComponent implements OnInit {
this.processLogService.newLogs.subscribe((data) => this.newLogsHandler(data));
}
writeHandler(data: ConsoleCommand) {
writeHandler(data: ConsoleContentCommand) {
this.setContent(data.content);
}
readHandler(data: CommandMessage) {
readHandler(data: ConsoleContentCommand) {
this.sendContent(this.console_content);
}
@ -53,12 +53,12 @@ export class ConsoleComponent implements OnInit {
}
}
showLiveLogsHandler(data: ConsoleCommand) {
this.processLogService.showLiveLogs = data.showLiveLogs;
showLiveLogsHandler(data: ShowLiveLogsCommand) {
this.processLogService.showLiveLogs = data.value;
}
rewriteContentWithProcessLogsOnDeployHandler(data: ConsoleCommand) {
this.rewriteContentWithProcessLogsOnDeploy = data.rewriteContentWithProcessLogsOnDeploy;
rewriteContentWithProcessLogsOnDeployHandler(data: RewriteContentCommand) {
this.rewriteContentWithProcessLogsOnDeploy = data.value;
}
setContent(content: string) {

View File

@ -0,0 +1,13 @@
// 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';
export interface ConsoleContentCommand extends CommandMessage {
content?: string;
}
export interface ShowLiveLogsCommand extends CommandMessage, SetValueCommand<boolean> {}
export interface RewriteContentCommand extends CommandMessage, SetValueCommand<string> {}

View File

@ -3,8 +3,6 @@
import { CommandMessage } from './command.message';
export interface ConsoleCommand extends CommandMessage {
content?: string;
showLiveLogs?: boolean;
rewriteContentWithProcessLogsOnDeploy?: string;
export interface SetValueCommand<T> extends CommandMessage {
value: T;
}