Explorar o código

HUE-2641 [spark] Display error lines

If there's an error message with a reference to a line number the line will now be marked with a red background.
Johan Ahlen %!s(int64=10) %!d(string=hai) anos
pai
achega
7a28f59

+ 10 - 5
apps/spark/src/spark/static/spark/js/spark.ko.js

@@ -75,7 +75,6 @@ var Result = function (snippet, result) {
   self.images.extend({ rateLimit: 50 });
   self.logs = ko.observable('');
   self.logLines = 0;
-  self.errors = ko.observable('');
   self.hasSomeResults = ko.computed(function () {
     return self.hasResultset() && self.data().length > 0; // status() == 'available'
   });
@@ -101,11 +100,10 @@ var Result = function (snippet, result) {
     self.fetchedOnce(false);
     self.data.removeAll();
     self.logs('');
-    self.errors('');
     self.startTime(new Date());
     self.endTime(new Date());
   };
-}
+};
 
 var TYPE_ACE_EDITOR_MAP = {
   'hive': 'ace/mode/hive',
@@ -125,7 +123,7 @@ var getDefaultSnippetProperties = function (snippetType) {
     properties['numExecutors'] = '';
     properties['queue'] = '';
     properties['archives'] = [];
-  };
+  }
 
   if (snippetType == 'jar') {
     properties['app_jar'] = '';
@@ -149,6 +147,8 @@ var getDefaultSnippetProperties = function (snippetType) {
   return properties;
 };
 
+var ERROR_REGEX = /line ([0-9]+)/i;
+
 var Snippet = function (vm, notebook, snippet) {
   var self = this;
 
@@ -344,7 +344,11 @@ var Snippet = function (vm, notebook, snippet) {
     }
     else if (data.status == 1) {
       self.status('failed');
-      self.result.errors(data.message);
+      var match = ERROR_REGEX.exec(data.message);
+      self.errors.push({
+        message: data.message,
+        line: match === null ? null : parseInt(match[1]) - 1
+      });
     } else {
       $(document).trigger("error", data.message);
       self.status('failed');
@@ -365,6 +369,7 @@ var Snippet = function (vm, notebook, snippet) {
 
     self.status('running');
     self.result.clear();
+    self.errors([]);
     self.result.logLines = 0;
     self.progress(0);
 

+ 7 - 5
apps/spark/src/spark/templates/editor_components.mako

@@ -648,12 +648,14 @@ from django.utils.translation import ugettext as _
     <div class="progress progress-striped active" style="height: 0" data-bind="css: {
       'progress-warning': progress() > 0 && progress() < 100,
       'progress-success': progress() == 100,
-      'progress-danger': progress() == 0 && result.errors().length > 0}" style="background-color: #FFF; width: 100%">
-      <div class="bar" data-bind="style: {'width': (result.errors().length > 0 ? 100 : progress()) + '%'}"></div>
+      'progress-danger': progress() == 0 && errors().length > 0}" style="background-color: #FFF; width: 100%">
+      <div class="bar" data-bind="style: {'width': (errors().length > 0 ? 100 : progress()) + '%'}"></div>
     </div>
   </div>
-  <div data-bind="visible: result.errors().length > 0, css: errorsKlass" style="margin-left: 3px">
-    <span data-bind="text: result.errors"></span>
+  <div data-bind="visible: errors().length > 0, css: errorsKlass" style="margin-left: 3px">
+    <ul data-bind="foreach: errors">
+      <li data-bind="text: message"></li>
+    </ul>
   </div>
 
   <div class="snippet-footer-actions-bar">
@@ -723,7 +725,7 @@ from django.utils.translation import ugettext as _
     <div class="pull-right hover-actions" style="padding-top: 8px; font-size: 15px;">
       <span style="color: #CCC; padding-right: 10px;" data-bind="visible: type() != 'text' && status() != 'ready' && status() != 'loading', text: result.executionTime().toHHMMSS()"></span>
 
-      <a href="javascript:void(0)" data-bind="visible: status() != 'ready' && status() != 'loading' && result.errors().length == 0, click: function() { $data.showLogs(! $data.showLogs()); window.setTimeout(redrawFixedHeaders, 100); }, css: {'blue': $data.showLogs}" title="${ _('Show Logs') }">
+      <a href="javascript:void(0)" data-bind="visible: status() != 'ready' && status() != 'loading' && errors().length == 0, click: function() { $data.showLogs(! $data.showLogs()); window.setTimeout(redrawFixedHeaders, 100); }, css: {'blue': $data.showLogs}" title="${ _('Show Logs') }">
         <i class="fa fa-file-text-o"></i>
       </a>
 

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/ace/theme-hue.js


+ 13 - 11
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -1672,6 +1672,19 @@ ko.bindingHandlers.aceEditor = {
       });
     }
 
+    if (ko.isObservable(options.errors)) {
+      options.errors.subscribe(function(errors) {
+        editor.clearErrors();
+        if (errors.length > 0) {
+          errors.forEach(function (err) {
+            if (err.line !== null) {
+              editor.addError(err.message, err.line);
+            }
+          });
+        }
+      });
+    }
+
     editor.setTheme($.totalStorage("hue.ace.theme") || "ace/theme/hue");
 
     var editorOptions = {
@@ -2111,17 +2124,6 @@ ko.bindingHandlers.aceEditor = {
           editor.completers.push(complete);
         });
       }
-      editor.clearErrors();
-      if (options.errors().length > 0) {
-        options.errors().forEach(function (err) {
-          editor.addError(err.message, err.line);
-          if (err.line == editor.getCursorPosition().row) {
-            window.setTimeout(function () {
-              $(element).find(".ace_active-line").remove();
-            }, 100)
-          }
-        });
-      }
     }
   }
 };

+ 7 - 9
tools/ace-editor/lib/ace/theme/hue.css

@@ -20,11 +20,6 @@
   opacity: 0;
 }
 
-.ace-hue .ace_gutter {
-  background: #f6f6f6;
-  color: #4D4D4C
-}
-
 .ace-hue .ace_print-margin {
   width: 1px;
   background: #f6f6f6
@@ -56,14 +51,17 @@
   border: 1px solid #D1D1D1
 }
 
-.ace-hue .ace_gutter-active-line {
-  background-color: #dcdcdc
-}
-
 .ace-hue .ace_marker-layer .ace_selected-word {
   border: 1px solid #D6D6D6
 }
 
+.ace-hue .ace_marker-layer .ace_error-line {
+  position: absolute;
+  background-color: #f2dede;
+  width: 100% !important;
+  margin-left: -3px;
+}
+
 .ace-hue .ace_invisible {
   color: #D1D1D1
 }

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio