Skip to content

Commit

Permalink
GpNetworkTools: fix results displaying (#667)
Browse files Browse the repository at this point in the history
  • Loading branch information
xbpcb authored Aug 15, 2024
1 parent 2905cb4 commit 7d0460f
Showing 1 changed file with 58 additions and 2 deletions.
60 changes: 58 additions & 2 deletions src/views/pages/globalping/network-tools.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,10 @@ <h1>{{displayingTestType}} from multiple locations in </h1>
{{elseif testResults}}
<c-gp-results-raw-output
testReqParams="{{testReqParams}}"
testResults="{{testResults}}"
testInProgress="{{testInProgress}}"
measurementsMetadata="{{measurementsMetadata}}">
measurementsMetadata="{{measurementsMetadata}}"
preparedTestResults="{{preparedTestResults}}"
activeTargetIdx="0">
</c-gp-results-raw-output>
{{else}}
<div class="gp-nettools_demo-tools_descr">
Expand Down Expand Up @@ -221,6 +222,8 @@ <h1>{{displayingTestType}} from multiple locations in </h1>
target: 'cdn.jsdelivr.net',
};
const CAPITALIZE_EXCLUDE_LIST = [ 'and', 'or', 'from', 'ltd', 'of' ];
const PROBE_NO_TIMING_VALUE = _.getProbeTimeOutValue();
const PROBE_STATUS_OFFLINE = _.getProbeStatusOfflineValue();

component.exports = {
data () {
Expand Down Expand Up @@ -395,6 +398,13 @@ <h1>{{displayingTestType}} from multiple locations in </h1>

this.set('measurementsMetadata', measurementsMetadata);
});

// prepare results for gp-results-raw-output
this.observe('testResults', (testResults) => {
if (!testResults) { return; }

this.set('preparedTestResults', this.prepareRegularResults(testResults));
});
}
},
oncomplete () {
Expand Down Expand Up @@ -834,5 +844,51 @@ <h1>{{displayingTestType}} from multiple locations in </h1>

return description;
},
prepareRegularResults (testResults) {
let dnsTraceEnabled = this.get('testReqParams.measurementOptions.trace');
let selectedTestType = this.get('selectedTestType');

return testResults.map((res) => {
let preparedRes = {
...res.probe,
statsPerTarget: [{
target: res.target,
}],
};

if (res.result.status !== 'in-progress') {
let { isFailed = false, lastTiming, value: avgTiming, extraValues } = _.calcGpTestResTiming(selectedTestType, res, dnsTraceEnabled);
let { packetsTotal } = _.parseGpRawOutputForTimings(res.result.rawOutput);
let minTiming = res.result?.stats?.min || PROBE_NO_TIMING_VALUE;
let maxTiming = res.result?.stats?.max || PROBE_NO_TIMING_VALUE;
let isOffline = res.result.status === PROBE_STATUS_OFFLINE;

preparedRes.statsPerTarget = [{
...preparedRes.statsPerTarget[0],
avgTiming,
isFailed,
isOffline,
extraValues,
rawOutput: res.result.rawOutput,
areTimingsReady: this.checkAreTimingsReady(lastTiming, maxTiming, minTiming, avgTiming, packetsTotal),
}];
}

return preparedRes;
});
},
checkAreTimingsReady (lastTiming, maxTiming, minTiming, avgTiming, packetsTotal) {
if (
!packetsTotal
|| typeof lastTiming === 'undefined'
|| typeof maxTiming === 'undefined'
|| typeof minTiming === 'undefined'
|| typeof avgTiming === 'undefined'
) {
return false;
}

return true;
},
};
</script>

0 comments on commit 7d0460f

Please sign in to comment.