Skip to content
Snippets Groups Projects
Commit dbe9f7e3 authored by paflov's avatar paflov
Browse files

repairs the network-check which was destroyed by a linting action and does some new linting

parent f64f6048
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,7 @@ export class BackendService {
private http: HttpClient
) {}
public getCheckConfigData(workspaceId: number, sysCheckName: string): Observable<CheckConfig> {
getCheckConfigData(workspaceId: number, sysCheckName: string): Observable<CheckConfig> {
return this.http
.get<CheckConfig>(`${this.serverUrl}workspace/${workspaceId}/sys-check/${sysCheckName}`)
.pipe(
......@@ -32,7 +32,7 @@ export class BackendService {
saveReport(workspaceId: number, sysCheckName: string, sysCheckReport: SysCheckReport): Observable<boolean> {
return this.http
.put(`${this.serverUrl}workspace/${workspaceId}/sys-check/${sysCheckName}/report`, {...sysCheckReport})
.put(`${this.serverUrl}workspace/${workspaceId}/sys-check/${sysCheckName}/report`, { ...sysCheckReport })
.pipe(
map(() => true),
catchError((err: ApiError) => {
......@@ -42,7 +42,7 @@ export class BackendService {
);
}
public getUnitAndPlayer(workspaceId: number, sysCheckId: string): Observable<UnitAndPlayerContainer|boolean> {
getUnitAndPlayer(workspaceId: number, sysCheckId: string): Observable<UnitAndPlayerContainer|boolean> {
const startingTime = BackendService.getMostPreciseTimestampBrowserCanProvide();
return this.http
.get<UnitAndPlayerContainer>(`${this.serverUrl}workspace/${workspaceId}/sys-check/${sysCheckId}/unit-and-player`)
......@@ -58,7 +58,7 @@ export class BackendService {
);
}
public benchmarkDownloadRequest(requestedDownloadSize: number): Promise<NetworkRequestTestResult> {
benchmarkDownloadRequest(requestedDownloadSize: number): Promise<NetworkRequestTestResult> {
const { serverUrl } = this;
const cacheKiller = `&uid=${new Date().getTime()}`;
const testResult: NetworkRequestTestResult = {
......@@ -80,7 +80,8 @@ export class BackendService {
if (xhr.status !== 200) {
testResult.error = `Error ${xhr.statusText} (${xhr.status}) `;
}
if (xhr.response.toString().length !== requestedDownloadSize) {
// eslint-disable-next-line eqeqeq
if (xhr.response.toString().length != requestedDownloadSize) {
testResult.error = 'Error: Data package has wrong size!' +
`(${requestedDownloadSize} !== ${xhr.response.toString().length})`;
}
......@@ -106,7 +107,7 @@ export class BackendService {
});
}
public benchmarkUploadRequest(requestedUploadSize: number): Promise<NetworkRequestTestResult> {
benchmarkUploadRequest(requestedUploadSize: number): Promise<NetworkRequestTestResult> {
const { serverUrl } = this;
const randomContent = BackendService.generateRandomContent(requestedUploadSize);
const testResult: NetworkRequestTestResult = {
......@@ -136,7 +137,8 @@ export class BackendService {
const response = JSON.parse(xhr.response);
const arrivingSize = parseFloat(response.packageReceivedSize);
if (arrivingSize !== requestedUploadSize) {
// eslint-disable-next-line eqeqeq
if (arrivingSize != requestedUploadSize) {
testResult.error = `Error: Data package has wrong size! ${requestedUploadSize} != ${arrivingSize}`;
}
} catch (e) {
......@@ -164,7 +166,9 @@ export class BackendService {
private static getMostPreciseTimestampBrowserCanProvide(): number {
if (typeof performance !== 'undefined') {
const timeOrigin = (typeof performance.timeOrigin !== 'undefined') ? performance.timeOrigin : performance.timing.navigationStart;
const timeOrigin = (typeof performance.timeOrigin !== 'undefined') ?
performance.timeOrigin :
performance.timing.navigationStart;
if (typeof timeOrigin !== 'undefined' && timeOrigin) {
return timeOrigin + performance.now();
}
......
......@@ -14,26 +14,25 @@ import {
})
export class NetworkCheckComponent implements OnInit, OnDestroy {
constructor(
public ds: SysCheckDataService,
private bs: BackendService
) {}
@ViewChild('downloadChart', {static: true}) downloadPlotter;
@ViewChild('uploadChart', {static: true}) uploadPlotter;
@ViewChild('downloadChart', { static: true }) downloadPlotter;
@ViewChild('uploadChart', { static: true }) uploadPlotter;
@Input() measureNetwork: boolean;
private networkStatsDownload: number[] = [];
private networkStatsUpload: number[] = [];
public networkRating: NetworkRating = {
networkRating: NetworkRating = {
downloadRating: 'N/A',
uploadRating: 'N/A',
overallRating: 'N/A'
};
public detectedNetworkInformation: DetectedNetworkInformation = {
detectedNetworkInformation: DetectedNetworkInformation = {
downlinkMegabitPerSecond: null,
effectiveNetworkType: null,
roundTripTimeMs: null,
......@@ -41,7 +40,7 @@ export class NetworkCheckComponent implements OnInit, OnDestroy {
available: false
};
private humanReadableMilliseconds = (milliseconds: number): string => (milliseconds / 1000).toString() + ' sec';
private humanReadableMilliseconds = (milliseconds: number): string => `${(milliseconds / 1000).toString()} sec`;
private static calculateAverageSpeedBytePerSecond(testResults: Array<NetworkRequestTestResult>): number {
return testResults.reduce((sum, result) => sum + (result.size / (result.duration / 1000)), 0) / testResults.length;
......@@ -58,7 +57,7 @@ export class NetworkCheckComponent implements OnInit, OnDestroy {
downlinkMegabitPerSecond: connection.downlink || null,
effectiveNetworkType: connection.effectiveType || null,
roundTripTimeMs: connection.rtt || null,
networkType: connection.type || null,
networkType: connection.type || null
};
}
if (this.ds.checkConfig && this.ds.networkReport.length === 0) {
......@@ -67,7 +66,7 @@ export class NetworkCheckComponent implements OnInit, OnDestroy {
});
}
public startCheck(): void {
startCheck(): void {
this.ds.networkReport = [];
this.ds.networkCheckStatus = {
done: false,
......@@ -206,7 +205,6 @@ export class NetworkCheckComponent implements OnInit, OnDestroy {
}
private plotStatistics(isDownloadPart: boolean, benchmarkSequenceResults: Array<NetworkRequestTestResult>) {
const datapoints = benchmarkSequenceResults
.filter(measurement => (measurement.error === null))
.map(measurement => ([measurement.size, measurement.duration]));
......@@ -230,7 +228,7 @@ export class NetworkCheckComponent implements OnInit, OnDestroy {
overallRating: 'unstable'
};
}
this.ds.networkCheckStatus.message = `Die folgenden Netzwerkeigenschaften wurden festgestellt:`;
this.ds.networkCheckStatus.message = 'Die folgenden Netzwerkeigenschaften wurden festgestellt:';
this.ds.networkCheckStatus.done = true;
const downAvg = this.getAverageNetworkStat(true);
......@@ -334,7 +332,7 @@ export class NetworkCheckComponent implements OnInit, OnDestroy {
}
}
public updateNetworkRating(): void {
updateNetworkRating(): void {
const networkRating: NetworkRating = {
downloadRating: 'N/A',
uploadRating: 'N/A',
......
......@@ -33,7 +33,7 @@ export class SysCheckComponent implements OnInit {
if (checkConfig) {
this.checkLabel = checkConfig.label;
if (checkConfig.customTexts.length > 0) {
const myCustomTexts: {[key: string]: string} = {};
const myCustomTexts: { [key: string]: string } = {};
checkConfig.customTexts.forEach(ct => {
myCustomTexts[ct.key] = ct.value;
});
......@@ -43,7 +43,7 @@ export class SysCheckComponent implements OnInit {
this.bs.getUnitAndPlayer(this.ds.checkConfig.workspaceId, this.ds.checkConfig.name)
.subscribe((unitAndPlayer: UnitAndPlayerContainer | boolean) => {
if (unitAndPlayer !== false && (unitAndPlayer as UnitAndPlayerContainer).player.length > 0) {
this.ds.unitAndPlayerContainer = unitAndPlayer as UnitAndPlayerContainer
this.ds.unitAndPlayerContainer = unitAndPlayer as UnitAndPlayerContainer;
} else {
console.error('Konnte Unit-Player nicht laden');
this.ds.checkConfig.hasUnit = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment