From 04e04029d2327a99a23ba69c8442df67a457da3b Mon Sep 17 00:00:00 2001 From: Martin Mechtel <mechtelm@user.hu-berlin.de> Date: Mon, 17 Dec 2018 21:28:20 +0100 Subject: [PATCH] report nearly completed --- src/app/app.component.ts | 3 ++ src/app/sys-check/backend.service.ts | 7 ++++- .../environment-check.component.ts | 18 ++++++----- .../network-check/network-check.component.ts | 10 +++++-- src/app/sys-check/report/report.component.css | 2 ++ .../sys-check/report/report.component.html | 2 +- src/app/sys-check/report/report.component.ts | 7 +++-- src/app/sys-check/run.component.html | 5 ++-- src/app/sys-check/run.component.ts | 30 ++++++++++++++++++- src/app/sys-check/start.component.ts | 3 ++ src/app/sys-check/syscheck-data.service.ts | 13 ++++---- 11 files changed, 76 insertions(+), 24 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 35387925..445ed926 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,3 +1,4 @@ +import { SyscheckDataService } from './sys-check/syscheck-data.service'; import { TestControllerService } from './test-controller'; import { LogindataService } from './logindata.service'; import { merge } from 'rxjs'; @@ -19,11 +20,13 @@ export class AppComponent implements OnInit { constructor ( private lds: LogindataService, private tcs: TestControllerService, + private ccs: SyscheckDataService, private router: Router) { } ngOnInit() { merge( + this.ccs.pageTitle$, this.lds.pageTitle$, this.tcs.pageTitle$).subscribe(t => { this.title = t; diff --git a/src/app/sys-check/backend.service.ts b/src/app/sys-check/backend.service.ts index f78b7b10..9d314095 100644 --- a/src/app/sys-check/backend.service.ts +++ b/src/app/sys-check/backend.service.ts @@ -3,7 +3,6 @@ import { Injectable, Inject } from '@angular/core'; import { HttpClient, HttpParams, HttpHeaders, HttpEvent, HttpErrorResponse } from '@angular/common/http'; import { Observable, of } from 'rxjs'; import { catchError } from 'rxjs/operators'; -import { NetworkRequestTestResult } from './syscheck-data.service'; @Injectable({ providedIn: 'root' @@ -229,3 +228,9 @@ export interface UnitData { def: string; player: string; } + +export interface NetworkRequestTestResult { + 'type': 'downloadTest' | 'uploadTest'; + 'size': number; + 'duration': number; +} diff --git a/src/app/sys-check/environment-check/environment-check.component.ts b/src/app/sys-check/environment-check/environment-check.component.ts index 3dc2138c..ffe9ee87 100644 --- a/src/app/sys-check/environment-check/environment-check.component.ts +++ b/src/app/sys-check/environment-check/environment-check.component.ts @@ -40,6 +40,10 @@ export class EnvironmentCheckComponent implements OnInit { ) { } ngOnInit() { + this.startCheck(); + } + + startCheck() { this.deviceInfo = window.navigator.userAgent; // tslint:disable-next-line:max-line-length this.regex = /(MSIE|Trident|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari(?!.+Edge)|(?!AppleWebKit.+)Chrome(?!.+Edge)|(?!AppleWebKit.+Chrome.+Safari.+)Edge|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d\.apre]+)/; @@ -64,12 +68,16 @@ export class EnvironmentCheckComponent implements OnInit { this.discoveredEnvRating = this.calculateEnvironmentRating(this.discoveredEnvData); - // dummy: transform to label-value-pairs! const myReport: ReportEntry[] = []; - myReport.push({'label': 'lalala', 'value': 'sososo'}); + myReport.push({'label': 'Betriebssystem', 'value': this.discoveredEnvData.osName}); + myReport.push({'label': 'Bewertung', 'value': this.discoveredEnvRating.OSRating}); + myReport.push({'label': 'Browser', 'value': this.discoveredEnvData.browserName + ' Version ' + this.discoveredEnvData.browserVersion}); + myReport.push({'label': 'Bewertung', 'value': this.discoveredEnvRating.BrowserRating}); + myReport.push({'label': 'Bildschirm', 'value': + this.discoveredEnvData.resolution.width.toString() + ' x ' + this.discoveredEnvData.resolution.height.toString()}); + myReport.push({'label': 'Bewertung', 'value': this.discoveredEnvRating.ResolutionRating}); this.ds.environmentData$.next(myReport); - } getOSVersion() { @@ -105,10 +113,6 @@ export class EnvironmentCheckComponent implements OnInit { return this.osName; } - goto() { - this.ds.questionnaireAvailable$.next(true); - } - // // // // public calculateEnvironmentRating(ed: EnvironmentData): EnvironmentRating { const ratings: EnvironmentRating = { diff --git a/src/app/sys-check/network-check/network-check.component.ts b/src/app/sys-check/network-check/network-check.component.ts index a94ce8d7..2cef7475 100644 --- a/src/app/sys-check/network-check/network-check.component.ts +++ b/src/app/sys-check/network-check/network-check.component.ts @@ -1,6 +1,7 @@ -import { SyscheckDataService, NetworkRequestTestResult, ReportEntry } from './../syscheck-data.service'; +import { SyscheckDataService, ReportEntry } from './../syscheck-data.service'; import { Component, OnInit } from '@angular/core'; -import { BackendService, RequestBenchmarkerFunction, RequestBenchmarkerFunctionCallback} from '../backend.service'; +import { BackendService, NetworkRequestTestResult, RequestBenchmarkerFunction, + RequestBenchmarkerFunctionCallback} from '../backend.service'; @Component({ selector: 'iqb-network-check', @@ -151,7 +152,10 @@ export class NetworkCheckComponent implements OnInit { // send data for reporting const myReport: ReportEntry[] = []; - myReport.push({'label': 'lalala', 'value': 'sososo'}); + myReport.push({'label': 'download', 'value': this.averageSpeed.downloadTest.toLocaleString()}); + myReport.push({'label': 'upload', 'value': this.averageSpeed.uploadTest.toLocaleString()}); + myReport.push({'label': 'ping', 'value': this.averageSpeed.pingTest.toLocaleString()}); + myReport.push({'label': 'Bewertung', 'value': this.networkRating}); this.ds.networkData$.next(myReport); }); diff --git a/src/app/sys-check/report/report.component.css b/src/app/sys-check/report/report.component.css index c695f52c..5515af2e 100644 --- a/src/app/sys-check/report/report.component.css +++ b/src/app/sys-check/report/report.component.css @@ -11,4 +11,6 @@ display: block; left: 15px; right: 15px; + overflow-y: auto; + overflow-x: scroll; } diff --git a/src/app/sys-check/report/report.component.html b/src/app/sys-check/report/report.component.html index 91fe87db..61a3bd8b 100644 --- a/src/app/sys-check/report/report.component.html +++ b/src/app/sys-check/report/report.component.html @@ -6,6 +6,6 @@ <p *ngFor="let rd of environmentData">{{ rd.label }}: {{ rd.value }}</p> <h2>Netzwerk-Info</h2> <p *ngFor="let rd of networkData">{{ rd.label }}: {{ rd.value }}</p> - <h2>Fragen</h2> + <h2 *ngIf="questionnaireData.length > 0">Fragen</h2> <p *ngFor="let rd of questionnaireData">{{ rd.label }}: {{ rd.value }}</p> </div> diff --git a/src/app/sys-check/report/report.component.ts b/src/app/sys-check/report/report.component.ts index 42194b5a..43a3522f 100644 --- a/src/app/sys-check/report/report.component.ts +++ b/src/app/sys-check/report/report.component.ts @@ -18,8 +18,11 @@ export class ReportComponent implements OnInit { } ngOnInit() { - this.ds.environmentData$.subscribe(rd => this.environmentData = rd); - this.ds.networkData$.subscribe(rd => this.networkData = rd); + // this.ds.environmentData$.subscribe(rd => ); too early! + this.ds.networkData$.subscribe(rd => { + this.networkData = rd; + this.environmentData = this.ds.environmentData$.getValue(); + }); this.ds.questionnaireData$.subscribe(rd => this.questionnaireData = rd); this.ds.reportEnabled$.subscribe(is => this.reportEnabled = is); diff --git a/src/app/sys-check/run.component.html b/src/app/sys-check/run.component.html index 190de470..125eb3f1 100644 --- a/src/app/sys-check/run.component.html +++ b/src/app/sys-check/run.component.html @@ -4,9 +4,9 @@ <div class="page-body"> <div class="sheetofpaper"> <mat-horizontal-stepper labelPosition="bottom" #stepper (selectionChange)="stepperSelectionChanged($event)"> - <mat-step> + <mat-step #stepEnv> <ng-template matStepLabel>Computer</ng-template> - <iqb-environment-check></iqb-environment-check> + <iqb-environment-check #compEnv></iqb-environment-check> <div class="navi_buttons"> <button mat-mini-fab matStepperNext> <i class="material-icons">chevron_right</i> @@ -56,6 +56,7 @@ <button mat-mini-fab matStepperPrevious> <i class="material-icons">chevron_left</i> </button> + <button mat-raised-button>Als E-Mail verschicken</button> </div> </mat-step> </mat-horizontal-stepper> diff --git a/src/app/sys-check/run.component.ts b/src/app/sys-check/run.component.ts index b0ed894f..f97fafdc 100644 --- a/src/app/sys-check/run.component.ts +++ b/src/app/sys-check/run.component.ts @@ -6,6 +6,7 @@ import { Component, OnInit, ViewChild } from '@angular/core'; import { CheckConfigData, BackendService } from './backend.service'; import { MatStepper, MatStep } from '../../../node_modules/@angular/material'; import { UnitCheckComponent } from './unit-check/unit-check.component'; +import { EnvironmentCheckComponent } from './environment-check/environment-check.component'; @Component({ @@ -15,15 +16,19 @@ import { UnitCheckComponent } from './unit-check/unit-check.component'; }) export class RunComponent implements OnInit { @ViewChild('stepper') stepper: MatStepper; + @ViewChild('stepEnv') stepEnv: MatStep; + @ViewChild('compEnv') compEnv: EnvironmentCheckComponent; @ViewChild('stepNetwork') stepNetwork: MatStep; - @ViewChild('stepUnit') stepUnit: MatStep; @ViewChild('compNetwork') compNetwork: NetworkCheckComponent; + @ViewChild('stepUnit') stepUnit: MatStep; @ViewChild('compUnit') compUnit: UnitCheckComponent; paramId: string; unitcheckAvailable = false; questionnaireAvailable = false; + emailEnabled = false; + constructor( private bs: BackendService, @@ -49,6 +54,25 @@ export class RunComponent implements OnInit { } else { this.bs.getCheckConfigData(this.paramId).subscribe( scData => { + if (typeof scData.downloadGood === 'undefined') { + scData.downloadGood = this.bs.basicTestConfigData.downloadGood; + } + if (typeof scData.downloadMinimum === 'undefined') { + scData.downloadMinimum = this.bs.basicTestConfigData.downloadMinimum; + } + if (typeof scData.uploadGood === 'undefined') { + scData.uploadGood = this.bs.basicTestConfigData.uploadGood; + } + if (typeof scData.uploadMinimum === 'undefined') { + scData.uploadMinimum = this.bs.basicTestConfigData.uploadMinimum; + } + if (typeof scData.pingGood === 'undefined') { + scData.pingGood = this.bs.basicTestConfigData.pingGood; + } + if (typeof scData.pingMinimum === 'undefined') { + scData.pingMinimum = this.bs.basicTestConfigData.pingMinimum; + } + this.ds.checkConfig$.next(scData); this.stepper.selectedIndex = 0; this.stepNetwork.completed = false; @@ -59,6 +83,8 @@ export class RunComponent implements OnInit { } stepperSelectionChanged(e) { + this.ds.setPageTitle(); + if (e.selectedStep === this.stepUnit) { if (!this.stepUnit.completed) { const cd = this.ds.checkConfig$.getValue(); @@ -70,6 +96,8 @@ export class RunComponent implements OnInit { this.compNetwork.startCheck(); this.stepNetwork.completed = true; } + } else if (e.selectedStep === this.stepEnv) { + this.compEnv.startCheck(); } } diff --git a/src/app/sys-check/start.component.ts b/src/app/sys-check/start.component.ts index abe4473f..629b8c22 100644 --- a/src/app/sys-check/start.component.ts +++ b/src/app/sys-check/start.component.ts @@ -1,3 +1,4 @@ +import { SyscheckDataService } from './syscheck-data.service'; import { Router, ActivatedRoute } from '@angular/router'; import { BackendService, CheckConfig } from './backend.service'; import { Component, OnInit } from '@angular/core'; @@ -15,6 +16,7 @@ export class StartComponent implements OnInit { constructor( private bs: BackendService, + private ds: SyscheckDataService, private route: ActivatedRoute, private router: Router) { } @@ -24,6 +26,7 @@ export class StartComponent implements OnInit { this.checkConfigList = myConfigs; this.checkConfigList.push(this.bs.basicTestConfig); this.dataLoading = false; + this.ds.setPageTitle(); }); } diff --git a/src/app/sys-check/syscheck-data.service.ts b/src/app/sys-check/syscheck-data.service.ts index 5763b114..00b91971 100644 --- a/src/app/sys-check/syscheck-data.service.ts +++ b/src/app/sys-check/syscheck-data.service.ts @@ -7,6 +7,8 @@ import { e } from '@angular/core/src/render3'; providedIn: 'root' }) export class SyscheckDataService { + public pageTitle$ = new BehaviorSubject<string>('IQB-Testcenter - System-Check'); + public checkConfig$ = new BehaviorSubject<CheckConfigData>(null); public environmentData$ = new BehaviorSubject<ReportEntry[]>([]); public networkData$ = new BehaviorSubject<ReportEntry[]>([]); @@ -22,8 +24,8 @@ export class SyscheckDataService { constructor() { this.checkConfig$.subscribe(cDef => { - this.environmentData$.next([]); this.networkData$.next([]); + this.questionnaireData$.next([]); if (cDef === null) { this.reportWithEmail$.next(false); this.unitcheckAvailable$.next(false); @@ -35,13 +37,10 @@ export class SyscheckDataService { } }); } -} - -export interface NetworkRequestTestResult { - 'type': 'downloadTest' | 'uploadTest'; - 'size': number; - 'duration': number; + setPageTitle() { + this.pageTitle$.next('IQB-Testcenter - System-Check'); + } } export interface ReportEntry { -- GitLab