Browse Source

Prevent fail when there's a screenshot error

Gaël Métais 10 years ago
parent
commit
6c47c406cb

+ 3 - 0
front/src/css/main.css

@@ -198,6 +198,9 @@ a.linkButton {
 .screenshotWrapper .screenshotImage {
   width: 100%;
 }
+.screenshotWrapper .screenshotError {
+  color: #fff;
+}
 .screenshotWrapper.desktop {
   border: 0.2em solid #AAA;
   padding: 0.5em;

+ 4 - 0
front/src/less/main.less

@@ -139,6 +139,10 @@ a.linkButton {
     .screenshotImage {
         width: 100%;
     }
+
+    .screenshotError {
+        color: #fff;
+    }
 }
 
 .screenshotWrapper.desktop {

+ 2 - 1
front/src/views/dashboard.html

@@ -13,7 +13,8 @@
             <a href="/result/{{result.runId}}/screenshot">
                 <div class="screenshotWrapper" ng-class="result.params.options.device || 'desktop'">
                     <div>
-                        <img class="screenshotImage" ng-src="{{result.screenshotUrl}}"/>
+                        <img ng-if="result.screenshotUrl" class="screenshotImage" ng-src="{{result.screenshotUrl}}"/>
+                        <span ng-if="!result.screenshotUrl" class="screenshotError">Screenshot not available</span>
                     </div>
                 </div>
             </a>

+ 2 - 1
front/src/views/screenshot.html

@@ -4,7 +4,8 @@
 
     <div class="screenshotWrapper" ng-class="result.params.options.device || 'desktop'">
         <div>
-            <img class="screenshotImage" ng-src="{{result.screenshotUrl}}"/>
+            <img ng-if="result.screenshotUrl" class="screenshotImage" ng-src="{{result.screenshotUrl}}"/>
+            <span ng-if="!result.screenshotUrl" class="screenshotError">Screenshot not available</span>
         </div>
     </div>
 

+ 7 - 1
lib/server/controllers/apiController.js

@@ -109,8 +109,14 @@ var ApiController = function(app) {
                         }
 
                     })
+                    
                     // Delete screenshot temporary file
-                    .then(screenshot.deleteTmpFile);
+                    .then(screenshot.deleteTmpFile)
+
+                    // Don't worry if there's an error
+                    .fail(function(err) {
+                        debug('An error occured while creating the screenshot\'s thumbnail. Ignoring and continuing...');
+                    });
 
             }