From f77d89fca28fd103c6bf5d650099a54f655a6473 Mon Sep 17 00:00:00 2001 From: paflov <paf@titelfrei.de> Date: Wed, 22 Jan 2020 12:40:07 +0100 Subject: [PATCH] rename run.compoment to sys-check-component --- src/app/sys-check/run.component.ts | 175 ------------------ src/app/sys-check/sys-check-routing.module.ts | 4 +- ...omponent.html => sys-check.component.html} | 0 ...omponent.scss => sys-check.component.scss} | 0 ...nt.spec.ts => sys-check.component.spec.ts} | 10 +- src/app/sys-check/sys-check.component.ts | 66 +++++++ src/app/sys-check/sys-check.module.ts | 4 +- 7 files changed, 75 insertions(+), 184 deletions(-) delete mode 100644 src/app/sys-check/run.component.ts rename src/app/sys-check/{run.component.html => sys-check.component.html} (100%) rename src/app/sys-check/{run.component.scss => sys-check.component.scss} (100%) rename src/app/sys-check/{run.component.spec.ts => sys-check.component.spec.ts} (61%) create mode 100644 src/app/sys-check/sys-check.component.ts diff --git a/src/app/sys-check/run.component.ts b/src/app/sys-check/run.component.ts deleted file mode 100644 index 7f401ac2..00000000 --- a/src/app/sys-check/run.component.ts +++ /dev/null @@ -1,175 +0,0 @@ -import { SaveReportComponent } from './report/save-report/save-report.component'; -import { NetworkCheckComponent } from './network-check/network-check.component'; -import { SyscheckDataService } from './syscheck-data.service'; -import { ActivatedRoute, ParamMap } from '@angular/router'; -import { Component, OnInit, ViewChild } from '@angular/core'; -import {BackendService, CheckConfig, CheckConfigData, FormDefEntry, Rating} from './backend.service'; -import { UnitCheckComponent } from './unit-check/unit-check.component'; -import { MatDialog, MatSnackBar } from '@angular/material'; -import { map, skip, zip } from 'rxjs/operators'; -import { StepperSelectionEvent } from '@angular/cdk/stepper'; - - -interface Checks { // a cleaned version of CheckConfigData .. TODO maybe merge them togeether - environment: boolean; - unit: boolean; - questions: boolean; - network: boolean; - report: boolean; -} - -@Component({ - selector: 'app-run', - templateUrl: './run.component.html', - styleUrls: ['./run.component.scss'] -}) -export class RunComponent implements OnInit { - - checks: Checks = { - environment: true, - unit: false, - questions: false, - network: false, - report: true - }; - - title: String = ''; - - constructor( - private bs: BackendService, - private ds: SyscheckDataService, - private route: ActivatedRoute - ) { - } - - ngOnInit() { - - this.route.paramMap.subscribe((params: ParamMap) => { - const paramId = params.get('c'); - if (paramId === this.bs.basicTestConfig.id) { - this.loadTestConfig(this.bs.basicTestConfigData); - } else { - this.bs.getCheckConfigData(paramId).subscribe(config => this.loadTestConfig(config)); - } - }); - } - - loadTestConfig(checkConfig: CheckConfigData) { - - console.log('loading', checkConfig); - - this.title = 'IQB-Testcenter: ' + checkConfig.label; - this.checks.environment = !checkConfig.questionsonlymode; - this.checks.unit = checkConfig.hasunit && !checkConfig.questionsonlymode; - this.checks.network = !checkConfig.skipnetwork && !checkConfig.questionsonlymode; - this.checks.questions = checkConfig.questions.length > 0; - this.checks.report = checkConfig.cansave; - - console.log('this.checks', this.checks); - this.ds.checkConfig$.next(checkConfig); - - if (this.checks.unit) { this.ds.taskQueue.push('loadunit'); } - if (this.checks.network) { this.ds.taskQueue.push('speedtest'); } - this.ds.nextTask(); - } - - // this.ds.networkData$.subscribe(nd => { - // // if (typeof this.stepNetwork !== 'undefined') { - // // this.stepNetwork.completed = nd.length > 0; - // // } - // }); - // - // this.route.paramMap.subscribe((params: ParamMap) => { - // this.paramId = params.get('c'); - // if (this.paramId === this.bs.basicTestConfig.id) { - // this.ds.checkConfig$.next(this.bs.basicTestConfigData); - // // this.stepper.selectedIndex = 0; - // // if (typeof this.stepNetwork !== 'undefined') { - // // this.stepNetwork.completed = false; - // // } - // this.unitcheckAvailable = false; - // this.questionnaireAvailable = false; - // this.questionsonlymode = false; - // this.skipnetwork = false; - // } else { - // this.bs.getCheckConfigData(this.paramId).subscribe( - // scData => { - // scData.downloadGood = this.bs.basicTestConfigData.downloadGood; - // scData.downloadMinimum = this.bs.basicTestConfigData.downloadMinimum; - // scData.uploadGood = this.bs.basicTestConfigData.uploadGood; - // scData.uploadMinimum = this.bs.basicTestConfigData.uploadMinimum; - // scData.pingGood = this.bs.basicTestConfigData.pingGood; - // scData.pingMinimum = this.bs.basicTestConfigData.pingMinimum; - // - // if (typeof scData.ratings !== 'undefined') { - // for (let i = 0; i < scData.ratings.length; i++) { - // if (scData.ratings[i].type === 'download') { - // scData.downloadGood = scData.ratings[i].good; - // scData.downloadMinimum = scData.ratings[i].min; - // } else if (scData.ratings[i].type === 'upload') { - // scData.uploadGood = scData.ratings[i].good; - // scData.uploadMinimum = scData.ratings[i].min; - // } else if (scData.ratings[i].type === 'ping') { - // scData.pingGood = scData.ratings[i].good; - // scData.pingMinimum = scData.ratings[i].min; - // } - // } - // } - // - // this.ds.checkConfig$.next(scData); - // // this.stepper.selectedIndex = 0; - // this.skipnetwork = scData.skipnetwork; - // // if (typeof this.stepNetwork !== 'undefined') { - // // this.stepNetwork.completed = this.skipnetwork; - // // } - // this.saveEnabled = scData.cansave; - // this.questionsonlymode = scData.questionsonlymode; - // if (this.questionsonlymode) { - // // worst case: step is shown but no questions - // this.questionnaireAvailable = true; - // this.unitcheckAvailable = false; - // } else { - // this.questionnaireAvailable = scData.questions.length > 0; - // this.unitcheckAvailable = scData.hasunit; - // } - // } - // ); - // } - // }); - // - // - // - // this.stepper.animationDone - // .pipe( - // skip(1), // animationDone gets called when the the stepper is rendered the frist time on step 1, but not selectionChange - // zip(this.stepper.selectionChange), - // map((combined: [any, StepperSelectionEvent]) => combined[1]) - // ) - // // .subscribe(stepEvent => {this.stepperSelectionChanged(stepEvent); }); - // } - // - // stepperSelectionChanged(e: StepperSelectionEvent) { - // this.ds.showNaviButtons$.next(false); - // - // if (e.selectedStep === this.stepUnit) { - // this.ds.showNaviButtons$.next(true); - // if (!this.stepUnit.completed) { - // const cd = this.ds.checkConfig$.getValue(); - // this.compUnit.loadUnitandPlayer(cd.id); - // this.stepUnit.completed = true; - // } - // } else if (e.selectedStep === this.stepNetwork) { - // if (this.skipnetwork) { - // this.stepNetwork.completed = true; - // } else { - // if (!this.stepNetwork.completed) { - // this.compNetwork.startCheck(); - // } - // } - // } - // } - - - - -} diff --git a/src/app/sys-check/sys-check-routing.module.ts b/src/app/sys-check/sys-check-routing.module.ts index c07fd666..8944a0d0 100644 --- a/src/app/sys-check/sys-check-routing.module.ts +++ b/src/app/sys-check/sys-check-routing.module.ts @@ -1,4 +1,4 @@ -import { RunComponent } from './run.component'; +import { SysCheckComponent } from './sys-check.component'; import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { StartComponent } from './start.component'; @@ -14,7 +14,7 @@ const routes: Routes = [ }, { path: 'run/:c', - component: RunComponent + component: SysCheckComponent }]; @NgModule({ diff --git a/src/app/sys-check/run.component.html b/src/app/sys-check/sys-check.component.html similarity index 100% rename from src/app/sys-check/run.component.html rename to src/app/sys-check/sys-check.component.html diff --git a/src/app/sys-check/run.component.scss b/src/app/sys-check/sys-check.component.scss similarity index 100% rename from src/app/sys-check/run.component.scss rename to src/app/sys-check/sys-check.component.scss diff --git a/src/app/sys-check/run.component.spec.ts b/src/app/sys-check/sys-check.component.spec.ts similarity index 61% rename from src/app/sys-check/run.component.spec.ts rename to src/app/sys-check/sys-check.component.spec.ts index e9439dda..bf1b59b5 100644 --- a/src/app/sys-check/run.component.spec.ts +++ b/src/app/sys-check/sys-check.component.spec.ts @@ -1,20 +1,20 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { RunComponent } from './run.component'; +import { SysCheckComponent } from './sys-check.component'; describe('RunComponent', () => { - let component: RunComponent; - let fixture: ComponentFixture<RunComponent>; + let component: SysCheckComponent; + let fixture: ComponentFixture<SysCheckComponent>; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ RunComponent ] + declarations: [ SysCheckComponent ] }) .compileComponents(); })); beforeEach(() => { - fixture = TestBed.createComponent(RunComponent); + fixture = TestBed.createComponent(SysCheckComponent); component = fixture.componentInstance; fixture.detectChanges(); }); diff --git a/src/app/sys-check/sys-check.component.ts b/src/app/sys-check/sys-check.component.ts new file mode 100644 index 00000000..092d29dd --- /dev/null +++ b/src/app/sys-check/sys-check.component.ts @@ -0,0 +1,66 @@ +import { SyscheckDataService } from './syscheck-data.service'; +import { ActivatedRoute, ParamMap } from '@angular/router'; +import { Component, OnInit} from '@angular/core'; +import {BackendService, CheckConfigData, FormDefEntry, Rating} from './backend.service'; + + +interface Checks { + environment: boolean; + unit: boolean; + questions: boolean; + network: boolean; + report: boolean; +} + +@Component({ + selector: 'app-run', + templateUrl: './sys-check.component.html', + styleUrls: ['./sys-check.component.scss'] +}) +export class SysCheckComponent implements OnInit { + + checks: Checks = { + environment: true, + unit: false, + questions: false, + network: false, + report: true + }; + + title: String = ''; + + constructor( + private bs: BackendService, + private ds: SyscheckDataService, + private route: ActivatedRoute + ) { + } + + ngOnInit() { + + this.route.paramMap.subscribe((params: ParamMap) => { + const paramId = params.get('c'); + if (paramId === this.bs.basicTestConfig.id) { + this.loadTestConfig(this.bs.basicTestConfigData); + } else { + this.bs.getCheckConfigData(paramId).subscribe(config => this.loadTestConfig(config)); + } + }); + } + + loadTestConfig(checkConfig: CheckConfigData) { + + this.title = 'IQB-Testcenter: ' + checkConfig.label; + this.checks.environment = !checkConfig.questionsonlymode; + this.checks.unit = checkConfig.hasunit && !checkConfig.questionsonlymode; + this.checks.network = !checkConfig.skipnetwork && !checkConfig.questionsonlymode; + this.checks.questions = checkConfig.questions.length > 0; + this.checks.report = checkConfig.cansave; + + this.ds.checkConfig$.next(checkConfig); + + if (this.checks.unit) { this.ds.taskQueue.push('loadunit'); } + if (this.checks.network) { this.ds.taskQueue.push('speedtest'); } + this.ds.nextTask(); + } +} diff --git a/src/app/sys-check/sys-check.module.ts b/src/app/sys-check/sys-check.module.ts index 90eb2e36..c0cec441 100644 --- a/src/app/sys-check/sys-check.module.ts +++ b/src/app/sys-check/sys-check.module.ts @@ -6,7 +6,7 @@ import { CommonModule } from '@angular/common'; import { SysCheckRoutingModule } from './sys-check-routing.module'; import { StartComponent } from './start.component'; -import { RunComponent } from './run.component'; +import { SysCheckComponent } from './sys-check.component'; import { FlexLayoutModule } from '@angular/flex-layout'; import { MatButtonModule, MatCheckboxModule, MatCardModule, MatStepperModule, MatIconModule, MatDialogModule, MatFormFieldModule, MatInputModule, MatSelectModule, @@ -48,7 +48,7 @@ import { TcSpeedChartComponent } from './network-check/tc-speed-chart.component' ], declarations: [ StartComponent, - RunComponent, + SysCheckComponent, EnvironmentCheckComponent, NetworkCheckComponent, UnitCheckComponent, -- GitLab