Procházet zdrojové kódy

HUE-4116 [editor] Integrate saving schedule into the main save button

Romain Rigaux před 9 roky
rodič
revize
94e91c6

+ 3 - 2
apps/oozie/src/oozie/static/oozie/js/coordinator-editor.ko.js

@@ -156,7 +156,7 @@ var CoordinatorEditorViewModel = function (coordinator_json, credentials_json, w
 
   if (! coordinator_json['properties']['timezone']) {
     coordinator_json['properties']['timezone'] = tzdetect.matches()[0];
-   }
+  }
   self.canEdit = ko.mapping.fromJS(can_edit_json);
   self.isEditing = ko.observable(coordinator_json.id == null);
   self.isEditing.subscribe(function (newVal) {
@@ -213,9 +213,10 @@ var CoordinatorEditorViewModel = function (coordinator_json, credentials_json, w
         if (data.status == 0) {
           self.coordinator.id(data.id);
           self.coordinator.tracker().markCurrentStateAsClean();
-          $(document).trigger("info", data.message);
           if (cb) {
             cb(data);
+          } else {
+        	$(document).trigger("info", data.message);
           }
           if (window.location.search.indexOf("coordinator") == -1) {
             window.location.hash = '#coordinator=' + data.id;

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

@@ -1350,6 +1350,10 @@
         snippet.jobs.length = 0;
       });
 
+      if (self.schedulerViewModel) {
+    	self.saveScheduler();
+      }
+
       $.post("/notebook/api/notebook/save", {
         "notebook": ko.mapping.toJSON(cp, NOTEBOOK_MAPPING),
         "editorMode": vm.editorMode
@@ -1573,10 +1577,12 @@
     };
 
     self.saveScheduler = function() {
-      self.schedulerViewModel.coordinator.name('My daily run');  // TODO Temp fix until js errors are gone
-      self.schedulerViewModel.save(function(data) {
-    	self.coordinatorUuid(data.uuid);
-      });
+      if (self.schedulerViewModel.coordinator.isDirty()) {
+        self.schedulerViewModel.coordinator.name('My daily run');  // TODO Temp fix until js errors are gone
+        self.schedulerViewModel.save(function(data) {
+    	  self.coordinatorUuid(data.uuid);
+        });
+      }
     };
 
     self.viewSchedulerId = ko.observable('0000000-160519110441280-oozie-oozi-C');

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

@@ -1049,9 +1049,9 @@ ${ hueIcons.symbols() }
       
       <!-- ko if: $root.selectedNotebook() -->
       <!-- ko with: $root.selectedNotebook() -->
-        <!-- ko if: $root.selectedNotebook().id() -->
+        <!-- ko if: $root.selectedNotebook().isSaved() -->
           <a data-bind="click: loadScheduler">Load</a></br>
-          <a data-bind="click: saveScheduler">Save</a></br></br>
+
            Start</br>
           <a href="#scheduledJobsTab" data-toggle="tab">${_('View')}</a>
 
@@ -1059,7 +1059,7 @@ ${ hueIcons.symbols() }
           </div>
         <!-- /ko -->
 
-        <!-- ko ifnot: $root.selectedNotebook().id() -->
+        <!-- ko ifnot: $root.selectedNotebook().isSaved() -->
           ${ _('Document needs to be saved first.') }
         <!-- /ko -->
       <!-- /ko -->