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-19581. Need to show proper error message in scenarios of failures with asset import (Madhan Mohan Reddy via gauravn7)
Date Wed, 18 Jan 2017 07:17:13 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk e0d78edb9 -> 7d2388b35


AMBARI-19581. Need to show proper error message in scenarios of failures with asset import
(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/7d2388b3
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7d2388b3
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7d2388b3

Branch: refs/heads/trunk
Commit: 7d2388b35b7c6b477244c7ed5e9a1f480e98ccf9
Parents: e0d78ed
Author: Gaurav Nagar <grvngr@gmail.com>
Authored: Wed Jan 18 12:46:56 2017 +0530
Committer: Gaurav Nagar <grvngr@gmail.com>
Committed: Wed Jan 18 12:46:56 2017 +0530

----------------------------------------------------------------------
 .../resources/ui/app/components/asset-list.js     | 15 ++++-----------
 .../resources/ui/app/components/flow-designer.js  | 18 +++++++++++++++---
 .../src/main/resources/ui/app/styles/app.less     |  5 +++++
 .../ui/app/templates/components/asset-config.hbs  |  3 +--
 .../ui/app/templates/components/asset-list.hbs    |  9 ++++++---
 .../ui/app/templates/components/asset-manager.hbs |  5 ++++-
 .../ui/app/templates/components/flow-designer.hbs |  8 ++++----
 7 files changed, 39 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7d2388b3/contrib/views/wfmanager/src/main/resources/ui/app/components/asset-list.js
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/components/asset-list.js b/contrib/views/wfmanager/src/main/resources/ui/app/components/asset-list.js
index 2ea82b0..9ad0494 100644
--- a/contrib/views/wfmanager/src/main/resources/ui/app/components/asset-list.js
+++ b/contrib/views/wfmanager/src/main/resources/ui/app/components/asset-list.js
@@ -46,20 +46,9 @@ export default Ember.Component.extend({
     this.$('#asset_list_dialog').modal().on('hidden.bs.modal', function() {
       this.sendAction('showAssetList', false);
     }.bind(this));
-
-    this.$('#asset-list').on('click', 'tr', function(event) {
-      if(!$(this).hasClass('active-asset-row')) {
-        $(this).addClass('active-asset-row').siblings().removeClass('active-asset-row');
-      }
-      self.set('currentAssetId', $(this).data("assetId"));
-      self.set('assetNotSelected', false);
-    });
     this.initializeFuseSearch();
   }.on('didInsertElement'),
   initializeFuseSearch() {
-     // var fuse = new Fuse(this.get("assetList"), this.get('fuseSearchOptions'));
-     // this.set('fuse', fuse);
-     // this.set('filteredAssetList', fuse.search(this.get("assetSearchCriteria")));
      this.set('fuse', new Fuse(this.get("assetList"), this.get('fuseSearchOptions')));
      this.set('filteredAssetList', this.get("assetList"));
    },
@@ -77,6 +66,10 @@ export default Ember.Component.extend({
     importAsset() {
       this.$('#asset_list_dialog').modal('hide');
       this.sendAction('importAsset', this.get('assetList').filterBy('id', this.currentAssetId.toString())[0]);
+    },
+    selectAsset(assetId) {
+      this.set('currentAssetId', assetId);
+      this.set('assetNotSelected', false);
     }
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/7d2388b3/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 d0c05d6..8bbe831 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
@@ -352,13 +352,14 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
   importActionSettingsFromString(actionSettings) {
     var x2js = new X2JS();
     var actionSettingsObj = x2js.xml_str2json(actionSettings);
+    var actionSettingsObjType = Object.keys(actionSettingsObj)[0];
     var currentActionNode = this.flowRenderer.currentCyNode.data().node;
-    if (actionSettingsObj[currentActionNode.actionType]) {
+    if (actionSettingsObjType === currentActionNode.actionType) {
       var actionJobHandler = this.actionTypeResolver.getActionJobHandler(currentActionNode.actionType);
       actionJobHandler.handleImport(currentActionNode, actionSettingsObj[currentActionNode.actionType]);
       this.flowRenderer.hideOverlayNodeActions();
     } else {
-      this.set("errorMsg", "Invalid asset settings");
+      this.set("errorMsg", actionSettingsObjType + " action settings can't be imported to
" + currentActionNode.actionType + " action");
     }
   },
   importActionNodeFromString(actionNodeXmlString) {
@@ -399,6 +400,7 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
   exportActionNodeXml() {
     var self = this;
     self.set("isAssetPublishing", true);
+    self.set("errorMsg", "");
     var workflowGenerator = WorkflowGenerator.create({workflow:this.get("workflow"), workflowContext:this.get('workflowContext')});
     var actionNodeXml = workflowGenerator.getActionNodeXml(this.flowRenderer.currentCyNode.data().name,
this.flowRenderer.currentCyNode.data().node.actionType);
     var dynamicProperties = this.get('propertyExtractor').getDynamicProperties(actionNodeXml);
@@ -931,6 +933,7 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
       var self = this;
       this.set("showingActionSettingsFileBrowser", false);
       if(this.get('actionSettingsFilePath')){
+        self.set("errorMsg", "");
         var actionSettingsXmlDefered=this.getWorkflowFromHdfs(this.get('actionSettingsFilePath'));
         actionSettingsXmlDefered.promise.then(function(data){
           this.importActionSettingsFromString(data);
@@ -949,6 +952,7 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
       var self = this;
       this.set("showingImportActionNodeFileBrowser", false);
       if(this.get('actionNodeFilePath')){
+        self.set("errorMsg", "");
         var actionSettingsXmlDefered=this.getWorkflowFromHdfs(this.get('actionNodeFilePath'));
         actionSettingsXmlDefered.promise.then(function(data){
           this.importActionNodeFromString(data);
@@ -1077,6 +1081,7 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
     saveAssetConfig() {
       var self=this;
       self.set("isAssetPublishing", true);
+      self.set("errorMsg", "");
       var workflowGenerator = WorkflowGenerator.create({workflow:self.get("workflow"), workflowContext:self.get('workflowContext')});
       var actionNodeXml = workflowGenerator.getActionNodeXml(self.flowRenderer.currentCyNode.data().name,
self.flowRenderer.currentCyNode.data().node.actionType);
       var dynamicProperties = self.get('propertyExtractor').getDynamicProperties(actionNodeXml);
@@ -1094,9 +1099,13 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
     showAssetList(value) {
       var self=this;
       if (value) {
+        self.set("errorMsg", "");
         var fetchAssetsDefered=self.get("assetManager").fetchAssets();
         fetchAssetsDefered.promise.then(function(response){
-          self.set('assetList', JSON.parse(response).data);
+          var assetData = JSON.parse(response).data;
+          assetData = assetData.filterBy('type', self.flowRenderer.currentCyNode.data().node.actionType);
+          self.set('assetList', assetData);
+          self.set('assetListType', self.flowRenderer.currentCyNode.data().node.actionType);
           self.set('showingAssetList', value);
         }.bind(this)).catch(function(data){
           self.set("errorMsg", "There is some problem while fetching assets. Please try again.");
@@ -1109,6 +1118,7 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
     importAsset(asset) {
       var self=this;
       self.set("isAssetImporting", true);
+      self.set("errorMsg", "");
       var importAssetDefered=self.get("assetManager").importAssetDefinition(asset.id);
       importAssetDefered.promise.then(function(response){
         var importedAsset = JSON.parse(response).data;
@@ -1123,6 +1133,7 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
     showAssetNodeList(value) {
       var self=this;
       if (value) {
+        self.set("errorMsg", "");
         var fetchAssetsDefered=self.get("assetManager").fetchAssets();
         fetchAssetsDefered.promise.then(function(response){
           self.set('assetList', JSON.parse(response).data);
@@ -1138,6 +1149,7 @@ export default Ember.Component.extend(FindNodeMixin, Validations, {
     importAssetNode(asset) {
       var self=this;
       self.set("isAssetImporting", true);
+      self.set("errorMsg", "");
       var importAssetDefered=self.get("assetManager").importAssetDefinition(asset.id);
       importAssetDefered.promise.then(function(response){
         var importedAsset = JSON.parse(response).data;

http://git-wip-us.apache.org/repos/asf/ambari/blob/7d2388b3/contrib/views/wfmanager/src/main/resources/ui/app/styles/app.less
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/styles/app.less b/contrib/views/wfmanager/src/main/resources/ui/app/styles/app.less
index bc0e419..05bdb5a 100644
--- a/contrib/views/wfmanager/src/main/resources/ui/app/styles/app.less
+++ b/contrib/views/wfmanager/src/main/resources/ui/app/styles/app.less
@@ -1627,3 +1627,8 @@ input:invalid {
   width: 100%;
   min-height: 100px;
 }
+.no-asset-records {
+  text-align: center;
+  padding: 3px;
+  overflow-y: auto;
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/7d2388b3/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/asset-config.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/asset-config.hbs
b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/asset-config.hbs
index 4ee6d05..3ae4bff 100644
--- a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/asset-config.hbs
+++ b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/asset-config.hbs
@@ -22,12 +22,11 @@
         <button type="button" class="close" data-dismiss="modal" aria-label="Close" {{action
'close'}}>
           <span aria-hidden="true">&times;</span>
         </button>
-        <h4 class="modal-title">Add Asset</h4>
+        <h4 class="modal-title">Publish Asset</h4>
       </div>
       <div class="modal-body">
           <form class="form-horizontal">
             <div class="panel panel-default">
-              <!-- <div class="panel-heading">General</div> -->
               <div class="panel-body">
                 <div class="form-group">
                   <label for="assetName" class="control-label col-xs-2">Name</label>

http://git-wip-us.apache.org/repos/asf/ambari/blob/7d2388b3/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/asset-list.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/asset-list.hbs
b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/asset-list.hbs
index d377d2c..bc5201d 100644
--- a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/asset-list.hbs
+++ b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/asset-list.hbs
@@ -22,7 +22,7 @@
         <button type="button" class="close" data-dismiss="modal" aria-label="Close" {{action
'close'}}>
           <span aria-hidden="true">&times;</span>
         </button>
-        <h4 class="modal-title">Select Asset</h4>
+        <h4 class="modal-title">Import Asset</h4>
       </div>
       <div class="modal-body">
         {{input type="text" class="form-control marginBottom10" name="assetSearchCriteria"
value=assetSearchCriteria placeholder="Asset Search"}}
@@ -38,11 +38,14 @@
             </thead>
           </table>
         </div>
-        <div class="panel panel-default asset-list-panel-body">
+        <div class="panel panel-default asset-list-panel-body {{if (eq filteredAssetList.length
0) 'no-asset-records'}}">
+          {{#if (eq filteredAssetList.length 0)}}
+            No {{#if (not-eq assetListType "")}} {{assetListType}}{{/if}} assets
+          {{/if}}
           <table id="asset-list" class="table asset-list listing table-striped table-hover
table-bordered" cellspacing="0" width="100%">
             <tbody>
               {{#each filteredAssetList as |asset idx|}}
-                <tr data-asset-id="{{asset.id}}">
+                <tr {{action 'selectAsset' asset.id}} class="{{if (eq currentAssetId asset.id)
"active-asset-row"}}">
                   <td class="col-xs-3">{{asset.name}}</td>
                   <td class="col-xs-3">{{asset.type}}</td>
                   <td class="col-xs-3">{{asset.description}}</td>

http://git-wip-us.apache.org/repos/asf/ambari/blob/7d2388b3/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/asset-manager.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/asset-manager.hbs
b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/asset-manager.hbs
index 0fa86b0..7a21af1 100644
--- a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/asset-manager.hbs
+++ b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/asset-manager.hbs
@@ -38,7 +38,10 @@
             </thead>
           </table>
         </div>
-        <div class="panel panel-default asset-list-panel-body">
+        <div class="panel panel-default asset-list-panel-body {{if (eq filteredAssetList.length
0) 'no-asset-records'}}">
+          {{#if (eq filteredAssetList.length 0)}}
+            <span>No assets</span>
+          {{/if}}
           <table id="asset-list" class="table asset-list listing table-striped table-hover
table-bordered" cellspacing="0" width="100%">
             <tbody>
               {{#each filteredAssetList as |asset idx|}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/7d2388b3/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 80af968..95c8c3b 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
@@ -248,12 +248,12 @@
             <span class="overlay-asset-import-icon" title="Import Asset" {{action "showAssetList"
true}}>
                 <i class="fa fa-download"></i>
             </span>
-            <span class="overlay-asset-export-icon" title="Publish Asset" {{action "showAssetConfig"
true}}>
-                <i class="fa fa-upload"></i>
-            </span>
             <span class="overlay-hdfs-asset-import-icon" title="Import asset from HDFS"
{{action "showActionSettingsFileBrowser"}}>
               <i class="fa fa-cloud-download"></i>
             </span>
+            <span class="overlay-asset-export-icon" title="Publish Asset" {{action "showAssetConfig"
true}}>
+                <i class="fa fa-upload"></i>
+            </span>
             <span class="overlay-hdfs-asset-export-icon" title="Publish Asset to HDFS"
{{action "showExportActionNodeFileBrowser"}}>
               <i class="fa fa-cloud-upload"></i>
             </span>
@@ -303,7 +303,7 @@
   {{#asset-config showAssetConfig="showAssetConfig" saveAssetConfig="saveAssetConfig" assetModel=assetConfig}}{{/asset-config}}
 {{/if}}
 {{#if showingAssetList}}
-  {{#asset-list showAssetList="showAssetList" importAsset="importAsset" assetList=assetList}}{{/asset-list}}
+  {{#asset-list showAssetList="showAssetList" importAsset="importAsset" assetList=assetList
assetListType=assetListType}}{{/asset-list}}
 {{/if}}
 {{#if showingAssetNodeList}}
   {{#asset-list showAssetList="showAssetNodeList" importAsset="importAssetNode" deleteAsset="deleteAsset"
assetList=assetList}}{{/asset-list}}


Mime
View raw message