From 69440990e042b1b2ca80ae37b0334a130ca80c00 Mon Sep 17 00:00:00 2001 From: mechtelm <nicht@mehr.fragen> Date: Mon, 20 Apr 2020 12:05:52 +0200 Subject: [PATCH] app mostly works - time to test and to issue issues --- src/app/app.component.ts | 2 +- src/app/backend.service.ts | 4 +- src/app/maindata.service.ts | 1 + .../start-lock-input.component.html | 2 +- .../start-lock-input.component.ts | 2 +- .../test-controller.component.ts | 2 + .../unithost/unit-routing-guards.ts | 6 +- .../unithost/unithost.component.ts | 82 ++++++++++--------- 8 files changed, 54 insertions(+), 47 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index df2819cf..d21bb55f 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -75,7 +75,7 @@ export class AppComponent implements OnInit, OnDestroy { this.appDelayedProcessesSubscription = this.mds.delayedProcessesCount$.pipe( debounceTime(500) ).subscribe( c => { - this.showSpinner = c > 0; + this.showSpinner = this.mds.progressVisualEnabled && c > 0; }); window.addEventListener('message', (event: MessageEvent) => { diff --git a/src/app/backend.service.ts b/src/app/backend.service.ts index 8ecf52b2..6906fbb2 100644 --- a/src/app/backend.service.ts +++ b/src/app/backend.service.ts @@ -118,9 +118,9 @@ export class BackendService { })); } - startTest(bookletId: string): Observable<string | number> { + startTest(bookletName: string): Observable<string | number> { return this.http - .put<number>(this.serverUrl + 'test', {bookletId}) + .put<number>(this.serverUrl + 'test', {bookletName}) .pipe( map((testId: number) => String(testId)), catchError(errCode => of(errCode)) diff --git a/src/app/maindata.service.ts b/src/app/maindata.service.ts index 23a51b92..45151e2f 100644 --- a/src/app/maindata.service.ts +++ b/src/app/maindata.service.ts @@ -17,6 +17,7 @@ const localStorageAuthDataKey = 'iqb-tc'; export class MainDataService { public appError$ = new BehaviorSubject<AppError>(null); public delayedProcessesCount$ = new BehaviorSubject<number>(0); + public progressVisualEnabled = true; public isApiVersionValid = true; // set by app.component.ts diff --git a/src/app/test-controller/start-lock-input/start-lock-input.component.html b/src/app/test-controller/start-lock-input/start-lock-input.component.html index f9d8b6d9..3678754c 100644 --- a/src/app/test-controller/start-lock-input/start-lock-input.component.html +++ b/src/app/test-controller/start-lock-input/start-lock-input.component.html @@ -13,7 +13,7 @@ <button mat-raised-button color="primary" [disabled]="!startkeyform.valid" type="submit" - [mat-dialog-close]="startkeyform">Weiter</button> + [mat-dialog-close]="startkeyform.value">Weiter</button> <button mat-raised-button [mat-dialog-close]="false">Abbrechen</button> </mat-dialog-actions> </form> diff --git a/src/app/test-controller/start-lock-input/start-lock-input.component.ts b/src/app/test-controller/start-lock-input/start-lock-input.component.ts index 6de789c7..31afbaa1 100644 --- a/src/app/test-controller/start-lock-input/start-lock-input.component.ts +++ b/src/app/test-controller/start-lock-input/start-lock-input.component.ts @@ -15,7 +15,7 @@ export class StartLockInputComponent { const myFormControls = {}; this.data.codes.forEach(c => { - myFormControls[c.testletId] = new FormControl('', [Validators.required, Validators.minLength(3)]); + myFormControls[c.testletId] = new FormControl(c.value, [Validators.required, Validators.minLength(3)]); }); this.startkeyform = new FormGroup(myFormControls); } diff --git a/src/app/test-controller/test-controller.component.ts b/src/app/test-controller/test-controller.component.ts index 7523cec9..67990f0d 100644 --- a/src/app/test-controller/test-controller.component.ts +++ b/src/app/test-controller/test-controller.component.ts @@ -385,6 +385,7 @@ export class TestControllerComponent implements OnInit, OnDestroy { // ##################################################################################### ngOnInit() { setTimeout(() => { + this.mds.progressVisualEnabled = false; this.routingSubscription = this.route.params.subscribe(params => { this.tcs.testId = params['t']; this.unsubscribeTestSubscriptions(); @@ -613,5 +614,6 @@ export class TestControllerComponent implements OnInit, OnDestroy { this.routingSubscription.unsubscribe(); } this.unsubscribeTestSubscriptions(); + this.mds.progressVisualEnabled = true; } } diff --git a/src/app/test-controller/unithost/unit-routing-guards.ts b/src/app/test-controller/unithost/unit-routing-guards.ts index 0a70ba93..a1e3e1ad 100644 --- a/src/app/test-controller/unithost/unit-routing-guards.ts +++ b/src/app/test-controller/unithost/unit-routing-guards.ts @@ -7,7 +7,7 @@ import { Injectable } from '@angular/core'; import { CanActivate, CanDeactivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; import { Observable, of, interval } from 'rxjs'; import { UnitControllerData } from '../test-controller.classes'; -import { CodeInputData, LogEntryKey, StartLockData } from '../test-controller.interfaces'; +import {CodeInputData, LogEntryKey, RunModeKey, StartLockData} from '../test-controller.interfaces'; import { MainDataService } from 'src/app/maindata.service'; import {MatDialog} from "@angular/material/dialog"; import { MatSnackBar } from '@angular/material/snack-bar'; @@ -113,7 +113,7 @@ export class UnitActivateGuard implements CanActivate { testletId: t.id, prompt: t.codePrompt, code: t.codeToEnter.toUpperCase().trim(), - value: this.tcs.mode === 'hot' ? '' : t.codeToEnter + value: this.tcs.mode === (RunModeKey.HOT_RETURN || RunModeKey.HOT_RESTART) ? '' : t.codeToEnter }); }); @@ -128,6 +128,8 @@ export class UnitActivateGuard implements CanActivate { }); return dialogRef.afterClosed().pipe( switchMap(result => { + console.log(typeof result); + console.log(result); if ((typeof result === 'undefined') || (result === false)) { return of(false); } else { diff --git a/src/app/test-controller/unithost/unithost.component.ts b/src/app/test-controller/unithost/unithost.component.ts index 1dd0b5ca..10eceed3 100644 --- a/src/app/test-controller/unithost/unithost.component.ts +++ b/src/app/test-controller/unithost/unithost.component.ts @@ -161,57 +161,59 @@ export class UnithostComponent implements OnInit, OnDestroy { // % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % ngOnInit() { - this.iFrameHostElement = <HTMLElement>document.querySelector('#iFrameHost'); + setTimeout(() => { + this.iFrameHostElement = <HTMLElement>document.querySelector('#iFrameHost'); - this.iFrameItemplayer = null; - this.leaveWarning = false; + this.iFrameItemplayer = null; + this.leaveWarning = false; - this.routingSubscription = this.route.params.subscribe(params => { - this.myUnitSequenceId = Number(params['u']); - this.tcs.currentUnitSequenceId = this.myUnitSequenceId; + this.routingSubscription = this.route.params.subscribe(params => { + this.myUnitSequenceId = Number(params['u']); + this.tcs.currentUnitSequenceId = this.myUnitSequenceId; - while (this.iFrameHostElement.hasChildNodes()) { - this.iFrameHostElement.removeChild(this.iFrameHostElement.lastChild); - } + while (this.iFrameHostElement.hasChildNodes()) { + this.iFrameHostElement.removeChild(this.iFrameHostElement.lastChild); + } - if ((this.myUnitSequenceId >= 1) && (this.myUnitSequenceId === this.myUnitSequenceId) && (this.tcs.rootTestlet !== null)) { - this.tcs.setBookletState(LastStateKey.LASTUNIT, params['u']); + if ((this.myUnitSequenceId >= 1) && (this.myUnitSequenceId === this.myUnitSequenceId) && (this.tcs.rootTestlet !== null)) { + this.tcs.setBookletState(LastStateKey.LASTUNIT, params['u']); - const currentUnit = this.tcs.rootTestlet.getUnitAt(this.myUnitSequenceId); - this.unitTitle = currentUnit.unitDef.title; - this.myUnitDbKey = currentUnit.unitDef.alias; - this.tcs.currentUnitDbKey = this.myUnitDbKey; - this.tcs.currentUnitTitle = this.unitTitle; - this.itemplayerSessionId = Math.floor(Math.random() * 20000000 + 10000000).toString(); + const currentUnit = this.tcs.rootTestlet.getUnitAt(this.myUnitSequenceId); + this.unitTitle = currentUnit.unitDef.title; + this.myUnitDbKey = currentUnit.unitDef.alias; + this.tcs.currentUnitDbKey = this.myUnitDbKey; + this.tcs.currentUnitTitle = this.unitTitle; + this.itemplayerSessionId = Math.floor(Math.random() * 20000000 + 10000000).toString(); - this.setPageList([], ''); + this.setPageList([], ''); - this.iFrameItemplayer = <HTMLIFrameElement>document.createElement('iframe'); - // this.iFrameItemplayer.setAttribute('srcdoc', this.tcs.getPlayer(currentUnit.unitDef.playerId)); - this.iFrameItemplayer.setAttribute('sandbox', 'allow-forms allow-scripts allow-same-origin'); - this.iFrameItemplayer.setAttribute('class', 'unitHost'); - this.iFrameItemplayer.setAttribute('height', String(this.iFrameHostElement.clientHeight)); + this.iFrameItemplayer = <HTMLIFrameElement>document.createElement('iframe'); + // this.iFrameItemplayer.setAttribute('srcdoc', this.tcs.getPlayer(currentUnit.unitDef.playerId)); + this.iFrameItemplayer.setAttribute('sandbox', 'allow-forms allow-scripts allow-same-origin'); + this.iFrameItemplayer.setAttribute('class', 'unitHost'); + this.iFrameItemplayer.setAttribute('height', String(this.iFrameHostElement.clientHeight)); - if (this.tcs.hasUnitRestorePoint(this.myUnitSequenceId)) { - this.pendingUnitRestorePoint = {tag: this.itemplayerSessionId, value: this.tcs.getUnitRestorePoint(this.myUnitSequenceId)}; - } else { - this.pendingUnitRestorePoint = null; - } + if (this.tcs.hasUnitRestorePoint(this.myUnitSequenceId)) { + this.pendingUnitRestorePoint = {tag: this.itemplayerSessionId, value: this.tcs.getUnitRestorePoint(this.myUnitSequenceId)}; + } else { + this.pendingUnitRestorePoint = null; + } - this.leaveWarning = false; - if (!this.tcs.pageNav) { - this.iFrameHostElement.style.bottom = '0px'; - } + this.leaveWarning = false; + if (!this.tcs.pageNav) { + this.iFrameHostElement.style.bottom = '0px'; + } - if (this.tcs.hasUnitDefinition(this.myUnitSequenceId)) { - this.pendingUnitDefinition = {tag: this.itemplayerSessionId, value: this.tcs.getUnitDefinition(this.myUnitSequenceId)}; - } else { - this.pendingUnitDefinition = null; + if (this.tcs.hasUnitDefinition(this.myUnitSequenceId)) { + this.pendingUnitDefinition = {tag: this.itemplayerSessionId, value: this.tcs.getUnitDefinition(this.myUnitSequenceId)}; + } else { + this.pendingUnitDefinition = null; + } + this.iFrameHostElement.appendChild(this.iFrameItemplayer); + srcDoc.set(this.iFrameItemplayer, this.tcs.getPlayer(currentUnit.unitDef.playerId)); } - this.iFrameHostElement.appendChild(this.iFrameItemplayer); - srcDoc.set(this.iFrameItemplayer, this.tcs.getPlayer(currentUnit.unitDef.playerId)); - } - }); + }); + }) } // ++++++++++++ page nav ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- GitLab