Comply API changes & remove unused stuff

This commit is contained in:
Kristóf Tóth 2019-08-28 16:45:40 +02:00
parent 074fa89db7
commit 4e60bfc8df
8 changed files with 25 additions and 32 deletions

View File

@ -1,5 +1,5 @@
import { Component, OnInit, Output, EventEmitter } from '@angular/core'; import { Component, OnInit, Output, EventEmitter } from '@angular/core';
import { WebSocketService } from '../services/websocket.service'; import { WebSocketService, Intent } from '../services/websocket.service';
import { WebSocketMessage } from '../message-types/websocket-message'; import { WebSocketMessage } from '../message-types/websocket-message';
import { ConsoleReadMessage, ConsoleWriteMessage } from '../message-types/console-messages'; import { ConsoleReadMessage, ConsoleWriteMessage } from '../message-types/console-messages';
@ -28,22 +28,19 @@ export class ConsoleComponent implements OnInit {
} }
readHandler(message: ConsoleReadMessage) { readHandler(message: ConsoleReadMessage) {
this.sendContent(this.console_content); this.webSocketService.send({
'key': 'console.read',
'content': this.console_content,
'intent': Intent.EVENT
});
} }
writeHandler(message: ConsoleWriteMessage) { writeHandler(message: ConsoleWriteMessage) {
this.setContent(message.value); this.setContent(message.content);
this.contentChanged.next(message.value); this.contentChanged.next(message.content);
} }
setContent(content: string) { setContent(content: string) {
this.console_content = content; this.console_content = content;
} }
sendContent(content: string) {
this.webSocketService.send({
'key': 'console.content',
'value': content
});
}
} }

View File

@ -1,12 +1,7 @@
import { SetValueCommand } from './set-value-command';
import { WebSocketMessage } from './websocket-message'; import { WebSocketMessage } from './websocket-message';
export interface ConsoleReadMessage extends WebSocketMessage {} export interface ConsoleReadMessage extends WebSocketMessage {}
export interface ConsoleWriteMessage extends WebSocketMessage { export interface ConsoleWriteMessage extends WebSocketMessage {
value: string; content: string;
} }
export interface ConsoleLiveLogsMessage extends WebSocketMessage, SetValueCommand<boolean> {}
export interface ConsoleRewriteContentMessage extends WebSocketMessage, SetValueCommand<string> {}

View File

@ -1,8 +0,0 @@
import { SetValueCommand } from './set-value-command';
import { WebSocketMessage } from './websocket-message';
export interface LayoutMessage extends WebSocketMessage, SetValueCommand<string> {}
export interface HideMessagesMessage extends WebSocketMessage, SetValueCommand<boolean> {}
export interface TerminalMenuItemMessage extends WebSocketMessage, SetValueCommand<string> {}

View File

@ -1,3 +0,0 @@
export interface SetValueCommand<T> {
value: T;
}

View File

@ -1,3 +1,5 @@
export interface WebSocketMessage { export interface WebSocketMessage {
key: string; key: string;
scope?: string;
intent?: string;
} }

View File

@ -27,10 +27,10 @@ export abstract class ConfigServiceBase {
firstConfigs.push(config.pipe(take(requiredEmitCount))); firstConfigs.push(config.pipe(take(requiredEmitCount)));
}); });
merge(...firstConfigs).subscribe(undefined, undefined, () => { merge(...firstConfigs).subscribe({complete: () => {
this.configDone.next(); this.configDone.next();
this.configDone.complete(); this.configDone.complete();
}); }});
} }
subscribeConfigKeys() { subscribeConfigKeys() {

View File

@ -75,9 +75,9 @@ export class ConfigReadyService {
recvdConfigDone.complete(); recvdConfigDone.complete();
}); });
merge(...this.readyNotifiers).subscribe(undefined, undefined, () => { merge(...this.readyNotifiers).subscribe({complete: () => {
this.configDone.next(); this.configDone.next();
this.configDone.complete(); this.configDone.complete();
}); }});
} }
} }

View File

@ -4,6 +4,15 @@ import { webSocket, WebSocketSubject } from 'rxjs/webSocket';
import { filter, map } from 'rxjs/operators'; import { filter, map } from 'rxjs/operators';
import { WebSocketMessage } from '../message-types/websocket-message'; import { WebSocketMessage } from '../message-types/websocket-message';
export enum Scope {
ZMQ = 'zmq',
WEBSOCKET = 'websocket'
}
export enum Intent {
CONTROL = 'control',
EVENT = 'event'
}
@Injectable() @Injectable()
export class WebSocketService { export class WebSocketService {
@ -22,6 +31,7 @@ export class WebSocketService {
public observeKey<T extends WebSocketMessage>(key: string): Observable<T> { public observeKey<T extends WebSocketMessage>(key: string): Observable<T> {
return this.ws.pipe( return this.ws.pipe(
filter(message => message.key.startsWith(key)), filter(message => message.key.startsWith(key)),
filter(message => message.intent !== Intent.EVENT),
map(message => <T> message) map(message => <T> message)
); );
} }