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 4ac0a8855d4fc9c65e0d5b9433e1e61444c91935..3dc2138cb69a441b3212f50232bab0a41a17d090 100644 --- a/src/app/sys-check/environment-check/environment-check.component.ts +++ b/src/app/sys-check/environment-check/environment-check.component.ts @@ -1,5 +1,6 @@ +import { ReportEntry } from './../syscheck-data.service'; import { Component, OnInit } from '@angular/core'; -import { SyscheckDataService, EnvironmentRating, EnvironmentData } from '../syscheck-data.service'; +import { SyscheckDataService } from '../syscheck-data.service'; import { GeneratedFile } from '@angular/compiler'; @@ -12,7 +13,7 @@ export class EnvironmentCheckComponent implements OnInit { environmentRating: EnvironmentRating; screenSize: any; deviceInfo: any; - osName: any = "Unknown"; + osName: any = 'Unknown'; regex: any; helperRegex: any; isExisting: Array<string>; @@ -34,23 +35,23 @@ export class EnvironmentCheckComponent implements OnInit { BrowserRating: 'N/A' }; - constructor( + constructor( private ds: SyscheckDataService ) { } ngOnInit() { 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]+)/; // credit due to: https://gist.github.com/ticky/3909462#gistcomment-2245669 this.helperRegex = /[^.]*/; this.isExisting = this.regex.exec(this.deviceInfo); this.isExisting = this.helperRegex.exec(this.isExisting[0]); - this.result = this.isExisting[0].split("/"); - this.screenSize = "Screen size is " + window.screen.width + " pixels by " + window.screen.height + " pixels"; + this.result = this.isExisting[0].split('/'); + this.screenSize = 'Screen size is ' + window.screen.width + ' pixels by ' + window.screen.height + ' pixels'; this.osName = window.navigator.platform; - this.discoveredEnvData = { osName: this.getOSVersion(), browserName: this.result[0], @@ -59,30 +60,101 @@ export class EnvironmentCheckComponent implements OnInit { height: window.screen.height, width: window.screen.width } - } + }; + + this.discoveredEnvRating = this.calculateEnvironmentRating(this.discoveredEnvData); - this.discoveredEnvRating = this.ds.calculateEnvironmentRating(this.discoveredEnvData); + // dummy: transform to label-value-pairs! + const myReport: ReportEntry[] = []; + myReport.push({'label': 'lalala', 'value': 'sososo'}); - this.ds.environmentData$.next(this.discoveredEnvData); + this.ds.environmentData$.next(myReport); } getOSVersion() { - if (window.navigator.userAgent.indexOf("Windows")!= -1) { - if (window.navigator.userAgent.indexOf("Windows NT 10.0")!= -1) this.osName="Windows 10"; - if (window.navigator.userAgent.indexOf("Windows NT 6.2") != -1) this.osName="Windows 8"; - if (window.navigator.userAgent.indexOf("Windows NT 6.1") != -1) this.osName="Windows 7"; - if (window.navigator.userAgent.indexOf("Windows NT 6.0") != -1) this.osName="Windows Vista"; - if (window.navigator.userAgent.indexOf("Windows NT 5.1") != -1) this.osName="Windows XP"; - if (window.navigator.userAgent.indexOf("Windows NT 5.0") != -1) this.osName="Windows 2000"; + if (window.navigator.userAgent.indexOf('Windows') !== -1) { + if (window.navigator.userAgent.indexOf('Windows NT 10.0') !== -1) { + this.osName = 'Windows 10'; + } + if (window.navigator.userAgent.indexOf('Windows NT 6.2') !== -1) { + this.osName = 'Windows 8'; + } + if (window.navigator.userAgent.indexOf('Windows NT 6.1') !== -1) { + this.osName = 'Windows 7'; + } + if (window.navigator.userAgent.indexOf('Windows NT 6.0') !== -1) { + this.osName = 'Windows Vista'; + } + if (window.navigator.userAgent.indexOf('Windows NT 5.1') !== -1) { + this.osName = 'Windows XP'; + } + if (window.navigator.userAgent.indexOf('Windows NT 5.0') !== -1) { + this.osName = 'Windows 2000'; + } + } + if (window.navigator.userAgent.indexOf('Mac') !== -1) { + this.osName = 'Mac/iOS'; + } + if (window.navigator.userAgent.indexOf('X11') !== -1) { + this.osName = 'UNIX'; + } + if (window.navigator.userAgent.indexOf('Linux') !== -1) { + this.osName = 'Linux'; } - if (window.navigator.userAgent.indexOf("Mac") != -1) this.osName="Mac/iOS"; - if (window.navigator.userAgent.indexOf("X11") != -1) this.osName="UNIX"; - if (window.navigator.userAgent.indexOf("Linux") != -1) this.osName="Linux"; return this.osName; } goto() { this.ds.questionnaireAvailable$.next(true); } + + // // // // + public calculateEnvironmentRating(ed: EnvironmentData): EnvironmentRating { + const ratings: EnvironmentRating = { + OSRating: 'N/A', + ResolutionRating: 'N/A', + BrowserRating: 'N/A' + }; + + if (ed.osName === 'Windows 7' || ed.osName === 'Windows 10' || ed.osName === 'Windows 8' || ed.osName === 'Mac/iOS') { + ratings.OSRating = 'Good'; + } else if (ed.osName === 'Windows Vista' || ed.osName === 'Linux' || ed.osName === 'UNIX') { + ratings.OSRating = 'Possibly compatible'; + } else { + ratings.OSRating = 'Not compatible'; + } + + if (ed.browserName.indexOf('Chrome') || ed.browserName.indexOf('Mozilla')) { + if (parseInt(ed.browserVersion, 10) >= 60) { + ratings.BrowserRating = 'Good'; + } else { + ratings.BrowserRating = 'Not compatible'; + } + } + + if (ed.resolution.width >= 1024 && ed.resolution.height >= 768) { + ratings.ResolutionRating = 'Good'; + } else { + ratings.ResolutionRating = 'Not compatible'; + } + return ratings; + } +} + +export interface EnvironmentData { + osName: string; + // osVersion: string; + browserName: string; + browserVersion: string; + resolution: { + height: number; + width: number; + }; +} + +export interface EnvironmentRating { + OSRating: 'N/A' | 'Good'| 'Not compatible' | 'Possibly compatible'; + ResolutionRating: 'N/A' | 'Good'| 'Not compatible' | 'Possibly compatible'; + BrowserRating: 'N/A' | 'Good'| 'Not compatible' | 'Possibly compatible'; } 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 5053dc4cb694657408e352ab1d002657eac20cf4..54cb05f10b6496fa04955e4192b0147f9a512fc8 100644 --- a/src/app/sys-check/network-check/network-check.component.ts +++ b/src/app/sys-check/network-check/network-check.component.ts @@ -1,4 +1,4 @@ -import { SyscheckDataService, NetworkRequestTestResult, ReportEntry } from './../syscheck-data.service'; +import { SyscheckDataService, NetworkRequestTestResult, NetworkRating, ReportEntry } from './../syscheck-data.service'; import { Component, OnInit } from '@angular/core'; import { BackendService, RequestBenchmarkerFunction, RequestBenchmarkerFunctionCallback} from '../backend.service'; @@ -165,20 +165,3 @@ export interface AverageSpeed { downloadTest: number; pingTest: number; } - -export interface EnvironmentData { - osName: string; - // osVersion: string; - browserName: string; - browserVersion: string; - resolution: { - height: number; - width: number; - }; -} - -export interface EnvironmentRating { - OSRating: 'N/A' | 'Good'| 'Not compatible' | 'Possibly compatible'; - ResolutionRating: 'N/A' | 'Good'| 'Not compatible' | 'Possibly compatible'; - BrowserRating: 'N/A' | 'Good'| 'Not compatible' | 'Possibly compatible'; -} diff --git a/src/app/sys-check/questionnaire/questionnaire.component.html b/src/app/sys-check/questionnaire/questionnaire.component.html index ccbf61b5dc5b30044470a2fc030b99d550d06350..580603178ae113dd4f5289a7c89a5943379e85f3 100644 --- a/src/app/sys-check/questionnaire/questionnaire.component.html +++ b/src/app/sys-check/questionnaire/questionnaire.component.html @@ -2,8 +2,8 @@ <mat-spinner></mat-spinner> </div> <div class="step-body" #questionnaireBody> - <div [formGroup]="form"> - <p *ngFor="let f of formdef"> +<!-- <div [formGroup]="form"> + <div *ngFor="let f of formdef"> <label>{{f.prompt}}</label> <div [ngSwitch]="f.type"> @@ -18,6 +18,6 @@ </div> <div class="errorMessage" *ngIf="!isValid">{{f.prompt}} is required</div> - </p> - </div> + </div> + </div>--> </div> diff --git a/src/app/sys-check/syscheck-data.service.ts b/src/app/sys-check/syscheck-data.service.ts index 0fb20c305fb4b30d1840717a31386a57243964a4..ded71829660bb6dde8d2f6395843052c0a518914 100644 --- a/src/app/sys-check/syscheck-data.service.ts +++ b/src/app/sys-check/syscheck-data.service.ts @@ -56,38 +56,6 @@ export class SyscheckDataService { } } } - - public calculateEnvironmentRating(ed: EnvironmentData): EnvironmentRating { - let ratings: EnvironmentRating = { - OSRating: 'N/A', - ResolutionRating: 'N/A', - BrowserRating: 'N/A' - }; - - if(ed.osName === "Windows 7" || ed.osName === "Windows 10" || ed.osName === "Windows 8" || ed.osName === "Mac/iOS") { - ratings.OSRating = 'Good'; - } else if (ed.osName === "Windows Vista" || ed.osName === "Linux" || ed.osName === "UNIX") { - ratings.OSRating = 'Possibly compatible'; - } else { - ratings.OSRating = 'Not compatible'; - } - - if(ed.browserName.indexOf("Chrome") || ed.browserName.indexOf("Mozilla")) - if(parseInt(ed.browserVersion) >= 60) { - ratings.BrowserRating = 'Good' - } - else { - ratings.BrowserRating = 'Not compatible' - } - - if(ed.resolution.width >= 1024 && ed.resolution.height >= 768) { - ratings.ResolutionRating = 'Good' - } else { - ratings.ResolutionRating = 'Not compatible' - } - return ratings; - } - } export interface NetworkData {