Skip to content

Commit

Permalink
Move to ndt7 (#25)
Browse files Browse the repository at this point in the history
* Update .gitignore to include app/libraries and npm-debug.log

* Replace ndt5 with ndt7

* Update firebase token.

* Commit ndt7 assets

* Update ndt7-js, remove vendored version, use gulp to copy libs

* Update yarn.lock, remove package-lock.json

* Update nodejs version and README

* Remove bower.

* Add missing \n and move gauge status update out of the $apply

* Rename timeProgress to gaugeProgress
  • Loading branch information
robertodauria authored Mar 2, 2021
1 parent ff9ab17 commit ba65014
Show file tree
Hide file tree
Showing 13 changed files with 161 additions and 5,795 deletions.
3 changes: 0 additions & 3 deletions .bowerrc

This file was deleted.

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ node_modules/
bower_components/
tmp
.DS_Store
.firebase
.firebase
app/libraries
npm-debug.log
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
language: node_js
node_js:
- node
- 10
script:
- npm install -g firebase-tools
- bower install
- npm install -g firebase-tools gulp
- gulp copy_libs
deploy:

# production
- provider: firebase
token:
secure: r1cRKzr4oBC7mUuXamslr9dCWCjyPj4Kyn84wg5jSQhPj3Qg43zGzd98IIxr3rM3chPtpRg4yX579HCXDh4cqUI98qdzrKZqctxiphmOpAIppgJxKWomUIY9/W0V0Ysn3ft9uJA1X5OcJDqH9C4bU+ZHSrohwzW6h8xDTf52HXinuybZD/GzwzEstj41fNWnwyVq1TT47zC/FutkFqY07ZvIp4ocp8OcBMBTGtxepNs6/ekL4W+8tR/LSTByRKEu2/MSuMMUIFtSV2tjZ0G7JkbaV9ig/vBG27gimcrqo/RS3aZ0ylRrKvYT5HlRNAsq1xYpKBk5nj0iji9xcfx3HBtVXM6S4mMB2RnO8I8httok+bfu3a08wAARPrqY+CW7C+2UvYcJM6adYT7/QhIxKTrGl5vzc9bCpRkGnXX45+xEtvXd2L3YctpG80r8FiGtewDmpu/U+Lc5YnGvzRaTQThcUNtmRBVnHKtgiVCOH8cz3hPBkvzmQBNzUhJCKzpcBtogfr+QHshJne3Q4qd74C0J4Gh4VkSTcQjVVpOHpCV/iJt4RnVTs58viyKeEfFChRJs6G3BQDo4cPBrESuBCQLWDZyoWuetkMQFC4LYK2IL1RxGpZ+Hw2J2L3j3RT04zu65b5P/gWr+YLymgsTr4FhQEj8Rd+boMnAxHo9u9D8=
secure: OuAmTXbpWXEPxOijY9KvSls1HhWsv/T1fy69rjHdzAcCmGr/0f56/a8YL5n52gjXKQgDtgwDNRMMbkHn6fkOwenCZtgnxSyqUR3Fn/o7FVxAGe7yG17W13mj6K3H0Uw4uqXWuxdJjLCW1Xyxfh4+FppVhGwRvvFVso/n+o6a79yGCsvnu5MHq9TCFFWoOzmi53Il/fPlB9wpkCBkNdW2Q4LHLWX/JVMQ6hNK4brBJbhoWwRObi1XsQGEG/IJTxUJffiwEgHB+dBOPEv0yPMQYfS+6onN3ZZX5AlhK7JcjbmN0fooIMAG5sxIsvSmonFnUzqhntbMDCCKBRx+6+qhOFGBMlzVMr29Btx9Pdf1Ih/8kyCR8e6Bzde/C4ek2uTGYQFQhJinX3vDqnkMimlGwksLz+31JqUPqc04Dhs+SQuD4EIhVW0PAot6fM/SgNJzPV6ZrL+LR5JPhNXcwsZjxP/r+XLuBcoDcarbJZ6CZf/ry8fhlrBpsUe1Ib7TdqPsBTNVt7RwCL14xaPwnrpu+jnDNVIsDkxyGKFPvxF02b6sbwGvj1Abx9se/qR3hdI9hNn6kInoWsxa/S8UFfcxXtLxWIW02TMSmmJmgdFrkAiN6X6QfiNDvYnA2//+w3xtZ13fInHqjxF3EVABHicvky9Ip9S+hCWPflPIHcOIL2E=
project: mlab-oti
edge: true
only: hosting:speedtest
Expand All @@ -20,7 +20,7 @@ deploy:
# sandbox
- provider: firebase
token:
secure: r1cRKzr4oBC7mUuXamslr9dCWCjyPj4Kyn84wg5jSQhPj3Qg43zGzd98IIxr3rM3chPtpRg4yX579HCXDh4cqUI98qdzrKZqctxiphm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Z6CZf/ry8fhlrBpsUe1Ib7TdqPsBTNVt7RwCL14xaPwnrpu+jnDNVIsDkxyGKFPvxF02b6sbwGvj1Abx9se/qR3hdI9hNn6kInoWsxa/S8UFfcxXtLxWIW02TMSmmJmgdFrkAiN6X6QfiNDvYnA2//+w3xtZ13fInHqjxF3EVABHicvky9Ip9S+hCWPflPIHcOIL2E=
project: mlab-sandbox
edge: true
only: hosting:speedtest
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

* Install website build dependencies for your operating system and environment
* Node >= v10.15.1 - Using NVM: `nvm install v10.15.1`
* Bower - `npm install -g bower`
* Gulp - Installed with `yarn`
* Firebase tools - `npm install -g firebase-tools`

## Adding new languages
Expand Down
18 changes: 1 addition & 17 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ angular.module('Measure', [
'ngRoute',
'gettext',
'Measure.Measure',
'Measure.MeasurementLab',
'Measure.GaugeService'
])

.value('ndtServer', {})

.config(['$locationProvider', '$routeProvider', function($locationProvider, $routeProvider) {
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/', {
templateUrl: '/measure/measure.html',
controller: 'MeasureCtrl'
Expand All @@ -30,18 +29,3 @@ angular.module('Measure', [
// gettextCatalog.debug = true;
}
})

.run(function (MLabService, ndtServer, $rootScope) {

MLabService.findServer().then(
function(foundServer) {
ndtServer.fqdn = foundServer.fqdn;
ndtServer.city = foundServer.city;
ndtServer.country = foundServer.country;
$rootScope.$emit('updatedServer');
},
function(failureNotification) {console.log(failureNotification)}
);


});
5 changes: 1 addition & 4 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,10 @@
<script src="assets/js/util.js"></script>
<script src="assets/js/main.js"></script>

<script type="text/javascript" src="assets/js/ndt-controller.js"></script>
<script type="text/javascript" src="assets/js/ndt-browser-client.js"></script>
<script type="text/javascript" src="assets/js/ndt-wrapper.js"></script>
<script type="text/javascript" src="libraries/ndt7.min.js"></script>

<script src="measure/measure.js"></script>
<script src="services/gaugeService.js"></script>
<script src="services/mlabService.js"></script>
<script src="app.js"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
Expand Down
135 changes: 73 additions & 62 deletions app/measure/measure.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,13 @@ angular.module('Measure.Measure', ['ngRoute'])

$scope.measurementComplete = false;

if (!Modernizr.websockets) {
$scope.unsupportedSystem = true;
return;
}


$rootScope.$on('updatedServer', function() {
$scope.location = ndtServer.city + ", " + ndtServer.country;
$scope.address = ndtServer.fqdn;
});

ProgressGauge.create();
$scope.currentPhase = '';
$scope.currentSpeed = '';

$scope.startTest = function () {
var timeStarted,
timeRunning,
timeProgress,
timeState,
intervalPromise,
TIME_EXPECTED = 10 * 1000;
var gaugeProgress,
TIME_EXPECTED = 10;

if ($scope.privacyConsent !== true) {
return;
Expand All @@ -40,12 +25,6 @@ angular.module('Measure.Measure', ['ngRoute'])
$scope.startButtonClass = 'disabled';
$scope.measurementComplete = false;

if ($scope.address === undefined) {
console.log('M-Lab server currently not selected, waiting for NS answer.');
$timeout($scope.startTest, 1000);
return;
}

if (ndtSemaphore == true) {
return;
}
Expand All @@ -59,49 +38,81 @@ angular.module('Measure.Measure', ['ngRoute'])

$scope.currentSpeed = gettextCatalog.getString('Starting');
$scope.currentPhase = '';
startTest(ndtServer.fqdn);

intervalPromise = $interval(function() {
var downloadSpeedVal = downloadSpeed();
var uploadSpeedVal = uploadSpeed(false);

if (timeState !== currentPhase && currentPhase != undefined) {
timeState = currentPhase;
timeStarted = new Date().getTime();
}
if (currentPhase === PHASE_UPLOAD || currentPhase === PHASE_DOWNLOAD) {
timeRunning = new Date().getTime() - timeStarted;

if (currentPhase === PHASE_UPLOAD) {
timeProgress = ( timeRunning > TIME_EXPECTED) ? 0.5 : timeRunning / (TIME_EXPECTED * 2);
} else {
timeProgress = ( timeRunning > TIME_EXPECTED) ? 1.0 : (timeRunning / (TIME_EXPECTED * 2) + 0.5);
}
ProgressGauge.progress(timeProgress, false);
}

if (currentPhase == PHASE_UPLOAD) {
$scope.currentPhase = gettextCatalog.getString('Upload');
$scope.currentSpeed = uploadSpeedVal ? uploadSpeedVal.toFixed(2) + ' Mb/s' : gettextCatalog.getString('Initializing');
} else if (currentPhase == PHASE_DOWNLOAD) {
$scope.currentPhase = gettextCatalog.getString('Download');
$scope.currentSpeed = downloadSpeedVal ? downloadSpeedVal.toFixed(2) + ' Mb/s' : gettextCatalog.getString('Initializing');
} else if (currentPhase == PHASE_RESULTS) {
$scope.measurementResult = {};

ndt7.test(
{
userAcceptedDataPolicy: true,
uploadworkerfile: "libraries/ndt7-upload-worker.min.js",
downloadworkerfile: "libraries/ndt7-download-worker.min.js"
},
{
serverChosen: function (server) {
$scope.location = server.location.city + ", " +
server.location.country;
$scope.address = server.machine;
console.log('Testing to:', {
machine: server.machine,
locations: server.location,
});
},
downloadStart: (data) => {
$scope.$apply(function() {
$scope.currentPhase = gettextCatalog.getString('Download');
$scope.currentSpeed = gettextCatalog.getString('Initializing');
});
},
downloadMeasurement: (data) => {
if (data.Source === 'client') {
$scope.$apply(function () {
$scope.currentSpeed = data.Data.MeanClientMbps.toFixed(2) + ' Mb/s';
});
gaugeProgress = (data.Data.ElapsedTime > TIME_EXPECTED) ? 0.5 :
data.Data.ElapsedTime / (TIME_EXPECTED * 2);
ProgressGauge.progress(gaugeProgress, false);
}
},
downloadComplete: (data) => {
$scope.measurementResult.s2cRate =
data.LastClientMeasurement.MeanClientMbps.toFixed(2) + ' Mb/s';
$scope.measurementResult.latency =
(data.LastServerMeasurement.TCPInfo.MinRTT / 1000).toFixed(0) + ' ms';
$scope.measurementResult.loss =
(data.LastServerMeasurement.TCPInfo.BytesRetrans /
data.LastServerMeasurement.TCPInfo.BytesSent * 100).toFixed(2) + '%';
console.log(data);
},
uploadStart: (data) => {
$scope.$apply(function() {
$scope.currentPhase = gettextCatalog.getString('Upload');
$scope.currentSpeed = gettextCatalog.getString('Initializing');
})
},
uploadMeasurement: function(data) {
if (data.Source === 'client') {
$scope.$apply(function () {
$scope.currentSpeed = data.Data.MeanClientMbps.toFixed(2) + ' Mb/s';
});
gaugeProgress = (data.Data.ElapsedTime > TIME_EXPECTED) ? 1.0 :
data.Data.ElapsedTime / (TIME_EXPECTED * 2) + 0.5;
ProgressGauge.progress(gaugeProgress, false);
}
},
uploadComplete: function (data) {
$scope.measurementResult.c2sRate =
data.LastClientMeasurement.MeanClientMbps.toFixed(2) + ' Mb/s';
console.log(data);
},
},
).then(() => {
$scope.$apply(function() {
$scope.currentPhase = gettextCatalog.getString('Complete');
$scope.currentSpeed = '';
$scope.measurementComplete = true;
$scope.measurementResult = {
's2cRate': downloadSpeed().toFixed(2) + ' Mb/s',
'c2sRate': uploadSpeed().toFixed(2) + ' Mb/s',
'latency': readNDTvar('MinRTT') + ' ms',
'loss': String((readNDTvar('TCPInfo.BytesRetrans') / readNDTvar("TCPInfo.BytesSent") * 100).toFixed(2)) + "%"
};
ndtSemaphore = false;
$scope.startButtonClass = '';

$interval.cancel(intervalPromise);
}

}, 100);
});
ndtSemaphore = false;
})
}
});
78 changes: 0 additions & 78 deletions app/services/mlabService.js

This file was deleted.

18 changes: 0 additions & 18 deletions bower.json

This file was deleted.

11 changes: 10 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ gulp.task('pot', function () {

// Copy dependencies to ./public/libs/
gulp.task('copy_libs', function() {
gulp.src(npmDist(), {base:'./node_modules/@bower_components'})
// Copy all the libraries under @bower_components to libraries/.
gulp.src([
"./node_modules/@bower_components/**/*.**",
], {base: "./node_modules/@bower_components"})
.pipe(gulp.dest('./app/libraries'));

// Copy the minified @m-lab/ndt7 js files to libraries/.
gulp.src([
"./node_modules/@m-lab/ndt7/src/*.min.js",
])
.pipe(gulp.dest('./app/libraries'));
});
Loading

0 comments on commit ba65014

Please sign in to comment.