You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2017/02/21 16:39:35 UTC

[04/25] ambari git commit: AMBARI-20064 : hive20 view : added notification on error of preview or upload of table (nitirajrathore)

AMBARI-20064 : hive20 view : added notification on error of preview or upload of table (nitirajrathore)


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

Branch: refs/heads/branch-feature-AMBARI-12556
Commit: fad8f2745b8e39c51800fede563e170d30ddf9f3
Parents: c7bd689
Author: Nitiraj Singh Rathore <ni...@gmail.com>
Authored: Mon Feb 20 14:21:18 2017 +0530
Committer: Nitiraj Singh Rathore <ni...@gmail.com>
Committed: Mon Feb 20 14:21:18 2017 +0530

----------------------------------------------------------------------
 .../resources/ui/app/components/upload-table.js |  2 +-
 .../main/resources/ui/app/mixins/ui-logger.js   |  9 +++++
 .../databases/database/tables/upload-table.js   | 41 ++++----------------
 .../resources/ui/app/services/alert-messages.js |  7 +++-
 .../app/templates/components/upload-table.hbs   |  4 +-
 5 files changed, 27 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/fad8f274/contrib/views/hive20/src/main/resources/ui/app/components/upload-table.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/components/upload-table.js b/contrib/views/hive20/src/main/resources/ui/app/components/upload-table.js
