diff --git a/.gitignore b/.gitignore index ee5c9d8336b76b3bb5658d0888bdec86eb7b0990..1f84d74fa6c7792dccc281707ac555755aaac259 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,7 @@ testem.log # System Files .DS_Store Thumbs.db + + +src/environments/environment.ts +.gitignore diff --git a/src/app/sys-check/network-check/network-check.component.html b/src/app/sys-check/network-check/network-check.component.html index f68601b509559ce48fecbff98fc3641c99907ce4..d57508de8a5235622bb4da8b58d640a212fe74fd 100644 --- a/src/app/sys-check/network-check/network-check.component.html +++ b/src/app/sys-check/network-check/network-check.component.html @@ -34,4 +34,14 @@ </mat-card-content> </mat-card> + <mat-card> + <mat-card-title>Netzwerkeigenschaften</mat-card-title> + <mat-card-content> + <p *ngIf="!detectedNetworkInformations.available">Ihr Browser ist veraltet, daher konnten keine weiteren Netzwerkeigenschaften ermittelt werden.</p> + <p *ngIf="detectedNetworkInformations.available">Verbindung: {{detectedNetworkInformations.effectiveNetworkType}} {{detectedNetworkInformations.networkType}}</p> + <p *ngIf="detectedNetworkInformations.roundTripTimeMs">Network RoundTrip: {{detectedNetworkInformations.roundTripTimeMs}} Millisekunden</p> + <p *ngIf="detectedNetworkInformations.downlinkMegabitPerSecond">Network Downlink: {{detectedNetworkInformations.downlinkMegabitPerSecond}} mbps</p> + </mat-card-content> + </mat-card> + </div> 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 7c3ea8f6d34b35e927e613807f7c602d2fbc7f69..d482fdae60c561946f38fb2848eb283a7501ba51 100644 --- a/src/app/sys-check/network-check/network-check.component.ts +++ b/src/app/sys-check/network-check/network-check.component.ts @@ -32,6 +32,14 @@ interface NetworkRating { overallRating: TechCheckRating; } +interface DetectedNetworkInformations { + available: boolean; + downlinkMegabitPerSecond: number; + effectiveNetworkType: string; + roundTripTimeMs: number; + networkType: string; +} + @Component({ selector: 'iqb-network-check', templateUrl: './network-check.component.html', @@ -75,11 +83,18 @@ export class NetworkCheckComponent implements OnInit { overallRating: 'N/A' }; + private detectedNetworkInformations: DetectedNetworkInformations = { + downlinkMegabitPerSecond: null, + effectiveNetworkType: null, + roundTripTimeMs: null, + networkType: null, + available: false + }; + constructor( private ds: SyscheckDataService, private bs: BackendService - ) { - } + ) {} ngOnInit() {} @@ -101,6 +116,8 @@ export class NetworkCheckComponent implements OnInit { this.plotPrepare(BenchmarkType.down); this.plotPrepare(BenchmarkType.up); + this.getBrowsersNativeNetworkInformations(); + this.loopBenchmarkSequence(BenchmarkType.down) .then(() => this.loopBenchmarkSequence(BenchmarkType.up)) .then(() => this.reportResults()) @@ -270,6 +287,32 @@ export class NetworkCheckComponent implements OnInit { reportEntry.push({id: '0', type: 'network', label: 'Uploadbewertung', value: this.networkRating.uploadRating}); reportEntry.push({id: '0', type: 'network', label: 'Allgemeine Bewertung der Verbindung', value: this.networkRating.overallRating}); + if (this.detectedNetworkInformations.available) { + if (this.detectedNetworkInformations.roundTripTimeMs) { + reportEntry.push({ + id: '0', type: 'network', label: 'RoundTrip in Ms', + value: this.detectedNetworkInformations.roundTripTimeMs.toString() + }); + } + if (this.detectedNetworkInformations.effectiveNetworkType) { + reportEntry.push({ + id: '0', type: 'network', label: 'Netzwerktyp nach Leistung', + value: this.detectedNetworkInformations.effectiveNetworkType + }); + } + if (this.detectedNetworkInformations.networkType) { + reportEntry.push({ + id: '0', type: 'network', label: 'Netzwerktyp', + value: this.detectedNetworkInformations.networkType + }); + } + if (this.detectedNetworkInformations.downlinkMegabitPerSecond) { + reportEntry.push({ + id: '0', type: 'network', label: 'Downlink mbps', + value: this.detectedNetworkInformations.downlinkMegabitPerSecond.toString() + }); + } + } this.ds.networkData$.next(reportEntry); } @@ -330,6 +373,22 @@ export class NetworkCheckComponent implements OnInit { } + private getBrowsersNativeNetworkInformations() { + + const connection = navigator['connection'] || navigator['mozConnection'] || navigator['webkitConnection']; + console.log('connection', connection); + if (connection) { + this.detectedNetworkInformations = { + available: true, + downlinkMegabitPerSecond: connection.downlink || null, + effectiveNetworkType: connection.effectiveType || null, + roundTripTimeMs: connection.rtt || null, + networkType: connection.type || null, + }; + } + } + + private humanReadableBytes(bytes: number): string { const units = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];