Skip to content
Snippets Groups Projects
Commit 1ac34195 authored by paf's avatar paf
Browse files

linting

parent b5f7d4de
No related branches found
No related tags found
No related merge requests found
Pipeline #19017 passed with warnings
......@@ -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 => {
......
......@@ -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();
}
}),
......
......@@ -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();
}
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment