screenshotCtrl.js 1.1 KB

123456789101112131415161718192021222324252627282930
  1. var screenshotCtrl = angular.module('screenshotCtrl', ['resultsFactory', 'menuService']);
  2. screenshotCtrl.controller('ScreenshotCtrl', ['$scope', '$rootScope', '$routeParams', '$location', 'Results', 'API', 'Menu', function($scope, $rootScope, $routeParams, $location, Results, API, 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. }, function(err) {
  12. $scope.error = true;
  13. });
  14. } else {
  15. $scope.result = $rootScope.loadedResult;
  16. }
  17. }
  18. $scope.backToDashboard = function() {
  19. $location.path('/result/' + $scope.runId);
  20. };
  21. $scope.testAgain = function() {
  22. API.relaunchTest($scope.result);
  23. };
  24. loadResults();
  25. }]);