mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2025-07-01 04:56:23 +00:00
Implement solution check forwarding
This commit is contained in:
@ -6,6 +6,7 @@ import { WebSocketMessage } from '../message-types/websocket-message';
|
||||
import { DashboardConfigService } from '../services/config.service';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { delay, retryWhen, tap } from 'rxjs/operators';
|
||||
import { FSMUpdateService } from '../services/fsmupdate.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dashboard',
|
||||
@ -37,11 +38,13 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
||||
private webSocketService: WebSocketService,
|
||||
private changeDetectorRef: ChangeDetectorRef,
|
||||
private http: HttpClient,
|
||||
private configService: DashboardConfigService) {}
|
||||
private configService: DashboardConfigService,
|
||||
private fsmUpdateService: FSMUpdateService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.webSocketService.connect();
|
||||
this.configService.init();
|
||||
this.subscribeCheckSolution();
|
||||
this.hideIframeUntilResponseOk();
|
||||
this.subscribeResizeOnLayoutChange();
|
||||
this.initCommandHandling();
|
||||
@ -49,6 +52,15 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
||||
this.sendReady();
|
||||
}
|
||||
|
||||
subscribeCheckSolution() {
|
||||
this.fsmUpdateService.init();
|
||||
this.fsmUpdateService.in_accepted_state.subscribe(in_accepted_state => {
|
||||
if (in_accepted_state) {
|
||||
window.parent.postMessage('check solution', '*');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
hideIframeUntilResponseOk() {
|
||||
// TODO: hide iframe and show it after this whole deal...
|
||||
this.reloadIframeWhenResponseOk();
|
||||
@ -62,7 +74,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
initCommandHandling() {
|
||||
this.webSocketService.observeKey<WebSocketMessage>('dashboard').subscribe(message => {
|
||||
this.webSocketService.observeControl<WebSocketMessage>('dashboard').subscribe(message => {
|
||||
this.command_handlers[message.key](message);
|
||||
this.changeDetectorRef.detectChanges();
|
||||
});
|
||||
|
Reference in New Issue
Block a user