瀏覽代碼

[metastore] Alert user in case of error

Enrico Berti 10 年之前
父節點
當前提交
e36e296

+ 6 - 1
apps/beeswax/src/beeswax/static/beeswax/js/beeswax.vm.js

@@ -90,6 +90,8 @@ function BeeswaxViewModel(server, assistHelper) {
 
   self.impalaSessionLink = ko.observable("");
 
+  self.isEditor = ko.observable(true);
+
   self.chartType = ko.observable("bars");
   self.chartSorting = ko.observable("none");
   self.chartData = ko.observableArray();
@@ -652,13 +654,16 @@ function BeeswaxViewModel(server, assistHelper) {
           }
           if (! failed) {
             $(document).trigger('stop_watch.query');
-
             if (fn) {
               fn(data);
             } else {
               self.fetchResults();
             }
           }
+          else {
+            self.design.watch.errors.push(data.message);
+            $(document).trigger('stop_watch.query');
+          }
         } else {
           self.design.statement(data.statement); // In case new no result statement executed
           if (data.log) {

+ 9 - 3
apps/beeswax/src/beeswax/templates/execute.mako

@@ -218,7 +218,7 @@ ${ layout.menubar(section='query') }
       % endif
     </div>
   </div>
-  <div class="resizer" data-bind="splitDraggable : { appName: '${app_name}', onPosition: onPanelPosition }"><div class="resize-bar"><i class="fa fa-ellipsis-v"></i></div></div>
+  <div class="resizer" data-bind="splitDraggable : { appName: '${app_name}', onPosition: onPanelPosition, leftPanelVisible: isEditor }"><div class="resize-bar"><i class="fa fa-ellipsis-v"></i></div></div>
   <div class="right-panel" id="querySide">
     <div class="alert" data-bind="visible: design.isRedacted">
       ${ _('This query had some sensitive information removed when saved.') }
@@ -2420,6 +2420,7 @@ $(document).ready(function () {
 
   function watchPageComponents() {
     $('#advanced-settings').hide();
+    viewModel.isEditor(false);
     $('#navigator').hide();
     $('#queryContainer').hide();
     $('#resizePanel').hide();
@@ -2650,7 +2651,6 @@ viewModel.design.fileResources.values.subscribe(function() {
   $(".fileChooser:not(:has(~ button))").after(getFileBrowseButton($(".fileChooser:not(:has(~ button))")));
 });
 
-
 % if action == 'watch-results':
   $(document).ready(watchEvents);
   $(document).one('fetched.query', function(e) {
@@ -2664,7 +2664,13 @@ viewModel.design.fileResources.values.subscribe(function() {
     cacheQueryTextEvents();
   });
   $(document).on('stop_watch.query', function(e) {
-    if (viewModel.design.results.errors().length == 0) {
+    var successUrl = "${request.GET['on_success_url']}";
+    if (viewModel.design.watch.errors().length != 0) {
+      window.setTimeout(function(){
+        window.location.href = successUrl + (successUrl.indexOf("?") > -1 ? "&" : "?") + "error=" + encodeURIComponent(viewModel.design.watch.errors().join("\n"));
+      }, 200);
+    }
+    else if (viewModel.design.results.errors().length == 0) {
       window.setTimeout(function(){
         window.location.href = "${request.GET['on_success_url']}";
       }, 200);

+ 4 - 0
apps/metastore/src/metastore/templates/databases.mako

@@ -113,6 +113,10 @@ ${ components.menubar() }
 
     ko.applyBindings(viewModel);
 
+    if (location.getParameter("error") != "") {
+      $.jHueNotify.error(location.getParameter("error"));
+    }
+
     var databases = $(".datatables").dataTable({
       "sDom": "<'row'r>t<'row'<'span8'i><''p>>",
       "bPaginate": false,

+ 4 - 0
apps/metastore/src/metastore/templates/tables.mako

@@ -155,6 +155,10 @@ ${ components.menubar() }
 
     ko.applyBindings(viewModel);
 
+    if (location.getParameter("error") != "") {
+      $.jHueNotify.error(location.getParameter("error"));
+    }
+
     var tables = $(".datatables").dataTable({
       "sDom": "<'row'r>t<'row'<'span8'i><''p>>",
       "bPaginate": false,

+ 2 - 0
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -796,7 +796,9 @@
         if (ko.isObservable(options.leftPanelVisible) && ! options.leftPanelVisible()) {
           $rightPanel.css("width", "100%");
           $rightPanel.css("left", "0");
+          $resizer.hide();
         } else {
+          $resizer.show();
           var totalWidth = $container.width();
           leftPanelWidth = Math.min(leftPanelWidth, totalWidth - 100);
           var rightPanelWidth = totalWidth - leftPanelWidth - $resizer.width();