Browse Source

HUE-2585 [impala] Display further errors when no line is specified in the error message

Improved displaying of errors
Enrico Berti 10 years ago
parent
commit
7361436460

+ 4 - 8
apps/beeswax/src/beeswax/templates/execute.mako

@@ -249,7 +249,7 @@ ${layout.menubar(section='query')}
         <div class="tab-content">
           <div id="queryPane">
 
-            <div data-bind="css: {'hide': design.errors().length == 0}" class="alert alert-error">
+            <div data-bind="css: {'hide': design.errors().length == 0 || design.inlineErrors().length > 0}" class="alert alert-error">
               <!-- ko if: $root.getQueryErrors().length > 0 -->
               <p><strong>${_('Please provide a query')}</strong></p>
               <!-- /ko -->
@@ -262,7 +262,7 @@ ${layout.menubar(section='query')}
               <!-- /ko -->
             </div>
 
-            <div data-bind="css: {'hide': design.watch.errors().length == 0}" class="alert alert-error">
+            <div data-bind="css: {'hide': design.watch.errors().length == 0 || design.watch.inlineErrors().length > 0}" class="alert alert-error">
               <p><strong>${_('Your query has the following error(s):')}</strong></p>
 
               <div data-bind="foreach: design.watch.errors">
@@ -2128,8 +2128,8 @@ $(document).on('error.query', function () {
 
   // Move error to codeMirror if we know the line number
   $.each($(".queryErrorMessage"), function(index, el) {
-    var err = $(el).text().toLowerCase();
-    var firstPos = err.indexOf("line");
+    var err = $(el).text();
+    var firstPos = err.toLowerCase().indexOf("line");
     if (firstPos > -1) {
       selectedLine = $.trim(err.substring(err.indexOf(" ", firstPos), err.indexOf(":", firstPos))) * 1;
       errorWidgets.push(
@@ -2145,10 +2145,6 @@ $(document).on('error.query', function () {
     }
   });
 
-  if ($(".queryErrorMessage:hidden").length == $(".queryErrorMessage").length) {
-    $(".queryErrorMessage").parent().parent().hide();
-  }
-
   reinitializeTableExtenders();
 });
 

+ 12 - 0
apps/beeswax/static/js/beeswax.vm.js

@@ -74,6 +74,18 @@ function BeeswaxViewModel(server) {
 
   self.design = ko.mapping.fromJS(DESIGN_DEFAULTS);
 
+  self.design.inlineErrors = ko.computed(function() {
+    return ko.utils.arrayFilter(self.design.errors(), function(err) {
+        return err.toLowerCase().indexOf("line") > -1;
+    });
+  });
+
+  self.design.watch.inlineErrors = ko.computed(function() {
+    return ko.utils.arrayFilter(self.design.watch.errors(), function(err) {
+        return err.toLowerCase().indexOf("line") > -1;
+    });
+  });
+
   self.chartType = ko.observable("bars");
   self.chartSorting = ko.observable("none");
   self.chartData = ko.observableArray();