ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pallav...@apache.org
Subject ambari git commit: AMBARI-20228. HiveView 2.0 : After download CSV, the pop-up persists (pallavkul)
Date Tue, 28 Feb 2017 11:36:21 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 3a2411a9d -> 2081ca0fa


AMBARI-20228. HiveView 2.0 : After download CSV, the pop-up persists (pallavkul)


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

Branch: refs/heads/branch-2.5
Commit: 2081ca0fa7f2effadb273ba57f4429a8f3e9d60e
Parents: 3a2411a
Author: pallavkul <pallav.kul@gmail.com>
Authored: Tue Feb 28 17:04:45 2017 +0530
Committer: pallavkul <pallav.kul@gmail.com>
Committed: Tue Feb 28 17:06:06 2017 +0530

----------------------------------------------------------------------
 .../src/main/resources/ui/app/adapters/job.js   | 43 +++++++++++++-
 .../resources/ui/app/routes/queries/query.js    | 39 -------------
 .../ui/app/routes/queries/query/results.js      | 59 +++++++++++++++++++-
 .../src/main/resources/ui/app/services/query.js |  9 +--
 .../ui/app/templates/queries/query/results.hbs  |  7 ++-
 5 files changed, 103 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2081ca0f/contrib/views/hive20/src/main/resources/ui/app/adapters/job.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/adapters/job.js b/contrib/views/hive20/src/main/resources/ui/app/adapters/job.js
