Move live log checking logic to ProcessLogService

This commit is contained in:
Kristóf Tóth
2018-05-30 11:14:48 +02:00
parent fc10db6cac
commit c889de0b05
5 changed files with 17 additions and 13 deletions

View File

@ -9,11 +9,11 @@ import { BehaviorSubject } from 'rxjs/BehaviorSubject';
@Injectable()
export class ProcessLogService {
newLog = new BehaviorSubject<any>(config.console.defaultLogs);
newLogs = new BehaviorSubject<any>(config.console.defaultLogs);
showLiveLogs = config.console.showLiveLogs;
command_handlers = {
'new_log': this.newLogHandler.bind(this)
'new_log': this.newLogsHandler.bind(this)
};
constructor(private webSocketService: WebSocketService) {
@ -23,9 +23,15 @@ export class ProcessLogService {
);
}
newLogHandler(data: ProcessLogCommand) {
emitNewLogsIfNoLiveLogs(log: any) {
if (!config.console.showLiveLogs) {
this.newLogs.next(log);
}
}
newLogsHandler(data: ProcessLogCommand) {
if (this.showLiveLogs) {
this.newLog.next({
this.newLogs.next({
stdout: data.stdout,
stderr: data.stderr
});