Add a warning when max runs per day is reached

This commit is contained in:
Gaël Métais
2015-02-06 12:03:02 +01:00
parent d556f84929
commit 5f2553047d
8 changed files with 38 additions and 41 deletions
+1
View File
@@ -10,6 +10,7 @@ var yltApp = angular.module('YellowLabTools', [
'timelineCtrl',
'runsFactory',
'resultsFactory',
'apiService',
'menuService',
'gradeDirective',
'offendersDirectives'
+2 -8
View File
@@ -1,6 +1,6 @@
var dashboardCtrl = angular.module('dashboardCtrl', ['resultsFactory', 'menuService']);
dashboardCtrl.controller('DashboardCtrl', ['$scope', '$rootScope', '$routeParams', '$location', 'Results', 'Runs', 'Menu', function($scope, $rootScope, $routeParams, $location, Results, Runs, Menu) {
dashboardCtrl.controller('DashboardCtrl', ['$scope', '$rootScope', '$routeParams', '$location', 'Results', 'API', 'Menu', function($scope, $rootScope, $routeParams, $location, Results, API, Menu) {
$scope.runId = $routeParams.runId;
$scope.Menu = Menu.setCurrentPage('dashboard', $scope.runId);
$scope.fromSocialShare = $location.search().share;
@@ -34,13 +34,7 @@ dashboardCtrl.controller('DashboardCtrl', ['$scope', '$rootScope', '$routeParams
};
$scope.testAgain = function() {
Runs.save({
url: $scope.result.params.url,
waitForResponse: false,
screenshot: true
}, function(data) {
$location.path('/queue/' + data.runId);
});
API.launchTest($scope.result.params.url);
};
/// When comming from a social shared link, the user needs to click on "See full report" button to display the full dashboard.
+2 -9
View File
@@ -1,16 +1,9 @@
var indexCtrl = angular.module('indexCtrl', []);
indexCtrl.controller('IndexCtrl', ['$scope', '$location', 'Runs', function($scope, $location, Runs) {
indexCtrl.controller('IndexCtrl', ['$scope', '$location', 'API', function($scope, $location, API) {
$scope.launchTest = function() {
if ($scope.url) {
Runs.save({
url: $scope.url,
waitForResponse: false,
screenshot: true
}, function(data) {
$location.path('/queue/' + data.runId);
});
API.launchTest();
}
};
}]);
+2 -8
View File
@@ -1,6 +1,6 @@
var ruleCtrl = angular.module('ruleCtrl', []);
ruleCtrl.controller('RuleCtrl', ['$scope', '$rootScope', '$routeParams', '$location', '$sce', 'Menu', 'Results', 'Runs', function($scope, $rootScope, $routeParams, $location, $sce, Menu, Results, Runs) {
ruleCtrl.controller('RuleCtrl', ['$scope', '$rootScope', '$routeParams', '$location', '$sce', 'Menu', 'Results', 'API', function($scope, $rootScope, $routeParams, $location, $sce, Menu, Results, API) {
$scope.runId = $routeParams.runId;
$scope.policyName = $routeParams.policy;
$scope.Menu = Menu.setCurrentPage(null, $scope.runId);
@@ -29,13 +29,7 @@ ruleCtrl.controller('RuleCtrl', ['$scope', '$rootScope', '$routeParams', '$locat
};
$scope.testAgain = function() {
Runs.save({
url: $scope.result.params.url,
waitForResponse: false,
screenshot: true
}, function(data) {
$location.path('/queue/' + data.runId);
});
API.launchTest($scope.result.params.url);
};
loadResults();
+2 -8
View File
@@ -1,6 +1,6 @@
var screenshotCtrl = angular.module('screenshotCtrl', ['resultsFactory', 'menuService']);
screenshotCtrl.controller('ScreenshotCtrl', ['$scope', '$rootScope', '$routeParams', '$location', 'Results', 'Runs', 'Menu', function($scope, $rootScope, $routeParams, $location, Results, Runs, Menu) {
screenshotCtrl.controller('ScreenshotCtrl', ['$scope', '$rootScope', '$routeParams', '$location', 'Results', 'API', 'Menu', function($scope, $rootScope, $routeParams, $location, Results, API, Menu) {
$scope.runId = $routeParams.runId;
$scope.Menu = Menu.setCurrentPage(null, $scope.runId);
@@ -24,13 +24,7 @@ screenshotCtrl.controller('ScreenshotCtrl', ['$scope', '$rootScope', '$routePara
};
$scope.testAgain = function() {
Runs.save({
url: $scope.result.params.url,
waitForResponse: false,
screenshot: true
}, function(data) {
$location.path('/queue/' + data.runId);
});
API.launchTest($scope.result.params.url);
};
loadResults();
+2 -8
View File
@@ -1,6 +1,6 @@
var timelineCtrl = angular.module('timelineCtrl', []);
timelineCtrl.controller('TimelineCtrl', ['$scope', '$rootScope', '$routeParams', '$location', '$timeout', 'Menu', 'Results', 'Runs', function($scope, $rootScope, $routeParams, $location, $timeout, Menu, Results, Runs) {
timelineCtrl.controller('TimelineCtrl', ['$scope', '$rootScope', '$routeParams', '$location', '$timeout', 'Menu', 'Results', 'API', function($scope, $rootScope, $routeParams, $location, $timeout, Menu, Results, API) {
$scope.runId = $routeParams.runId;
$scope.Menu = Menu.setCurrentPage('timeline', $scope.runId);
@@ -132,13 +132,7 @@ timelineCtrl.controller('TimelineCtrl', ['$scope', '$rootScope', '$routeParams',
};
$scope.testAgain = function() {
Runs.save({
url: $scope.result.params.url,
waitForResponse: false,
screenshot: true
}, function(data) {
$location.path('/queue/' + data.runId);
});
API.launchTest($scope.result.params.url);
};
loadResults();
+26
View File
@@ -0,0 +1,26 @@
var apiService = angular.module('apiService', []);
apiService.factory('API', ['$location', 'Runs', 'Results', function($location, Runs, Results) {
return {
launchTest: function(url) {
Runs.save({
url: url,
waitForResponse: false,
screenshot: true
}, function(data) {
$location.path('/queue/' + data.runId);
}, function(response) {
if (response.status === 429) {
alert('Too many requests, you reached the max number of requests allowed in 24h');
} else {
alert('An error occured...');
}
});
}
};
}]);
+1
View File
@@ -33,6 +33,7 @@
<script src="/js/controllers/timelineCtrl.js"></script>
<script src="/js/models/resultsFactory.js"></script>
<script src="/js/models/runsFactory.js"></script>
<script src="/js/services/apiService.js"></script>
<script src="/js/services/menuService.js"></script>
<script src="/js/directives/gradeDirective.js"></script>
<script src="/js/directives/offendersDirectives.js"></script>