screenshotCtrl.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. var screenshotCtrl = angular.module('screenshotCtrl', ['resultsFactory', 'menuService']);
  2. screenshotCtrl.controller('ScreenshotCtrl', ['$scope', '$rootScope', '$routeParams', '$location', 'Results', 'Runs', 'Menu', function($scope, $rootScope, $routeParams, $location, Results, Runs, Menu) {
  3. $scope.runId = $routeParams.runId;
  4. $scope.Menu = Menu.setCurrentPage(null, $scope.runId);
  5. function loadResults() {
  6. // Load result if needed
  7. if (!$rootScope.loadedResult || $rootScope.loadedResult.runId !== $routeParams.runId) {
  8. Results.get({runId: $routeParams.runId}, function(result) {
  9. $rootScope.loadedResult = result;
  10. $scope.result = result;
  11. init();
  12. }, function(err) {
  13. $scope.error = true;
  14. });
  15. } else {
  16. $scope.result = $rootScope.loadedResult;
  17. }
  18. }
  19. $scope.backToDashboard = function() {
  20. $location.path('/result/' + $scope.runId);
  21. };
  22. $scope.testAgain = function() {
  23. Runs.save({
  24. url: $scope.result.params.url,
  25. waitForResponse: false,
  26. screenshot: true
  27. }, function(data) {
  28. $location.path('/queue/' + data.runId);
  29. });
  30. };
  31. loadResults();
  32. }]);