index 9fc73a4..7559e9c 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/adapters/job.js
+++ b/contrib/views/hive20/src/main/resources/ui/app/adapters/job.js
@@ -26,12 +26,49 @@ export default ApplicationAdapter.extend({
 
   getQuery(job) {
     let queryUrl = this.buildURL() + "/file" + encodeURI(job.get('queryFile'));
-    console.log(queryUrl);
   },
 
   saveToHDFS(jobId, path){
-    let resultUrl = this.urlForFindRecord(jobId, 'job') + "/results/csv/saveToHDFS?commence=true&file="
+ path + ".csv";
-    return this.ajax(resultUrl, 'GET');
+    let url = this.urlForFindRecord(jobId, 'job') + "/results/csv/saveToHDFS?commence=true&file="
+ path + ".csv";
+
+    return new Ember.RSVP.Promise((resolve, reject) => {
+      this.ajax(url).then((response) => {
+        if (response.status.toLowerCase() !== "TERMINATED".toLowerCase()) {
+          this.pollSaveToHDFS(response).then( (response) => {
+            resolve(response);
+          },  (error) => {
+            reject(error);
+          });
+        } else {
+          resolve(response);
+        }
+      }, (error) => {
+        reject(error);
+      });
+    })
+
+  },
+
+  pollSaveToHDFS: function (data) {
+    let url = this.urlForFindRecord(data.jobId, 'job') + "/results/csv/saveToHDFS";
+
+    return new Ember.RSVP.Promise((resolve, reject) => {
+
+      this.ajax(url).then( (response) => {
+        if (response.status.toLowerCase() !== "TERMINATED".toLowerCase()) {
+          Ember.run.later( () => {
+            this.pollSaveToHDFS(response)
+              .then((data) => { resolve(data)}, (error) => {
+                reject(error);
+              });
+          }, 2000);
+        } else {
+            resolve(response);
+        }
+      }, (error) => {
+        reject(error);
+      });
+    });
   },
 
   downloadAsCsv(jobId, path){

http://git-wip-us.apache.org/repos/asf/ambari/blob/2081ca0f/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query.js b/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query.js
index 8f0085c..4ac93db 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query.js
+++ b/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query.js
@@ -530,45 +530,6 @@ export default Ember.Route.extend(UILoggerMixin, {
       this.get('controller').set('showWorksheetModal', false);
     },
 
-    saveToHDFS(jobId, path){
-
-      console.log('saveToHDFS query route with jobId == ', jobId);
-      console.log('saveToHDFS query route with path == ', path);
-
-      this.get('query').saveToHDFS(jobId, path)
-        .then((data) => {
-          console.log('successfully saveToHDFS', data);
-          this.get('controller').set('isExportResultSuccessMessege', true);
-          this.get('controller').set('isExportResultFailureMessege', false);
-
-          Ember.run.later(() => {
-            this.get('controller').set('showSaveHdfsModal', false);
-          }, 2 * 1000);
-
-        }, (error) => {
-          console.log("Error encountered", error);
-          this.get('controller').set('isExportResultFailureMessege', true);
-          this.get('controller').set('isExportResultSuccessMessege', false);
-
-          Ember.run.later(() => {
-            this.get('controller').set('showSaveHdfsModal', false);
-          }, 2 * 1000);
-
-        });
-    },
-
-    downloadAsCsv(jobId, path){
-
-      console.log('downloadAsCsv query route with jobId == ', jobId);
-      console.log('downloadAsCsv query route with path == ', path);
-
-      let downloadAsCsvUrl = this.get('query').downloadAsCsv(jobId, path) || '';
-
-      this.get('controller').set('showDownloadCsvModal', false);
-      window.open(downloadAsCsvUrl);
-
-    },
-
     expandQueryEdidorPanel(){
       if(!this.get('isQueryEdidorPaneExpanded')){
         this.set('isQueryEdidorPaneExpanded', true);

http://git-wip-us.apache.org/repos/asf/ambari/blob/2081ca0f/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query/results.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query/results.js
b/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query/results.js
index 4b59a13..df970fb 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query/results.js
+++ b/contrib/views/hive20/src/main/resources/ui/app/routes/queries/query/results.js
@@ -17,8 +17,9 @@
  */
 
 import Ember from 'ember';
+import UILoggerMixin from '../../../mixins/ui-logger';
 
-export default Ember.Route.extend({
+export default Ember.Route.extend(UILoggerMixin, {
 
   jobs: Ember.inject.service(),
   query: Ember.inject.service(),
@@ -44,7 +45,14 @@ export default Ember.Route.extend({
       this.controller.set('previousPage', model.get('previousPage'));
       this.controller.set('hasNext', model.get('hasNext'));
       this.controller.set('hasPrevious', model.get('hasPrevious'));
+
       this.controller.set('queryResult', model.get('queryResult'));
+      this.controller.set('isExportResultSuccessMessege', false);
+      this.controller.set('isExportResultFailureMessege', false);
+      this.controller.set('showSaveHdfsModal', false);
+      this.controller.set('showDownloadCsvModal', false);
+
+
       this.controller.set('hasJobAssociated', true);
     } else {
       this.controller.set('hasJobAssociated', false);
@@ -54,6 +62,55 @@ export default Ember.Route.extend({
 
   actions:{
 
+    saveToHDFS(jobId, path){
+
+      var self = this;
+
+      console.log('saveToHDFS query route with jobId == ', jobId);
+      console.log('saveToHDFS query route with path == ', path);
+
+      this.get('query').saveToHDFS(jobId, path)
+        .then((data) => {
+
+          console.log('successfully saveToHDFS', data);
+          this.get('controller').set('isExportResultSuccessMessege', true);
+          this.get('controller').set('isExportResultFailureMessege', false);
+
+          Ember.run.later(() => {
+            this.get('controller').set('showSaveHdfsModal', false);
+            this.get('logger').success('Successfully Saved to HDFS.');
+
+          }, 2 * 1000);
+
+        }, (error) => {
+
+          console.log("Error encountered", error);
+          this.get('controller').set('isExportResultFailureMessege', true);
+          this.get('controller').set('isExportResultSuccessMessege', false);
+
+          Ember.run.later(() => {
+            this.get('controller').set('showSaveHdfsModal', false);
+            this.get('logger').danger('Failed to save to HDFS.', this.extractError(error));
+          }, 2 * 1000);
+
+
+        });
+    },
+
+
+    downloadAsCsv(jobId, path){
+
+      console.log('downloadAsCsv query route with jobId == ', jobId);
+      console.log('downloadAsCsv query route with path == ', path);
+
+      let downloadAsCsvUrl = this.get('query').downloadAsCsv(jobId, path) || '';
+
+      this.get('controller').set('showDownloadCsvModal', false);
+      this.get('logger').success('Successfully downloaded as CSV.');
+      window.open(downloadAsCsvUrl);
+
+    },
+
   }
 
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/2081ca0f/contrib/views/hive20/src/main/resources/ui/app/services/query.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/services/query.js b/contrib/views/hive20/src/main/resources/ui/app/services/query.js
index 3bf10c0..6860f4d 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/services/query.js
+++ b/contrib/views/hive20/src/main/resources/ui/app/services/query.js
@@ -43,14 +43,7 @@ export default Ember.Service.extend({
   },
 
   saveToHDFS(jobId, path){
-    let self = this;
-    return new Promise( (resolve, reject) => {
-      this.get('store').adapterFor('job').saveToHDFS(jobId, path).then(function(data) {
-        resolve(data);
-      }, function(err) {
-          reject(err);
-      });
-    });
+    return this.get('store').adapterFor('job').saveToHDFS(jobId, path);
   },
 
   downloadAsCsv(jobId, path){

http://git-wip-us.apache.org/repos/asf/ambari/blob/2081ca0f/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query/results.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query/results.hbs
b/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query/results.hbs
index ad44c5a..966312c 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query/results.hbs
+++ b/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query/results.hbs
@@ -39,9 +39,10 @@
   saveToHDFS='saveToHDFS'
   downloadAsCsv='downloadAsCsv'
   expandQueryResultPanel='expandQueryResultPanel'
-  isExportResultSuccessMessege=false
-  isExportResultFailureMessege=false
-  showSaveHdfsModal=false
+  isExportResultSuccessMessege=isExportResultSuccessMessege
+  isExportResultFailureMessege=isExportResultFailureMessege
+  showSaveHdfsModal=showSaveHdfsModal
+  showDownloadCsvModal=showDownloadCsvModal
   }}
 {{/if}}
 


Mime
View raw message