Browse Source

HUE-3378 [editor] Cookie the 'show logs' action

Enrico Berti 9 years ago
parent
commit
37573d1

+ 8 - 1
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -359,7 +359,11 @@
     self.result = new Result(snippet, snippet.result);
     self.showGrid = ko.observable(typeof snippet.showGrid != "undefined" && snippet.showGrid != null ? snippet.showGrid : true);
     self.showChart = ko.observable(typeof snippet.showChart != "undefined" && snippet.showChart != null ? snippet.showChart : false);
-    self.showLogs = ko.observable(typeof snippet.showLogs != "undefined" && snippet.showLogs != null ? snippet.showLogs : false);
+    var defaultShowLogs = false;
+    if (vm.editorMode && $.totalStorage('hue.editor.showLogs')) {
+      defaultShowLogs = $.totalStorage('hue.editor.showLogs');
+    }
+    self.showLogs = ko.observable(typeof snippet.showLogs != "undefined" && snippet.showLogs != null ? snippet.showLogs : defaultShowLogs);
     self.progress = ko.observable(typeof snippet.progress != "undefined" && snippet.progress != null ? snippet.progress : 0);
     self.jobs = ko.observableArray(typeof snippet.jobs != "undefined" && snippet.jobs != null ? snippet.jobs : []);
 
@@ -385,6 +389,9 @@
       if (val) {
         self.getLogs();
       }
+      if (vm.editorMode) {
+        $.totalStorage('hue.editor.showLogs', val);
+      }
     });
 
     self.isLoading = ko.computed(function () {

+ 1 - 1
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -403,7 +403,7 @@ ${ require.config() }
 </script>
 
 <script type="text/html" id="snippet-log">
-  <div class="snippet-log-container" data-bind="slideVisible: showLogs, onComplete: function(){ redrawFixedHeaders(200); }" style="display: none;">
+  <div class="snippet-log-container margin-bottom-10" data-bind="slideVisible: showLogs() && status() != 'ready' && status() != 'loading', onComplete: function(){ redrawFixedHeaders(200); }" style="display: none;">
     <div data-bind="delayedOverflow, css: resultsKlass" style="margin-top: 5px; position: relative;">
       <ul data-bind="visible: jobs().length > 0, foreach: jobs" class="unstyled jobs-overlay">
         <li><a data-bind="text: $.trim($data.name), attr: { href: $data.url }" target="_blank"></a></li>