Add a screenshot page

This commit is contained in:
Gaël Métais
2015-02-05 19:31:19 +01:00
parent 52e73ca7cd
commit 85d1119ad6
13 changed files with 162 additions and 85 deletions
+5
View File
@@ -6,6 +6,7 @@ var yltApp = angular.module('YellowLabTools', [
'dashboardCtrl',
'queueCtrl',
'ruleCtrl',
'screenshotCtrl',
'timelineCtrl',
'runsFactory',
'resultsFactory',
@@ -46,6 +47,10 @@ yltApp.config(['$routeProvider', '$locationProvider',
templateUrl: 'views/timeline.html',
controller: 'TimelineCtrl'
}).
when('/result/:runId/screenshot', {
templateUrl: 'views/screenshot.html',
controller: 'ScreenshotCtrl'
}).
when('/result/:runId/rule/:policy', {
templateUrl: 'views/rule.html',
controller: 'RuleCtrl'
@@ -0,0 +1,38 @@
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) {
$scope.runId = $routeParams.runId;
$scope.Menu = Menu.setCurrentPage(null, $scope.runId);
function loadResults() {
// Load result if needed
if (!$rootScope.loadedResult || $rootScope.loadedResult.runId !== $routeParams.runId) {
Results.get({runId: $routeParams.runId}, function(result) {
$rootScope.loadedResult = result;
$scope.result = result;
init();
}, function(err) {
$scope.error = true;
});
} else {
$scope.result = $rootScope.loadedResult;
init();
}
}
function init() {
}
$scope.testAgain = function() {
Runs.save({
url: $scope.result.params.url,
waitForResponse: false,
screenshot: true
}, function(data) {
$location.path('/queue/' + data.runId);
});
};
loadResults();
}]);