ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gna...@apache.org
Subject ambari git commit: AMBARI-19380. Workflow Draft Save-Not working. (Madhan Mohan Reddy via gauravn7)
Date Thu, 05 Jan 2017 11:33:08 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk ae7133674 -> 773d155c8


AMBARI-19380. Workflow Draft Save-Not working. (Madhan Mohan Reddy via gauravn7)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/773d155c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/773d155c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/773d155c

Branch: refs/heads/trunk
Commit: 773d155c86f65beaddfcc4950550555ad0ed9069
Parents: ae71336
Author: Gaurav Nagar <grvngr@gmail.com>
Authored: Thu Jan 5 17:01:37 2017 +0530
Committer: Gaurav Nagar <grvngr@gmail.com>
Committed: Thu Jan 5 17:02:50 2017 +0530

----------------------------------------------------------------------
 .../ui/app/components/flow-designer.js          | 41 +++++---------------
 .../main/resources/ui/app/components/save-wf.js | 13 ++++---
 .../app/templates/components/flow-designer.hbs  |  8 ++--
 3 files changed, 20 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/773d155c/contrib/views/wfmanager/src/main/resources/ui/app/components/flow-designer.js
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/components/flow-designer.js
b/contrib/views/wfmanager/src/main/resources/ui/app/components/flow-designer.js
index b02e021..3454374 100644
--- a/contrib/views/wfmanager/src/main/resources/ui/app/components/flow-designer.js
+++ b/contrib/views/wfmanager/src/main/resources/ui/app/components/flow-designer.js
@@ -465,7 +465,7 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
         request.setRequestHeader("X-XSRF-HEADER", Math.round(Math.random()*100000));
         request.setRequestHeader("X-Requested-By", "workflow-designer");
       },
-      data: self.persistWorkflowAsDraft(),
+      data: self.getWorkflowAsJson(),
       success: function(response) {
         //deferred.resolve(response);
       }.bind(this),
@@ -511,9 +511,6 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
     }
     return detect(obj);
   },
-  persistWorkflowAsDraft(){
-
-  },
   getDraftWorkflowData(path){
     var deferred = Ember.RSVP.defer();
     //var path = encodeURIComponent("/user/ambari-qa/examples/demo/draft");
@@ -612,25 +609,23 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
       scrollTop: scroll+200
     }, 1000);
   },
