Prechádzať zdrojové kódy

HUE-4423 [editor] Persist the coordinator ID of a submitted schedule

Romain Rigaux 9 rokov pred
rodič
commit
5123af87f6

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

@@ -1765,8 +1765,12 @@
     };
 
 
-    self.viewSchedulerId = ko.observable('0000025-160525025600562-oozie-oozi-C');
+    self.viewSchedulerId = ko.observable(typeof notebook.viewSchedulerId != "undefined" && notebook.viewSchedulerId != null ? notebook.viewSchedulerId : '');
+    self.viewSchedulerId.subscribe(function(newVal) {
+      self.save();
+    });
     self.loadingScheduler = ko.observable(false);
+    self.viewSchedulerInfo = ko.observable();
     self.viewScheduler = function() {
       if (typeof vm.RunningCoordinatorModel !== 'undefined') {
         logGA('schedule/view');
@@ -1775,6 +1779,7 @@
           format: 'json'
         }, function (data) {
           self.schedulerViewerViewModel(new vm.RunningCoordinatorModel(data.actions));
+          self.viewSchedulerInfo(ko.mapping.fromJS(data));
         }).fail(function (xhr) {
           $(document).trigger("error", xhr.responseText);
         }).always(function () {

+ 18 - 8
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -993,7 +993,7 @@ ${ hueIcons.symbols() }
       <li class="active"><a href="#sessionsTab" data-toggle="tab">${_('Sessions')}</a></li>
       % if ENABLE_QUERY_SCHEDULING.get():
       <li><a href="#scheduleTab" data-toggle="tab">${_('Schedule')}</a></li>
-      <li><a href="#scheduledJobsTab" data-toggle="tab">${_('Jobs')}</a></li>
+      <li><a href="#scheduledJobsTab" data-toggle="tab">${_('Instances')}</a></li>
       % endif
     </ul>
 
@@ -1053,17 +1053,20 @@ ${ hueIcons.symbols() }
 
       <!-- ko if: $root.selectedNotebook() -->
       <!-- ko with: $root.selectedNotebook() -->
-        <!-- ko if: $root.selectedNotebook().isSaved() -->
-          <a data-bind="click: showSubmitPopup">Submit</a></br>
-          <a class="pointer" data-bind="click: function(){ $('a[href=\'#scheduledJobsTab\']').click(); }">${_('View')}</a>
 
+        <!-- ko if: isSaved() -->
+          ${ _('Query was changed and needs to be saved.') }
+          <a data-bind="click: showSubmitPopup">${ _('Start') }</a></br>
+          </br>
           <div id="schedulerEditor">
+            <div id="schedulerEditor"></div>
           </div>
         <!-- /ko -->
 
-        <!-- ko ifnot: $root.selectedNotebook().isSaved() -->
-          ${ _('Document needs to be saved first.') }
+        <!-- ko ifnot: isSaved() -->
+          ${ _('Query needs to be saved first.') }
         <!-- /ko -->
+
       <!-- /ko -->
       <!-- /ko -->
     </div>
@@ -1073,13 +1076,18 @@ ${ hueIcons.symbols() }
       <!-- ko if: $root.selectedNotebook() -->
       <!-- ko with: $root.selectedNotebook() -->
       <!-- ko if: $root.selectedNotebook().isSaved() -->
-        <input type="text" data-bind="value: viewSchedulerId" /> <a class="pointer" data-bind="click: viewScheduler">load</a>
+        <a class="pointer" data-bind="click: viewScheduler">Refresh</a>
 
         <!-- ko if: loadingScheduler -->
         <div style="padding: 20px">
           <i class="fa fa-spinner fa-spin muted"></i>
         </div>
         <!-- /ko -->
+
+        <!-- ko if: viewSchedulerInfo -->
+        <span data-bind="text: viewSchedulerInfo().data"></span>
+        <!-- /ko -->
+
         <!-- ko with: schedulerViewerViewModel -->
         <div id="schedulerViewer">
           <table class="table table-striped table-condensed margin-top-10">
@@ -3279,9 +3287,11 @@ ${ hueIcons.symbols() }
       });
 
       huePubSub.subscribe('submit.popup.return', function (data) {
-        console.log('Job id', data.job_id);
+        viewModel.selectedNotebook().viewSchedulerId(data.job_id);
         $.jHueNotify.info('${_('Coordinator submitted.')}');
         $('.submit-modal').modal('hide');
+
+        $('a[href=\'#scheduledJobsTab\']').click();
       });
 
       huePubSub.subscribe('jobbrowser.data', function (jobs) {