Repository: ambari Updated Branches: refs/heads/trunk bcbc597b7 -> 0e3ced141
AMBARI-20131.Workflow details are lost upon refreshing the browser.(Padma Priya N via gauravn7) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0e3ced14 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0e3ced14 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0e3ced14 Branch: refs/heads/trunk Commit: 0e3ced141ff9969d0da33c53827b72cfff543f65 Parents: bcbc597 Author: Gaurav Nagar <grv...@gmail.com> Authored: Wed Mar 1 17:17:09 2017 +0530 Committer: Gaurav Nagar <grv...@gmail.com> Committed: Wed Mar 1 17:17:09 2017 +0530 ---------------------------------------------------------------------- .../ui/app/components/designer-workspace.js | 48 ++++++++++++-------- .../ui/app/domain/workflow-json-importer.js | 5 ++ .../main/resources/ui/app/domain/workflow.js | 2 +- .../main/resources/ui/app/services/user-info.js | 2 +- .../ui/app/services/workspace-manager.js | 17 ++++--- 5 files changed, 43 insertions(+), 31 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/0e3ced14/contrib/views/wfmanager/src/main/resources/ui/app/components/designer-workspace.js ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/components/designer-workspace.js b/contrib/views/wfmanager/src/main/resources/ui/app/components/designer-workspace.js index 74de3b7..0e49d70 100644 --- a/contrib/views/wfmanager/src/main/resources/ui/app/components/designer-workspace.js +++ b/contrib/views/wfmanager/src/main/resources/ui/app/components/designer-workspace.js @@ -32,10 +32,10 @@ export default Ember.Component.extend({ currentIndex : Ember.computed('tabs.[]', function() { return this.get('tabs').length > 0 ? this.get('tabs').length - 1 : 0; }), - tabsObserver : Ember.observer('tabs.[]', 'ta...@each.name', 'tabs.@each.filePath', function(){ + tabsObserver : function(){ this.get('workspaceManager').saveTabs(this.get('tabs')); this.tabManager(); - }), + }, initialize : function(){ if (Constants.isProjectManagerEnabled) { this.set("isProjectManagerEnabled", "true"); @@ -47,24 +47,29 @@ export default Ember.Component.extend({ this.get('tabCounter').set('bundle', 0); var tabsData = this.get('workspaceManager').restoreTabs(); tabsData.promise.then(function(tabs){ - if(tabs){ - this.set('tabs', tabs); - } - this.get('tabs').forEach((tab)=>{ - this.get('tabCounter').set(tab.type, (this.get('tabCounter').get(tab.type)) + 1); - }, this); - Ember.getOwner(this).lookup('route:design').on('openNewTab', function(path, type, isImportedFromDesigner, configuration){ - if(type === 'COORDINATOR'){ - this.createNewTab('coord', path); - }else if(type === 'BUNDLE'){ - this.createNewTab('bundle', path); - }else{ - this.createNewTab('wf', path, isImportedFromDesigner, configuration); - } - }.bind(this)); - - }.bind(this)).catch(function(data){ - }); + if(tabs){ + this.set('tabs', tabs); + } + this.get('tabs').forEach((tab)=>{ + this.get('tabCounter').set(tab.type, (this.get('tabCounter').get(tab.type)) + 1); + }, this); + Ember.addObserver(this, 'tabs.[]',this, this.tabsObserver); + Ember.addObserver(this, 'ta...@each.name',this, this.tabsObserver); + Ember.addObserver(this, 'tabs.@each.filePath',this, this.tabsObserver); + }.bind(this)).catch(function(data){ + Ember.addObserver(this, 'tabs.[]',this, this.tabsObserver); + Ember.addObserver(this, 'ta...@each.name',this, this.tabsObserver); + Ember.addObserver(this, 'tabs.@each.filePath',this, this.tabsObserver); + }); + Ember.getOwner(this).lookup('route:design').on('openNewTab', function(path, type, isImportedFromDesigner, configuration){ + if(type === 'COORDINATOR'){ + this.createNewTab('coord', path); + }else if(type === 'BUNDLE'){ + this.createNewTab('bundle', path); + }else{ + this.createNewTab('wf', path, isImportedFromDesigner, configuration); + } + }.bind(this)); }.on('init'), elementsInserted : function(){ this.tabManager(); @@ -84,6 +89,9 @@ export default Ember.Component.extend({ } }.on('didInsertElement'), onDestroy : function(){ + Ember.removeObserver(this, 'tabs.[]',this, this.tabsObserver); + Ember.removeObserver(this, 'ta...@each.name',this, this.tabsObserver); + Ember.removeObserver(this, 'tabs.@each.filePath',this, this.tabsObserver); this.get('tabs').clear(); }.on('willDestroyElement'), tabManager(){ http://git-wip-us.apache.org/repos/asf/ambari/blob/0e3ced14/contrib/views/wfmanager/src/main/resources/ui/app/domain/workflow-json-importer.js ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/domain/workflow-json-importer.js b/contrib/views/wfmanager/src/main/resources/ui/app/domain/workflow-json-importer.js index 2e937e5..e300480 100644 --- a/contrib/views/wfmanager/src/main/resources/ui/app/domain/workflow-json-importer.js +++ b/contrib/views/wfmanager/src/main/resources/ui/app/domain/workflow-json-importer.js @@ -30,6 +30,11 @@ var WorkflowJsonImporter= Ember.Object.extend({ workflow.set("name",workflowJson.name); workflow.schemaVersions.workflowVersion = workflowJson.schemaVersions.workflowVersion; workflow.schemaVersions.actionVersions = new Map(JSON.parse(workflowJson.schemaVersions.actionVersions)); + workflow.sla = workflowJson.sla; + workflow.slaEnabled = workflowJson.slaEnabled; + workflow.credentials = workflowJson.credentials; + workflow.globalSetting = workflowJson.globalSetting; + workflow.parameters = workflowJson.parameters; this.restoreKillNodes(workflowJson.killNodes,workflow); var nodeMap= new Map(); var startNode=this.visitNode(workflowJson.startNode,nodeMap); http://git-wip-us.apache.org/repos/asf/ambari/blob/0e3ced14/contrib/views/wfmanager/src/main/resources/ui/app/domain/workflow.js ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/domain/workflow.js b/contrib/views/wfmanager/src/main/resources/ui/app/domain/workflow.js index 9fd8286..228f0e2 100644 --- a/contrib/views/wfmanager/src/main/resources/ui/app/domain/workflow.js +++ b/contrib/views/wfmanager/src/main/resources/ui/app/domain/workflow.js @@ -31,7 +31,6 @@ var Workflow= Ember.Object.extend(FindNodeMixin,{ killNodes : null, nodeVisitor : null, nodeFactory:NodeFactory.create({}), - sla : SlaInfo.create({}), credentials : Ember.A([]), initialize(){ this.nodeVisitor=NodeVisitor.create({}); @@ -55,6 +54,7 @@ var Workflow= Ember.Object.extend(FindNodeMixin,{ this.set("draftVersion", "v1"); this.set("parameters", null); this.set("credentials", Ember.A([])); + this.set("sla", SlaInfo.create({})); this.appendDefaultKillNode(); src.addTransitionTo(dest); }, http://git-wip-us.apache.org/repos/asf/ambari/blob/0e3ced14/contrib/views/wfmanager/src/main/resources/ui/app/services/user-info.js ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/services/user-info.js b/contrib/views/wfmanager/src/main/resources/ui/app/services/user-info.js index 7c59f40..701f953 100644 --- a/contrib/views/wfmanager/src/main/resources/ui/app/services/user-info.js +++ b/contrib/views/wfmanager/src/main/resources/ui/app/services/user-info.js @@ -44,7 +44,7 @@ export default Ember.Service.extend({ deferred.reject(data); }); } - return deferred; + return deferred.promise; }, setUserData(data){ this.set("data", data); http://git-wip-us.apache.org/repos/asf/ambari/blob/0e3ced14/contrib/views/wfmanager/src/main/resources/ui/app/services/workspace-manager.js ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/services/workspace-manager.js b/contrib/views/wfmanager/src/main/resources/ui/app/services/workspace-manager.js index e77ef7f..8636fd5 100644 --- a/contrib/views/wfmanager/src/main/resources/ui/app/services/workspace-manager.js +++ b/contrib/views/wfmanager/src/main/resources/ui/app/services/workspace-manager.js @@ -22,14 +22,14 @@ export default Ember.Service.extend({ workInProgress : {}, userInfo : Ember.inject.service('user-info'), setLastActiveTab(tabId){ - this.get("userInfo").getUserData().promise.then(function(data){ + this.get("userInfo").getUserData().then(function(data){ localStorage.setItem(data+"-lastActiveTab", tabId); }.bind(this)).catch(function(e){ console.error(e); }); }, getLastActiveTab(){ - this.get("userInfo").getUserData().promise.then(function(data){ + this.get("userInfo").getUserData().then(function(data){ return localStorage.getItem(data+"-lastActiveTab"); }.bind(this)).catch(function(e){ console.error(e); @@ -37,8 +37,7 @@ export default Ember.Service.extend({ }, restoreTabs(){ var deferred = Ember.RSVP.defer(); - - this.get("userInfo").getUserData().promise.then(function(data){ + this.get("userInfo").getUserData().then(function(data){ var tabs = localStorage.getItem(data+'-tabsInfo'); deferred.resolve(JSON.parse(tabs)); }.bind(this)).catch(function(e){ @@ -60,15 +59,15 @@ export default Ember.Service.extend({ filePath : tab.filePath }); }); - this.get("userInfo").getUserData().promise.then(function(data){ - localStorage.setItem(data+'-tabsInfo', JSON.stringify(tabArray)); + this.get("userInfo").getUserData().then(function(data){ + localStorage.setItem(data+'-tabsInfo', JSON.stringify(tabArray)); }.bind(this)).catch(function(e){ console.error(e); }); }, restoreWorkInProgress(id){ var deferred = Ember.RSVP.defer(); - this.get("userInfo").getUserData().promise.then(function(data){ + this.get("userInfo").getUserData().then(function(data){ deferred.resolve(localStorage.getItem(data+"-"+id)); }.bind(this)).catch(function(data){ deferred.resolve(""); @@ -76,14 +75,14 @@ export default Ember.Service.extend({ return deferred; }, saveWorkInProgress(id, workInProgress){ - this.get("userInfo").getUserData().promise.then(function(data){ + this.get("userInfo").getUserData().then(function(data){ localStorage.setItem(data+"-"+id, workInProgress); }.bind(this)).catch(function(e){ console.error(e); }); }, deleteWorkInProgress(id){ - this.get("userInfo").getUserData().promise.then(function(data){ + this.get("userInfo").getUserData().then(function(data){ localStorage.removeItem(data+"-"+id); }.bind(this)).catch(function(e){ console.error(e);