Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | 1x | import { Component, OnInit, ViewChild } from '@angular/core'; import { Router } from '@angular/router'; import { FormControl, FormGroup, Validators } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { CustomtextService, MainDataService } from '../../shared/shared.module'; import { AppError, AuthData } from '../../app.interfaces'; import { BackendService } from '../../backend.service'; @Component({ templateUrl: './code-input.component.html', styles: [ '.mat-mdc-card {width: 400px;}' ] }) export class CodeInputComponent implements OnInit { @ViewChild('codeInputControl') codeInputControl!: FormControl; problemText = ''; problemCode = 0; codeinputform = new FormGroup({ code: new FormControl('', [Validators.required, Validators.minLength(2)]) }); constructor( private router: Router, public messageDialog: MatDialog, public cts: CustomtextService, public bs: BackendService, public mds: MainDataService ) { } ngOnInit(): void { setTimeout(() => { this.mds.appSubTitle$.next('Bitte Code eingeben'); const element = <HTMLElement>document.querySelector('.mat-input-element[formControlName="code"]'); Iif (element) { element.focus(); } }); } codeinput(): void { const codeData = this.codeinputform.value; this.problemText = ''; this.problemCode = 0; this.bs.codeLogin(codeData.code ?? '').subscribe({ next: authData => { const authDataTyped = authData as AuthData; this.mds.setAuthData(authDataTyped); if (authData.claims.test.length === 1 && Object.keys(authData.claims).length === 1) { this.bs.startTest(authData.claims.test[0].id).subscribe(testId => { this.router.navigate(['/t', testId]); }); } else { this.router.navigate(['/r']); } }, error: (error: AppError) => { this.problemCode = error.code || 777; if (error.code === 400) { this.problemText = 'Der Code ist leider nicht gültig. Bitte noch einmal versuchen'; } else if (error.code === 429) { this.problemText = 'Zu viele Fehlversuche! Probieren Sie es zu einem späteren Zeitpunkt noch einmal.'; } else { this.problemText = 'Problem bei der Anmeldung.'; throw error; } } }); } resetLogin(): void { this.mds.logOut(); } } |