diff --git a/src/app/group-monitor/group-monitor.component.ts b/src/app/group-monitor/group-monitor.component.ts index 4d7e1b5d17734f72f975b688abf16cca7ae84de6..588814aced396de30791c54ca5320b30aefd17d2 100644 --- a/src/app/group-monitor/group-monitor.component.ts +++ b/src/app/group-monitor/group-monitor.component.ts @@ -26,15 +26,6 @@ import { BookletUtil } from './booklet/booklet.util'; styleUrls: ['./group-monitor.component.css'] }) export class GroupMonitorComponent implements OnInit, OnDestroy { - constructor( - public dialog: MatDialog, - private route: ActivatedRoute, - private bs: BackendService, - public tsm: TestSessionManager, - private router: Router, - private cts: CustomtextService - ) {} - connectionStatus$: Observable<ConnectionStatus>; ownGroup$: Observable<GroupData>; @@ -60,9 +51,18 @@ export class GroupMonitorComponent implements OnInit, OnDestroy { private subscriptions: Subscription[] = []; - @ViewChild('adminbackground') mainElem:ElementRef; + @ViewChild('adminbackground') mainElem: ElementRef; @ViewChild('sidenav', { static: true }) sidenav: MatSidenav; + constructor( + public dialog: MatDialog, + private route: ActivatedRoute, + private bs: BackendService, + public tsm: TestSessionManager, + private router: Router, + private cts: CustomtextService + ) {} + ngOnInit(): void { this.subscriptions = [ this.route.params.subscribe(params => { diff --git a/src/app/shared/websocket-backend.service.ts b/src/app/shared/websocket-backend.service.ts index 23b8d7618ff394752e8cc8951fdaa0e560146b53..9af4e0ade353090770ce046515c2444a99b766e4 100644 --- a/src/app/shared/websocket-backend.service.ts +++ b/src/app/shared/websocket-backend.service.ts @@ -15,8 +15,8 @@ export abstract class WebsocketBackendService<T> extends WebsocketService implem protected abstract wsChannelName: string; protected abstract initialData: T; - public data$: BehaviorSubject<T>; - public connectionStatus$: BehaviorSubject<ConnectionStatus> = new BehaviorSubject<ConnectionStatus>('initial'); + data$: BehaviorSubject<T>; + connectionStatus$: BehaviorSubject<ConnectionStatus> = new BehaviorSubject<ConnectionStatus>('initial'); private wsConnectionStatusSubscription: Subscription = null; private wsDataSubscription: Subscription = null; @@ -56,7 +56,6 @@ export abstract class WebsocketBackendService<T> extends WebsocketService implem // TODO interceptor should have interfered and moved to error-page // https://github.com/iqb-berlin/testcenter-frontend/issues/53 catchError((err: ApiError) => { - console.warn(`Api-Error: ${err.code} ${err.info}`); this.connectionStatus$.next('error'); return new Observable<T>(); }) @@ -65,7 +64,6 @@ export abstract class WebsocketBackendService<T> extends WebsocketService implem this.data$.next(response.body); if (response.headers.has('SubscribeURI')) { this.wsUrl = response.headers.get('SubscribeURI'); - console.log('switch to websocket-mode'); this.subScribeToWsChannel(); } else { this.connectionStatus$.next('polling-sleep'); @@ -74,9 +72,7 @@ export abstract class WebsocketBackendService<T> extends WebsocketService implem }); } - public cutConnection(): void { - console.log('cut monitor connection'); - + cutConnection(): void { this.unsubscribeFromWebsocket(); this.closeConnection(); @@ -120,7 +116,6 @@ export abstract class WebsocketBackendService<T> extends WebsocketService implem skipWhile((item: boolean) => item === null), // skip pre-init-state tap((wsConnected: boolean) => { if (!wsConnected) { - console.log('switch to polling-mode'); this.scheduleNextPoll(); } }), diff --git a/src/app/shared/websocket.service.ts b/src/app/shared/websocket.service.ts index 81f81af55eb1c729d9b15bc75b7a25cc72d2058b..ba117511d2f601e4405188e702bd049d9f617ffb 100644 --- a/src/app/shared/websocket.service.ts +++ b/src/app/shared/websocket.service.ts @@ -12,45 +12,32 @@ interface WsMessage { export class WebsocketService { protected wsUrl = ''; private wsSubject$: WebSocketSubject<any>; - public wsConnected$ = new BehaviorSubject<boolean>(null); + wsConnected$ = new BehaviorSubject<boolean>(null); private wsSubscription: Subscription; - public connect(): void { + connect(): void { if (!this.wsSubject$) { - - console.log(`connecting... ${this.wsUrl}`); - this.wsSubject$ = webSocket({ - deserializer(event: MessageEvent): any { return JSON.parse(event.data); }, - serializer(value: any): WebSocketMessage { return JSON.stringify(value); }, - openObserver: { next: () => { - console.log('connection established'); this.wsConnected$.next(true); } }, - url: this.wsUrl }); this.wsSubscription = this.wsSubject$.subscribe( - () => {}, - () => { - console.error('connection error'); this.closeConnection(); }, - () => { - console.log('connection closed'); this.closeConnection(); } ); @@ -68,7 +55,7 @@ export class WebsocketService { } } - public send(event: string, data: any): void { + send(event: string, data: any): void { if (!this.wsSubject$) { this.connect(); } @@ -76,7 +63,7 @@ export class WebsocketService { this.wsSubject$.next({ event, data }); } - public getChannel<T>(channelName: string): Observable<T> { + getChannel<T>(channelName: string): Observable<T> { if (!this.wsSubject$) { this.connect(); } diff --git a/src/app/test-controller/command.service.ts b/src/app/test-controller/command.service.ts index 97f9aa75a580718167eef6e2959e29415d31b756..04b232606505b0920ab9f726395a6f7627dff20e 100644 --- a/src/app/test-controller/command.service.ts +++ b/src/app/test-controller/command.service.ts @@ -26,7 +26,7 @@ type TestStartedOrStopped = 'started' | 'terminated' | ''; providedIn: 'root' }) export class CommandService extends WebsocketBackendService<Command[]> implements OnDestroy { - public command$: Subject<Command> = new Subject<Command>(); + command$: Subject<Command> = new Subject<Command>(); protected initialData = []; protected pollingEndpoint = ''; @@ -88,7 +88,6 @@ export class CommandService extends WebsocketBackendService<Command[]> implement // min delay between items concatMap((command: Command) => timer(1000).pipe(ignoreElements(), startWith(command))), mergeMap((command: Command) => { - console.log(`try to execute ${CommandService.commandToString(command)}`); return this.http.patch(`${this.serverUrl}test/${this.tcs.testId}/command/${command.id}/executed`, {}) .pipe( map(() => command), @@ -144,7 +143,6 @@ export class CommandService extends WebsocketBackendService<Command[]> implement timestamp: Date.now() }; if (!isKnownCommand(keyword)) { - console.warn(`Unknown command: ${CommandService.commandToString(command)}`); return; } this.command$.next(command);