mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2024-12-05 02:21:31 +00:00
Comply API changes & remove unused stuff
This commit is contained in:
parent
074fa89db7
commit
4e60bfc8df
@ -1,5 +1,5 @@
|
||||
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 { ConsoleReadMessage, ConsoleWriteMessage } from '../message-types/console-messages';
|
||||
|
||||
@ -28,22 +28,19 @@ export class ConsoleComponent implements OnInit {
|
||||
}
|
||||
|
||||
readHandler(message: ConsoleReadMessage) {
|
||||
this.sendContent(this.console_content);
|
||||
this.webSocketService.send({
|
||||
'key': 'console.read',
|
||||
'content': this.console_content,
|
||||
'intent': Intent.EVENT
|
||||
});
|
||||
}
|
||||
|
||||
writeHandler(message: ConsoleWriteMessage) {
|
||||
this.setContent(message.value);
|
||||
this.contentChanged.next(message.value);
|
||||
this.setContent(message.content);
|
||||
this.contentChanged.next(message.content);
|
||||
}
|
||||
|
||||
setContent(content: string) {
|
||||
this.console_content = content;
|
||||
}
|
||||
|
||||
sendContent(content: string) {
|
||||
this.webSocketService.send({
|
||||
'key': 'console.content',
|
||||
'value': content
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,7 @@
|
||||
import { SetValueCommand } from './set-value-command';
|
||||
import { WebSocketMessage } from './websocket-message';
|
||||
|
||||
export interface ConsoleReadMessage 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> {}
|
||||
|
@ -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> {}
|
@ -1,3 +0,0 @@
|
||||
export interface SetValueCommand<T> {
|
||||
value: T;
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
export interface WebSocketMessage {
|
||||
key: string;
|
||||
scope?: string;
|
||||
intent?: string;
|
||||
}
|
||||
|
@ -27,10 +27,10 @@ export abstract class ConfigServiceBase {
|
||||
firstConfigs.push(config.pipe(take(requiredEmitCount)));
|
||||
});
|
||||
|
||||
merge(...firstConfigs).subscribe(undefined, undefined, () => {
|
||||
merge(...firstConfigs).subscribe({complete: () => {
|
||||
this.configDone.next();
|
||||
this.configDone.complete();
|
||||
});
|
||||
}});
|
||||
}
|
||||
|
||||
subscribeConfigKeys() {
|
||||
|
@ -75,9 +75,9 @@ export class ConfigReadyService {
|
||||
recvdConfigDone.complete();
|
||||
});
|
||||
|
||||
merge(...this.readyNotifiers).subscribe(undefined, undefined, () => {
|
||||
merge(...this.readyNotifiers).subscribe({complete: () => {
|
||||
this.configDone.next();
|
||||
this.configDone.complete();
|
||||
});
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,15 @@ import { webSocket, WebSocketSubject } from 'rxjs/webSocket';
|
||||
import { filter, map } from 'rxjs/operators';
|
||||
import { WebSocketMessage } from '../message-types/websocket-message';
|
||||
|
||||
export enum Scope {
|
||||
ZMQ = 'zmq',
|
||||
WEBSOCKET = 'websocket'
|
||||
}
|
||||
|
||||
export enum Intent {
|
||||
CONTROL = 'control',
|
||||
EVENT = 'event'
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class WebSocketService {
|
||||
@ -22,6 +31,7 @@ export class WebSocketService {
|
||||
public observeKey<T extends WebSocketMessage>(key: string): Observable<T> {
|
||||
return this.ws.pipe(
|
||||
filter(message => message.key.startsWith(key)),
|
||||
filter(message => message.intent !== Intent.EVENT),
|
||||
map(message => <T> message)
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user