Browse Source

Accept a URL parameter on the home page

Gaël Métais 8 years ago
parent
commit
f498bdabb3
1 changed files with 11 additions and 1 deletions
  1. 11 1
      front/src/js/controllers/indexCtrl.js

+ 11 - 1
front/src/js/controllers/indexCtrl.js

@@ -1,13 +1,23 @@
 var indexCtrl = angular.module('indexCtrl', []);
 
-indexCtrl.controller('IndexCtrl', ['$scope', 'Settings', 'API', function($scope, Settings, API) {
+indexCtrl.controller('IndexCtrl', ['$scope', '$routeParams', '$location', 'Settings', 'API', function($scope, $routeParams, $location, Settings, API) {
     
     $scope.settings = Settings.getMergedSettings();
 
     $scope.launchTest = function() {
         if ($scope.url) {
+            $location.search('url', null);
+            $location.search('run', null);
             Settings.saveSettings($scope.settings);
             API.launchTest($scope.url, $scope.settings);
         }
     };
+
+    // Auto fill URL field and auto launch test when the good params are set in the URL
+    if ($routeParams.url) {
+        $scope.url = $routeParams.url;
+        if ($routeParams.run === 'true' || $routeParams.run === 1 || $routeParams.run === '1') {
+            $scope.launchTest();
+        }
+    }
 }]);