-  openSaveWorkflow (isWfPathSet){
+  openSaveWorkflow() {
     this.get('workflowContext').clearErrors();
     var workflowGenerator=WorkflowGenerator.create({workflow:this.get("workflow"),
     workflowContext:this.get('workflowContext')});
     var workflowXml=workflowGenerator.process();
     if(this.get('workflowContext').hasErrors()){
       this.set('errors',this.get('workflowContext').getErrors());
-      this.set("jobXmlJSONStr", this.persistWorkflowAsDraft());
+      this.set("jobXmlJSONStr", this.getWorkflowAsJson());
       this.set("isDraft", true);
     }else{
-      this.set("jobXmlJSONStr", "");
+      this.set("jobXmlJSONStr", this.getWorkflowAsJson());
       var dynamicProperties = this.get('propertyExtractor').getDynamicProperties(workflowXml);
       var configForSubmit={props:dynamicProperties,xml:workflowXml,params:this.get('workflow.parameters')};
       this.set("workflowSubmitConfigs",configForSubmit);
       this.set("isDraft", false);
     }
-    if(isWfPathSet) {
-      this.set("showingSaveWorkflow",true);
-    }
+    this.set("showingSaveWorkflow",true);
   },
   openJobConfig (){
     this.get('workflowContext').clearErrors();
@@ -866,26 +861,9 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
       this.openJobConfig();
     },
     saveWorkflow(action){
-      if(this.get("fileInfo").get("path") && action === "save"){
-        this.openSaveWorkflow();
-        var url = Ember.ENV.API_URL + "/saveWorkflow?app.path=" + this.get("fileInfo").get("path")
+ "&overwrite=" + this.get("fileInfo").get("overWritePath");
-        var self = this, workflowData;
-
-        if(this.get('isDraft')){
-           url = Ember.ENV.API_URL + "/saveWorkflowDraft?app.path=" + this.get("fileInfo").get("path")
+ "&overwrite=" + this.get("fileInfo").get("overWritePath");;
-           workflowData = this.get("jobXmlJSONStr");
-        } else {
-           url = Ember.ENV.API_URL + "/saveWorkflow?app.path=" + this.get("fileInfo").get("path")
+ "&overwrite=" + this.get("fileInfo").get("overWritePath");;
-           workflowData = this.get("workflowSubmitConfigs").xml;
-        }
-
-        this.get("saveJobService").saveWorkflow(url, workflowData).promise.then(function(data){
-        }.bind(this)).catch(function(data){
-          self.set("errorMsg", "There is some problem while saving workflow.Please try again.");
-          self.showingErrorMsgInDesigner(data);
-        });
-      } else {
-        this.openSaveWorkflow(true);
+      this.openSaveWorkflow();
+      if(action === "saveDraft"){
+        this.set("isDraft", true);
       }
       this.set('dryrun', false);
     },
@@ -942,9 +920,8 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
           var draftData = JSON.parse(data);
           if(draftData.draftExists && draftData.isDraftCurrent){
             self.getDraftWorkflowData(path).promise.then(function(data){
-              var drafWorkflowJson = self.get('workspaceManager').restoreWorkInProgress(data);
               var workflowImporter=WorkflowJsonImporter.create({});
-              var workflow=workflowImporter.importWorkflow(drafWorkflowJson);
+              var workflow=workflowImporter.importWorkflow(data);
 
               self.resetDesigner();
               self.set("workflow",workflow);

http://git-wip-us.apache.org/repos/asf/ambari/blob/773d155c/contrib/views/wfmanager/src/main/resources/ui/app/components/save-wf.js
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/components/save-wf.js b/contrib/views/wfmanager/src/main/resources/ui/app/components/save-wf.js
index 8514cb0..d91c52a 100644
--- a/contrib/views/wfmanager/src/main/resources/ui/app/components/save-wf.js
+++ b/contrib/views/wfmanager/src/main/resources/ui/app/components/save-wf.js
@@ -78,15 +78,16 @@ export default Ember.Component.extend(Validations, {
     }
   },
   saveJob(){
-    var url, workflowData;
-    if(this.get('isDraft')){
-       url = Ember.ENV.API_URL + "/saveWorkflowDraft?app.path=" + this.get("filePath") +
"&overwrite=" + this.get("overwritePath");
-       workflowData = this.get("jobXmlJSONStr");
-    } else {
+    var url = Ember.ENV.API_URL + "/saveWorkflowDraft?app.path=" + this.get("filePath") +
"&overwrite=" + this.get("overwritePath");
+    var workflowData = this.get("jobXmlJSONStr");
+    this.saveWfJob(url, workflowData);
+    if(!this.get('isDraft')){
        url = Ember.ENV.API_URL + "/saveWorkflow?app.path=" + this.get("filePath") + "&overwrite="
+ this.get("overwritePath");
        workflowData = this.get("jobXml");
+       this.saveWfJob(url, workflowData);
     }
-
+  },
+  saveWfJob(url, workflowData) {
     var self = this;
     this.get("saveJobService").saveWorkflow(url, workflowData).promise.then(function(response){
         self.showNotification({

http://git-wip-us.apache.org/repos/asf/ambari/blob/773d155c/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/flow-designer.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/flow-designer.hbs
b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/flow-designer.hbs
index 6e1b054..42da448 100644
--- a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/flow-designer.hbs
+++ b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/flow-designer.hbs
@@ -48,12 +48,12 @@
                         <i class="fa fa-download marginright5"></i>Import from
Local FS
                     {{/file-picker}}
                   </a>
-                  <!--a class="pointer" title="Save workflow" {{action "saveWorkflow"
"save"}}>
+                  <a class="pointer" title="Save workflow" {{action "saveWorkflow" "save"}}>
                       <i class="fa fa-floppy-o marginright5"></i>Save
                   </a>
-                  <a class="pointer" title="Save workflow" {{action "saveWorkflow" }}>
-                      <i class="fa fa-floppy-o marginright5"></i>Save As
-                  </a-->
+                  <a class="pointer" title="Save as draft" {{action "saveWorkflow" "saveDraft"}}>
+                      <i class="fa fa-floppy-o marginright5"></i>Save As Draft
+                  </a>
                 </li>
                 <li>
                   <a class="pointer" data-toggle="modal" title="Save workflow to local
file system" {{action "downloadWorkflowXml"}}>


Mime
View raw message