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 f32db21d506a65b44ae6d0b54032d84f6067efb8..fefd1a496fb77a3e730196849fb792d024dd2ebe 100644 --- a/src/app/sys-check/network-check/network-check.component.ts +++ b/src/app/sys-check/network-check/network-check.component.ts @@ -58,10 +58,8 @@ export class NetworkCheckComponent implements OnInit, OnDestroy { networkType: connection.type || null, }; } - if (this.ds.networkReport.length === 0) { + if (this.ds.checkConfig && this.ds.networkReport.length === 0) { this.startCheck(); - } else { - } }) } @@ -86,29 +84,31 @@ export class NetworkCheckComponent implements OnInit, OnDestroy { } private plotPrepare(isDownloadPart: boolean) { - const testSizes = (isDownloadPart) ? this.ds.checkConfig.downloadSpeed.sequenceSizes : this.ds.checkConfig.uploadSpeed.sequenceSizes; - const plotterSettings = { - css: 'border: 1px solid silver; margin: 2px; width: 100%;', - width: 800, - height: 240, - labelPadding: 4, - xAxisMaxValue: 16 + Math.max(...testSizes), - xAxisMinValue: Math.min(...testSizes), - yAxisMaxValue: (isDownloadPart) ? 1200 : 2500, - yAxisMinValue: (isDownloadPart) ? 20 : 100, - xAxisStepSize: 4, - yAxisStepSize: (isDownloadPart) ? 50 : 100, - lineWidth: 5, - xProject: x => (x === 0 ) ? 0 : Math.sign(x) * Math.log2(Math.abs(x)), - yProject: y => (y === 0 ) ? 0 : Math.sign(y) * Math.log(Math.abs(y)), - xAxisLabels: (x) => (testSizes.indexOf(x) > -1) ? this.humanReadableBytes(x, false, true) : '', - yAxisLabels: (y, i) => (i < 10) ? this.humanReadableMilliseconds(y) : ' ', - }; + if (this.ds.checkConfig) { + const testSizes = (isDownloadPart) ? this.ds.checkConfig.downloadSpeed.sequenceSizes : this.ds.checkConfig.uploadSpeed.sequenceSizes; + const plotterSettings = { + css: 'border: 1px solid silver; margin: 2px; width: 100%;', + width: 800, + height: 240, + labelPadding: 4, + xAxisMaxValue: 16 + Math.max(...testSizes), + xAxisMinValue: Math.min(...testSizes), + yAxisMaxValue: (isDownloadPart) ? 1200 : 2500, + yAxisMinValue: (isDownloadPart) ? 20 : 100, + xAxisStepSize: 4, + yAxisStepSize: (isDownloadPart) ? 50 : 100, + lineWidth: 5, + xProject: x => (x === 0 ) ? 0 : Math.sign(x) * Math.log2(Math.abs(x)), + yProject: y => (y === 0 ) ? 0 : Math.sign(y) * Math.log(Math.abs(y)), + xAxisLabels: (x) => (testSizes.indexOf(x) > -1) ? this.humanReadableBytes(x, false, true) : '', + yAxisLabels: (y, i) => (i < 10) ? this.humanReadableMilliseconds(y) : ' ', + }; - if (isDownloadPart) { - this.downloadPlotter.reset(plotterSettings); - } else { - this.uploadPlotter.reset(plotterSettings); + if (isDownloadPart) { + this.downloadPlotter.reset(plotterSettings); + } else { + this.uploadPlotter.reset(plotterSettings); + } } } diff --git a/src/app/sys-check/network-check/tc-speed-chart.component.ts b/src/app/sys-check/network-check/tc-speed-chart.component.ts index 1fdaeb3e75cd0b92e857178f588c0602a707599f..625d7fcd3c911ac07d1de979d99dfaff47bfb1cf 100644 --- a/src/app/sys-check/network-check/tc-speed-chart.component.ts +++ b/src/app/sys-check/network-check/tc-speed-chart.component.ts @@ -87,34 +87,27 @@ export class TcSpeedChartComponent { } public plotData(dataPoints: Array<[number, number]>, color: string = null, style: 'line' | 'dots' = 'line') { - if (!dataPoints.length) { return; } - color = color || this.randomColor(); - const coordinates = this.dataPointsToCoordinates(dataPoints); - color = color || this.randomColor(); const oldStrokeColor = this.context.strokeStyle; const oldFillColor = this.context.fillStyle; this.context.strokeStyle = color; this.context.fillStyle = color; - if (style === 'line') { this.paintLine(coordinates); } if (style === 'dots') { this.paintDots(coordinates); } - this.context.strokeStyle = oldStrokeColor; this.context.fillStyle = oldFillColor; } private dataPointsToCoordinates(dataPoints: Array<[number, number]>): Array<[number, number]> { - return dataPoints .map((xy): [number, number] => [ // apply projection this.config.xProject(xy[0]), diff --git a/src/app/sys-check/report/report.component.ts b/src/app/sys-check/report/report.component.ts index b970c66de00bf9ff8e1551a8d027ff2d8d19f6c8..1a881b0d071a56f97d80ee1086bc2c599a6afb8f 100644 --- a/src/app/sys-check/report/report.component.ts +++ b/src/app/sys-check/report/report.component.ts @@ -74,7 +74,7 @@ export class ReportComponent implements OnInit { setTimeout(() => { this.ds.setNewCurrentStep('r'); this.questionnaireDataWarnings = []; - if (this.ds.checkConfig.questions.length > 0) { + if (this.ds.checkConfig && this.ds.checkConfig.questions.length > 0) { if (this.ds.questionnaireReport.length > 0) { this.ds.questionnaireReport.forEach(re => { if (re.warning) { diff --git a/src/app/sys-check/unit-check/unit-check.component.ts b/src/app/sys-check/unit-check/unit-check.component.ts index ee96e8c1d286ae883dec482b4cd9fb2192291b2e..2775e2bacfe16eac563c423c5e1cc955625cd841 100644 --- a/src/app/sys-check/unit-check/unit-check.component.ts +++ b/src/app/sys-check/unit-check/unit-check.component.ts @@ -41,57 +41,58 @@ export class UnitCheckComponent implements OnInit, OnDestroy { ngOnInit() { setTimeout(() => { this.ds.setNewCurrentStep('u'); - this.iFrameHostElement = <HTMLElement>document.querySelector('#iFrameHost'); - this.postMessageSubscription = this.mds.postMessage$.subscribe((m: MessageEvent) => { - const msgData = m.data; - const msgType = msgData['type']; - - if ((msgType !== undefined) && (msgType !== null)) { - switch (msgType) { - - case 'vopReadyNotification': - this.iFrameItemplayer.setAttribute('height', String(Math.trunc(this.iFrameHostElement.clientHeight))); - this.postMessageTarget = m.source as Window; - if (typeof this.postMessageTarget !== 'undefined') { - this.itemplayerSessionId = Math.floor(Math.random() * 20000000 + 10000000).toString(); - this.postMessageTarget.postMessage({ - type: 'vopStartCommand', - sessionId: this.itemplayerSessionId, - unitDefinition: this.pendingUnitDef, - playerConfig: { - logPolicy: 'disabled', - stateReportPolicy: 'none' - } - }, '*'); - } - break; - - case 'vopStateChangedNotification': - if (msgData['playerState']) { - const playerState = msgData['playerState']; - this.setPageList(Object.keys(playerState.validPages), playerState.currentPage); - } - break; - - default: - console.log('processMessagePost ignored message: ' + msgType); - break; + if (this.ds.unitAndPlayerContainer) { + this.iFrameHostElement = <HTMLElement>document.querySelector('#iFrameHost'); + this.postMessageSubscription = this.mds.postMessage$.subscribe((m: MessageEvent) => { + const msgData = m.data; + const msgType = msgData['type']; + + if ((msgType !== undefined) && (msgType !== null)) { + switch (msgType) { + + case 'vopReadyNotification': + this.iFrameItemplayer.setAttribute('height', String(Math.trunc(this.iFrameHostElement.clientHeight))); + this.postMessageTarget = m.source as Window; + if (typeof this.postMessageTarget !== 'undefined') { + this.itemplayerSessionId = Math.floor(Math.random() * 20000000 + 10000000).toString(); + this.postMessageTarget.postMessage({ + type: 'vopStartCommand', + sessionId: this.itemplayerSessionId, + unitDefinition: this.pendingUnitDef, + playerConfig: { + logPolicy: 'disabled', + stateReportPolicy: 'none' + } + }, '*'); + } + break; + + case 'vopStateChangedNotification': + if (msgData['playerState']) { + const playerState = msgData['playerState']; + this.setPageList(Object.keys(playerState.validPages), playerState.currentPage); + } + break; + + default: + console.log('processMessagePost ignored message: ' + msgType); + break; + } } - } - }); + }); - while (this.iFrameHostElement.hasChildNodes()) { - this.iFrameHostElement.removeChild(this.iFrameHostElement.lastChild); + while (this.iFrameHostElement.hasChildNodes()) { + this.iFrameHostElement.removeChild(this.iFrameHostElement.lastChild); + } + this.pendingUnitDef = this.ds.unitAndPlayerContainer.def; + this.iFrameItemplayer = <HTMLIFrameElement>document.createElement('iframe'); + this.iFrameItemplayer.setAttribute('sandbox', 'allow-forms allow-scripts allow-same-origin'); + this.iFrameItemplayer.setAttribute('class', 'unitHost'); + this.iFrameItemplayer.setAttribute('height', String(this.iFrameHostElement.clientHeight - 5)); + this.iFrameHostElement.appendChild(this.iFrameItemplayer); + srcDoc.set(this.iFrameItemplayer, this.ds.unitAndPlayerContainer.player); } - this.pendingUnitDef = this.ds.unitAndPlayerContainer.def; - this.iFrameItemplayer = <HTMLIFrameElement>document.createElement('iframe'); - this.iFrameItemplayer.setAttribute('sandbox', 'allow-forms allow-scripts allow-same-origin'); - this.iFrameItemplayer.setAttribute('class', 'unitHost'); - this.iFrameItemplayer.setAttribute('height', String(this.iFrameHostElement.clientHeight - 5)); - this.iFrameHostElement.appendChild(this.iFrameItemplayer); - srcDoc.set(this.iFrameItemplayer, this.ds.unitAndPlayerContainer.player); }) - } setPageList(validPages: string[], currentPage: string) {