AMBARI-19566. Hive View 2.0: Export Query Result (pallavkul)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/8b22dd01 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8b22dd01 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8b22dd01 Branch: refs/heads/branch-dev-patch-upgrade Commit: 8b22dd01811759bef9a325773fa9c95862bac57c Parents: c326ce4 Author: pallavkul <[email protected]> Authored: Tue Jan 17 16:20:02 2017 +0530 Committer: pallavkul <[email protected]> Committed: Tue Jan 17 16:20:02 2017 +0530 ---------------------------------------------------------------------- .../src/main/resources/ui/app/adapters/job.js | 7 ++- .../ui/app/components/export-result.js | 54 ++++++++++++++++++++ .../ui/app/components/query-result-table.js | 34 ++++++++++-- .../resources/ui/app/components/save-hdfs.js | 52 ------------------- .../resources/ui/app/routes/queries/query.js | 32 ++++++++++-- .../src/main/resources/ui/app/services/query.js | 8 +++ .../app/templates/components/export-result.hbs | 46 +++++++++++++++++ .../templates/components/query-result-table.hbs | 20 +++++++- .../ui/app/templates/components/save-hdfs.hbs | 37 -------------- .../ui/app/templates/queries/query.hbs | 14 ++--- 10 files changed, 194 insertions(+), 110 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/8b22dd01/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 e2f342e..9fc73a4 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 @@ -30,8 +30,13 @@ export default ApplicationAdapter.extend({ }, saveToHDFS(jobId, path){ - let resultUrl = this.urlForFindRecord(jobId, 'job').replace('/resources','') + "/results/csv/saveToHDFS?commence=true&file=" + path + ".csv"; + let resultUrl = this.urlForFindRecord(jobId, 'job') + "/results/csv/saveToHDFS?commence=true&file=" + path + ".csv"; return this.ajax(resultUrl, 'GET'); + }, + + downloadAsCsv(jobId, path){ + let resultUrl = this.urlForFindRecord(jobId, 'job') + "/results/csv/?fileName=" + path + ".csv"; + return resultUrl; } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/8b22dd01/contrib/views/hive20/src/main/resources/ui/app/components/export-result.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/components/export-result.js b/contrib/views/hive20/src/main/resources/ui/app/components/export-result.js new file mode 100644 index 0000000..517da1e --- /dev/null +++ b/contrib/views/hive20/src/main/resources/ui/app/components/export-result.js @@ -0,0 +1,54 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ember from 'ember'; + +export default Ember.Component.extend({ + + label: null, + confirmText: 'Confirm', + rejectText: 'Reject', + isExportResultSuccessMessege:false, + isExportResultFailureMessege:false, + + jobId: 0, + + pathName: Ember.computed('jobId', function() { + return 'Worksheet_' + this.get('jobId'); + }), + + labelIcon: null, + confirmIcon: null, + rejectIcon: null, + + closable: true, + titleClass: 'primary', + confirmClass: 'primary', + rejectClass: 'default', + + actions: { + confirm() { + let pathName = $("input.path-name").val(); + this.sendAction('confirm', this.get('jobId'), pathName); + }, + + reject() { + this.sendAction('reject'); + } + } +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/8b22dd01/contrib/views/hive20/src/main/resources/ui/app/components/query-result-table.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/components/query-result-table.js b/contrib/views/hive20/src/main/resources/ui/app/components/query-result-table.js index 429dfb3..919127f 100644 --- a/contrib/views/hive20/src/main/resources/ui/app/components/query-result-table.js +++ b/contrib/views/hive20/src/main/resources/ui/app/components/query-result-table.js @@ -67,7 +67,12 @@ export default Ember.Component.extend({ showSaveHdfsModal:false, - showDownloadCsvModal:false, + showDownloadCsvModal: false, + + isExportResultSuccessMessege:false, + + isSaveHdfsErrorMessege:false, + actions: { onScrolledToBottom() { @@ -88,20 +93,39 @@ export default Ember.Component.extend({ }, openSaveHdfsModal(){ - this.set('showSaveHdfsModal',true) + this.set('showSaveHdfsModal',true); + this.set('isExportResultSuccessMessege',false); + this.set('isExportResultFailureMessege',false); }, closeSaveHdfsModal(){ - this.set('showSaveHdfsModal',false) + this.set('showSaveHdfsModal',false); + this.set('isExportResultSuccessMessege',false); + this.set('isExportResultFailureMessege',false); + }, + + openDownloadCsvModal(){ + this.set('showDownloadCsvModal',true); + this.set('isExportResultSuccessMessege',false); + this.set('isExportResultFailureMessege',false); + }, + + closeDownloadCsvModal(){ + this.set('showDownloadCsvModal',false); + this.set('isExportResultSuccessMessege',false); + this.set('isExportResultFailureMessege',false); }, saveToHDFS(jobId, pathName){ console.log('saveToHDFS with jobId == ', jobId ); console.log('saveToHDFS with pathName == ', pathName ); - this.sendAction('saveToHDFS', jobId, pathName); + }, - + downloadAsCsv(jobId, pathName){ + console.log('downloadAsCsv with jobId == ', jobId ); + console.log('downloadAsCsv with pathName == ', pathName ); + this.sendAction('downloadAsCsv', jobId, pathName); } } http://git-wip-us.apache.org/repos/asf/ambari/blob/8b22dd01/contrib/views/hive20/src/main/resources/ui/app/components/save-hdfs.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/components/save-hdfs.js b/contrib/views/hive20/src/main/resources/ui/app/components/save-hdfs.js deleted file mode 100644 index 05b3b33..0000000 --- a/contrib/views/hive20/src/main/resources/ui/app/components/save-hdfs.js +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import Ember from 'ember'; - -export default Ember.Component.extend({ - - label: null, - confirmText: 'Confirm', - rejectText: 'Reject', - - jobId: 0, - - savePathName: Ember.computed('jobId', function() { - return 'Worksheet_' + this.get('jobId'); - }), - - labelIcon: null, - confirmIcon: null, - rejectIcon: null, - - closable: true, - titleClass: 'primary', - confirmClass: 'primary', - rejectClass: 'default', - - actions: { - confirm() { - let pathName = $("input.path-name").val(); - this.sendAction('confirm', this.get('jobId'), pathName); - }, - - reject() { - this.sendAction('reject'); - } - } -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/8b22dd01/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 d4c82fa..606b71a 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 @@ -81,6 +81,10 @@ export default Ember.Route.extend({ controller.set('queryResult', model.get('queryResult')); controller.set('currentJobId', null); + controller.set('isExportResultSuccessMessege', false); + controller.set('isExportResultFailureMessege', false); + controller.set('showSaveHdfsModal', false); + }, @@ -348,13 +352,35 @@ export default Ember.Route.extend({ this.get('query').saveToHDFS(jobId, path) .then((data) => { - Ember.run.later(() => { - console.log('successfully saveToHDFS', data); - }, 2 * 1000); + 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); } } http://git-wip-us.apache.org/repos/asf/ambari/blob/8b22dd01/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 d95a2e5..400f78b 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 @@ -51,7 +51,15 @@ export default Ember.Service.extend({ reject(err); }); }); + }, + + + downloadAsCsv(jobId, path){ + let self = this; + return this.get('store').adapterFor('job').downloadAsCsv(jobId, path); + } + }); http://git-wip-us.apache.org/repos/asf/ambari/blob/8b22dd01/contrib/views/hive20/src/main/resources/ui/app/templates/components/export-result.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/templates/components/export-result.hbs b/contrib/views/hive20/src/main/resources/ui/app/templates/components/export-result.hbs new file mode 100644 index 0000000..0b462cb --- /dev/null +++ b/contrib/views/hive20/src/main/resources/ui/app/templates/components/export-result.hbs @@ -0,0 +1,46 @@ +{{! +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +}} + +{{#modal-dialog + close="reject" + translucentOverlay=true + clickOutsideToClose=true + container-class="modal-dialog"}} + <div class="modal-content"> + <div class="modal-header text-{{titleClass}}"> + <button type="button" class="close" {{action "reject"}}><span aria-hidden="true">×</span></button> + </div> + <div class="modal-body"> + <p class="lead">{{#if labelIcon}}{{fa-icon labelIcon size="lg"}}{{/if}} {{label}}</p> + {{input class="form-control path-name" type="text" value=pathName}} + <div> + {{#if isExportResultSuccessMessege}} + <span class="text-success">Successfully done.</span> + {{/if}} + {{#if isExportResultFailureMessege}} + <span class="text-danger">Error encountered.</span> + {{/if}} + + </div> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-{{rejectClass}}" {{action "reject"}}>{{#if rejectIcon}}{{fa-icon rejectIcon}} {{/if}}{{rejectText}}</button> + <button type="button" class="btn btn-{{confirmClass}}" {{action "confirm"}}>{{#if confirmIcon}}{{fa-icon confirmIcon}} {{/if}}{{confirmText}}</button> + </div> + </div> +{{/modal-dialog}} http://git-wip-us.apache.org/repos/asf/ambari/blob/8b22dd01/contrib/views/hive20/src/main/resources/ui/app/templates/components/query-result-table.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/templates/components/query-result-table.hbs b/contrib/views/hive20/src/main/resources/ui/app/templates/components/query-result-table.hbs index 4bda978..4fe6f43 100644 --- a/contrib/views/hive20/src/main/resources/ui/app/templates/components/query-result-table.hbs +++ b/contrib/views/hive20/src/main/resources/ui/app/templates/components/query-result-table.hbs @@ -59,7 +59,7 @@ </div> {{#if showSaveHdfsModal}} - {{save-hdfs + {{export-result confirmText="OK" rejectText="CLOSE" label="Please enter save path and name." @@ -71,11 +71,27 @@ confirmClass="success" confirm="saveToHDFS" reject="closeSaveHdfsModal" + isExportResultSuccessMessege=isExportResultSuccessMessege + isExportResultFailureMessege=isExportResultFailureMessege }} {{/if}} {{#if showDownloadCsvModal}} -Yahoo + {{export-result + confirmText="OK" + rejectText="CLOSE" + label="Download results as CSV" + jobId=jobId + labelIcon="download" + rejectIcon="times" + confirmIcon="check" + closable=false + confirmClass="success" + confirm="downloadAsCsv" + reject="closeDownloadCsvModal" + isExportResultSuccessMessege=isExportResultSuccessMessege + isExportResultFailureMessege=isExportResultFailureMessege + }} {{/if}} {{yield}} http://git-wip-us.apache.org/repos/asf/ambari/blob/8b22dd01/contrib/views/hive20/src/main/resources/ui/app/templates/components/save-hdfs.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/templates/components/save-hdfs.hbs b/contrib/views/hive20/src/main/resources/ui/app/templates/components/save-hdfs.hbs deleted file mode 100644 index 5b53102..0000000 --- a/contrib/views/hive20/src/main/resources/ui/app/templates/components/save-hdfs.hbs +++ /dev/null @@ -1,37 +0,0 @@ -{{! -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -}} - -{{#modal-dialog - close="reject" - translucentOverlay=true - clickOutsideToClose=true - container-class="modal-dialog"}} - <div class="modal-content"> - <div class="modal-header text-{{titleClass}}"> - <button type="button" class="close" {{action "reject"}}><span aria-hidden="true">×</span></button> - </div> - <div class="modal-body"> - <p class="lead">{{#if labelIcon}}{{fa-icon labelIcon size="lg"}}{{/if}} {{label}}</p> - {{input class="form-control path-name" type="text" value=savePathName}} - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-{{rejectClass}}" {{action "reject"}}>{{#if rejectIcon}}{{fa-icon rejectIcon}} {{/if}}{{rejectText}}</button> - <button type="button" class="btn btn-{{confirmClass}}" {{action "confirm"}}>{{#if confirmIcon}}{{fa-icon confirmIcon}} {{/if}}{{confirmText}}</button> - </div> - </div> -{{/modal-dialog}} http://git-wip-us.apache.org/repos/asf/ambari/blob/8b22dd01/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query.hbs b/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query.hbs index 120a045..2138356 100644 --- a/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query.hbs +++ b/contrib/views/hive20/src/main/resources/ui/app/templates/queries/query.hbs @@ -46,6 +46,10 @@ goPrevPage='goPrevPage' expandQueryResultPanel='expandQueryResultPanel' saveToHDFS='saveToHDFS' + downloadAsCsv='downloadAsCsv' + isExportResultSuccessMessege=isExportResultSuccessMessege + isExportResultFailureMessege=isExportResultFailureMessege + showSaveHdfsModal=showSaveHdfsModal }} </div> </div> @@ -91,7 +95,6 @@ </div> {{#if showWorksheetModal}} - {{#modal-dialog translucentOverlay=true clickOutsideToClose=true container-class="modal-dialog modal-sm"}} <div class="modal-content"> <div class="modal-header"> @@ -105,15 +108,12 @@ {{input type="text" class="form-control" id="worksheet-title" placeholder="Title" value=worksheet.title }} </div> </div> - {{#if worksheetModalSuccess }} <div class="text-success">Successfully Saved.</div> {{/if}} {{#if worksheetModalFail }} <div class="text-danger">Error</div> {{/if}} - - </div> </div> @@ -123,12 +123,6 @@ </div> </div> {{/modal-dialog}} - - {{/if}} - - - - {{outlet}}
