mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2025-07-12 16:46:22 +00:00
Move live log checking logic to ProcessLogService
This commit is contained in:
@ -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
|
||||
});
|
||||
|
Reference in New Issue
Block a user