index 8df03e5..3da3056 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/components/upload-table.js
+++ b/contrib/views/hive20/src/main/resources/ui/app/components/upload-table.js
@@ -28,7 +28,7 @@ export default Ember.Component.extend({
   fileInfo: Ember.Object.create({
     files: Ember.A(),
     hdfsPath: null,
-    uploadSource: null,
+    uploadSource: "local",
   }),
   tableMeta: Ember.Object.create(),
   actions: {

http://git-wip-us.apache.org/repos/asf/ambari/blob/fad8f274/contrib/views/hive20/src/main/resources/ui/app/mixins/ui-logger.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/mixins/ui-logger.js b/contrib/views/hive20/src/main/resources/ui/app/mixins/ui-logger.js
index 277f69c..b01c4d4 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/mixins/ui-logger.js
+++ b/contrib/views/hive20/src/main/resources/ui/app/mixins/ui-logger.js
@@ -29,5 +29,14 @@ export default Ember.Mixin.create({
     } else {
       return error;
     }
+  },
+  extractMessage(error) {
+    if (Ember.isArray(error.errors) && (error.errors.length >= 0)) {
+      return error.errors[0].message;
+    } else if(!Ember.isEmpty(error.errors)) {
+      return error.errors.message;
+    } else{
+      return error.message;
+    }
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/fad8f274/contrib/views/hive20/src/main/resources/ui/app/routes/databases/database/tables/upload-table.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/routes/databases/database/tables/upload-table.js b/contrib/views/hive20/src/main/resources/ui/app/routes/databases/database/tables/upload-table.js
index a9bf9ea..e4c543b 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/routes/databases/database/tables/upload-table.js
+++ b/contrib/views/hive20/src/main/resources/ui/app/routes/databases/database/tables/upload-table.js
@@ -22,8 +22,9 @@ import constants from '../../../../utils/constants';
 import Column from '../../../../models/column';
 import datatypes from '../../../../configs/datatypes';
 import Helpers from '../../../../configs/helpers';
+import UILoggerMixin from '../../../../mixins/ui-logger';
 
-export default NewTable.extend({
+export default NewTable.extend(UILoggerMixin, {
   COLUMN_NAME_REGEX: "^[a-zA-Z]{1}[a-zA-Z0-9_]*$",
   TABLE_NAME_REGEX: "^[a-zA-Z]{1}[a-zA-Z0-9_]*$",
   HDFS_PATH_REGEX: "^[/]{1}.+",  // unix path allows everything but here we have to mention full path so starts with /
@@ -630,26 +631,19 @@ export default NewTable.extend({
     if(error){
       console.log(" error : ", error);
       this.set('error', JSON.stringify(error));
-      // this.get('notifyService').warn(error);
-      // TODO : add notifyService warn message.
-      console.log("TODO : add notifyService warn message.");
+      this.get('notifyService').error( this.extractMessage(error), this.extractError(error));
     }else{
       this.set("error");
     }
   },
-  previewError: function (error) {
-    this.setError(error);
-  },
   uploadTableFromHdfs : function(tableData){
     console.log("uploadTableFromHdfs called.");
-    // if(!(this.get("inputFileTypeCSV") == true && this.get("isFirstRowHeader") == false) ){
-      this.pushUploadProgressInfos(this.formatMessage('uploadingFromHdfs'));
-    // }
+    this.pushUploadProgressInfos(this.formatMessage('uploadingFromHdfs'));
     var csvParams = tableData.get("fileFormatInfo.csvParams");
-    let columns = tableData.get("tableMeta").columns.map(function(column){
+    let columns = tableData.get("tableMeta").columns.map(function (column) {
       return {"name": column.get("name"), "type": column.get("type.label")};
     });
-    let header = columns; //JSON.stringify(columns);
+    let header = columns;
 
     return this.getUploader().uploadFromHDFS({
       "databaseName": tableData.get("database"),
@@ -687,24 +681,11 @@ export default NewTable.extend({
     console.log("onUploadSuccessfull : ", data);
     this._transitionToCreatedTable(this.get("tableData").get('database'), this.get("tableData").get('tableMeta').name);
 
-    // this.get('notifyService').success(this.translate('hive.messages.successfullyUploadedTableHeader'),
-    //   this.translate('hive.messages.successfullyUploadedTableMessage' ,{tableName:this.get("tableData").get("tableMeta").name ,databaseName:this.get("tableData").get("database")}));
+    this.get('notifyService').success(this.translate('hive.messages.successfullyUploadedTableHeader'),
+      this.translate('hive.messages.successfullyUploadedTableMessage' ,{tableName:this.get("tableData").get("tableMeta").name ,databaseName:this.get("tableData").get("database")}));
     this.clearFields();
   },
 
-  onUploadError: function (error) {
-    console.log("onUploadError : ", error);
-    this.setError(error);
-  },
-  showOrHide: function () {
-    if (this.get('show') == false) {
-      this.set("displayOption", "display:none");
-      this.set("showMoreOrLess", "Show More");
-    } else {
-      this.set("displayOption", "display:table-row");
-      this.set("showMoreOrLess", "Show Less");
-    }
-  },
   validateInputs: function(tableData){
     let tableMeta = tableData.get("tableMeta");
     let containsEndlines = tableData.get("fileFormatInfo.containsEndlines");
@@ -722,9 +703,6 @@ export default NewTable.extend({
       this.set('previewObject', previewObject);
       return this.generatePreview(previewObject)
     },
-    previewFromHdfs: function () {
-      return this.generatePreview();
-    },
     uploadTable: function (tableData) {
       console.log("tableData", tableData);
       try {
@@ -736,8 +714,5 @@ export default NewTable.extend({
         this.hideUploadModal();
       }
     },
-    uploadFromHDFS: function () {
-      this.set("isLocalUpload", false);
-    }
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/fad8f274/contrib/views/hive20/src/main/resources/ui/app/services/alert-messages.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/services/alert-messages.js b/contrib/views/hive20/src/main/resources/ui/app/services/alert-messages.js
index a05fc7a..5280db2 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/services/alert-messages.js
+++ b/contrib/views/hive20/src/main/resources/ui/app/services/alert-messages.js
@@ -112,7 +112,12 @@ export default Ember.Service.extend({
     data.id = this._getNextAlertId();
     data.type = type;
     data.status = options.status || -1;
-    data.trace = this._getDetailedError(options.trace);
+    if(options.trace){
+      data.trace = this._getDetailedError(options.trace);
+    }
+    else{
+      data.trace = this._getDetailedError(options.stack);
+    }
     delete options.status;
     delete options.error;
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/fad8f274/contrib/views/hive20/src/main/resources/ui/app/templates/components/upload-table.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/templates/components/upload-table.hbs b/contrib/views/hive20/src/main/resources/ui/app/templates/components/upload-table.hbs
index e4388f0..0ee6b81 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/templates/components/upload-table.hbs
+++ b/contrib/views/hive20/src/main/resources/ui/app/templates/components/upload-table.hbs
@@ -41,10 +41,12 @@
         &nbsp;&nbsp;&nbsp;Table Preview
       </div>
     </div>
+  <div class="query-result">
     {{#if showPreview}}
-    {{simple-table header=columns rows=rows }}
+      {{simple-table header=columns rows=rows }}
     {{/if}}
   </div>
+  </div>
 </div>