Implement solution check forwarding

This commit is contained in:
Kristóf Tóth
2019-09-06 15:36:40 +02:00
parent 43e43b061d
commit 57db977873
11 changed files with 59 additions and 14 deletions

View File

@ -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();
});