Browse Source

HUE-4855 [notebook] Dynamically display if a query or notebook can be batched or scheduled

If editor mode: the snippet is either batchable through Oozie or not (e.g. Hive, Pig)
In notebook mode: all the snippets need to be batchable
Romain Rigaux 9 years ago
parent
commit
fa3264a

+ 4 - 4
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -254,7 +254,7 @@
 
     self.isBatchable = ko.computed(function() {
       return self.type() == 'hive'
-    	  || $.grep(vm.availableLanguages, function(language) { return language.type == self.type() && language.interface == 'oozie'; }).length > 0;
+          || $.grep(vm.availableLanguages, function(language) { return language.type == self.type() && language.interface == 'oozie'; }).length > 0;
     });
 
     // Ace stuff
@@ -1373,7 +1373,7 @@
     self.schedulerViewerViewModel = ko.observable();
     self.isBatchable = ko.computed(function() {
       return self.snippets().length > 0
-        && $.each(self.snippets(), function (index, snippet) {
+        && $.grep(self.snippets(), function (snippet) {
           return snippet.isBatchable();
         }).length == self.snippets().length;
     });
@@ -1989,11 +1989,11 @@
 
     if (options.languages && options.snippetViewSettings) {
       $.each(options.languages, function (idx, language) {
-    	self.availableLanguages.push({
+        self.availableLanguages.push({
           type: language.type,
           name: language.name,
           interface: language.interface,
-    	});
+        });
         var viewSettings = options.snippetViewSettings[language.type];
         if (viewSettings && viewSettings.sqlDialect) {
           self.sqlSourceTypes.push({

+ 9 - 11
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -1104,12 +1104,10 @@ ${ hueIcons.symbols() }
     </div>
 
     % if ENABLE_QUERY_SCHEDULING.get():
-    <!-- ko if: editorMode() -->
+    <!-- ko if: $root.selectedNotebook() && $root.selectedNotebook().isBatchable() -->
+    <!-- ko with: $root.selectedNotebook() -->
     <div class="tab-pane" id="scheduleTab">
 
-      <!-- ko if: $root.selectedNotebook() -->
-      <!-- ko with: $root.selectedNotebook() -->
-
         <!-- ko if: isSaved() -->
           ${ _('Query was changed and needs to be saved.') }
           <a data-bind="click: showSubmitPopup">${ _('Start') }</a></br>
@@ -1122,15 +1120,14 @@ ${ hueIcons.symbols() }
         <!-- ko ifnot: isSaved() -->
           ${ _('Query needs to be saved first.') }
         <!-- /ko -->
-
-      <!-- /ko -->
-      <!-- /ko -->
     </div>
+    <!-- /ko -->
+    <!-- /ko -->
 
+    <!-- ko if: $root.selectedNotebook() && $root.selectedNotebook().isBatchable() -->
+    <!-- ko with: $root.selectedNotebook() -->
     ## To move to 'notification' panel
     <div class="tab-pane" id="scheduledJobsTab">
-      <!-- ko if: $root.selectedNotebook() -->
-      <!-- ko with: $root.selectedNotebook() -->
       <!-- ko if: $root.selectedNotebook().isSaved() -->
         <a class="pointer" data-bind="click: viewScheduler">Refresh</a>
 
@@ -1172,9 +1169,10 @@ ${ hueIcons.symbols() }
         </div>
         <!-- /ko -->
       <!-- /ko -->
-      <!-- /ko -->
-      <!-- /ko -->
     </div>
+    <!-- /ko -->
+    <!-- /ko -->
+
     <!-- /ko -->
     % endif