You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2016/10/24 21:26:23 UTC
ambari git commit: AMBARI-18638. Include an option to upload query in
hive-view (alexantonenko)
Repository: ambari
Updated Branches:
refs/heads/trunk 8356a4e5d -> 1f6d95022
AMBARI-18638. Include an option to upload query in hive-view (alexantonenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1f6d9502
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1f6d9502
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1f6d9502
Branch: refs/heads/trunk
Commit: 1f6d95022006a98af15bc44ef5e0e8bd9e29e527
Parents: 8356a4e
Author: Alex Antonenko <hi...@gmail.com>
Authored: Tue Oct 25 00:26:16 2016 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Tue Oct 25 00:26:16 2016 +0300
----------------------------------------------------------------------
.../ui/hive-web/app/components/upload-query.js | 31 ++++++++++++++
.../ui/hive-web/app/controllers/index.js | 43 +++++++++++++++++++-
.../ui/hive-web/app/initializers/i18n.js | 2 +
.../ui/hive-web/app/templates/index.hbs | 31 +++++++++++++-
.../ui/hive-web/app/components/upload-query.js | 32 +++++++++++++++
.../ui/hive-web/app/controllers/index.js | 38 +++++++++++++++++
.../ui/hive-web/app/initializers/i18n.js | 2 +
.../ui/hive-web/app/templates/index.hbs | 24 +++++++++++
8 files changed, 199 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/1f6d9502/contrib/views/hive-next/src/main/resources/ui/hive-web/app/components/upload-query.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/components/upload-query.js b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/components/upload-query.js
new file mode 100644
index 0000000..4642abf
--- /dev/null
+++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/components/upload-query.js
@@ -0,0 +1,31 @@
+/**
+ * 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 EmberUploader from 'ember-uploader';
+
+export default EmberUploader.FileField.extend({
+
+ attributeBindings: ['id', 'style'],
+ id: 'upload',
+ style: 'display:none',
+ initialize: function() {
+ this.$().on('change', function(e) {
+ this.sendAction('filesUploaded', e.currentTarget.files);
+ }.bind(this));
+ }.on('didInsertElement')
+ });
http://git-wip-us.apache.org/repos/asf/ambari/blob/1f6d9502/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/index.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/index.js b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/index.js
index e67aaed..8250dbb 100644
--- a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/index.js
+++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/controllers/index.js
@@ -1,4 +1,4 @@
-/** * Licensed to the Apache Software Foundation (ASF) under one
+/* * 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
@@ -39,7 +39,6 @@ export default Ember.Controller.extend({
selectedDatabase: Ember.computed.alias('databaseService.selectedDatabase'),
isDatabaseExplorerVisible: true,
canKillSession: Ember.computed.and('model.sessionTag', 'model.sessionActive'),
-
queryProcessTabs: [
Ember.Object.create({
name: Ember.I18n.t('menus.logs'),
@@ -208,6 +207,7 @@ export default Ember.Controller.extend({
return this.createJob(job, originalModel);
},
+
getVisualExplainJson: function (job, originalModel) {
var self = this;
var defer = Ember.RSVP.defer();
@@ -622,6 +622,45 @@ export default Ember.Controller.extend({
query.set('fileContent', updatedContent);
},
+ filesUploaded: (function(files) {
+ var idCounter = 0;
+ return function (files) {
+ var self=this;
+ var name = files[0].name;
+ var i = name.indexOf(".");
+ var title = name.substr(0, i);
+ idCounter++;
+ var defer = Ember.RSVP.defer()
+ var reader = new FileReader();
+
+ reader.onloadstart = function(e) {
+ Ember.$("#uploadProgressModal").modal("show");
+ }
+ reader.onloadend = function(e) {
+ defer.resolve(e.target.result);
+ }
+ reader.onerror = function(e) {
+ self.get('notifyService').error("Upload failed");
+ Ember.$("#uploadProgressModal").modal("hide");
+ }
+ reader.readAsText(files[0]);
+ defer.promise.then(function(data) {
+ var model = self.store.createRecord(constants.namingConventions.savedQuery, {
+ dataBase: self.get('selectedDatabase.name'),
+ title: title,
+ id: 'fixture_upload' + idCounter
+ });
+ return Ember.RSVP.resolve(self.transitionToRoute(constants.namingConventions.subroutes.savedQuery, model)).then(function() {
+ return data;
+ });
+ }). then(function(data) {
+ self.set('openQueries.currentQuery.fileContent',data);
+ Ember.$("#uploadProgressModal").modal("hide");
+ });
+ };
+ }()),
+
+
addQuery: (function () {
var idCounter = 0;
http://git-wip-us.apache.org/repos/asf/ambari/blob/1f6d9502/contrib/views/hive-next/src/main/resources/ui/hive-web/app/initializers/i18n.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/initializers/i18n.js b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/initializers/i18n.js
index cc789e8..a046b35 100644
--- a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/initializers/i18n.js
+++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/initializers/i18n.js
@@ -195,6 +195,7 @@ TRANSLATIONS = {
save: 'Save',
downloadQuery: 'Download',
newQuery: 'New Worksheet',
+ uploadQuery: 'Upload',
newUdf: 'New UDF',
history: 'History',
ok: 'OK',
@@ -297,6 +298,7 @@ TRANSLATIONS = {
},
ui : {
'uploadProgress' : "Upload Progress",
+ 'uploading': "Uploading..",
'uploadFromLocal':"Upload from Local",
'uploadFromHdfs':"Upload from HDFS",
'selectFileType':"Select File Type",
http://git-wip-us.apache.org/repos/asf/ambari/blob/1f6d9502/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/index.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/index.hbs b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/index.hbs
index a06c330..e7cfa96 100644
--- a/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/index.hbs
+++ b/contrib/views/hive-next/src/main/resources/ui/hive-web/app/templates/index.hbs
@@ -15,6 +15,27 @@
* See the License for the specific language governing permissions and
* limitations under the License.
}}
+<div id="uploadProgressModal" class="modal fade" role="dialog" data-backdrop="static">
+ <div class="modal-dialog">
+
+ <!-- Modal content-->
+ <div class="modal-content">
+ <div class="modal-header">
+ <h4 class="modal-title">{{t "hive.ui.uploadProgress"}}</h4>
+ </div>
+ <div class="modal-body">
+ <p>
+ <ul>
+ {{t "hive.ui.uploading"}}
+ </ul>
+ </p>
+ </div>
+ </div>
+
+ </div>
+</div>
+
+
<div id="index-content">
<div class="main-content">
@@ -46,6 +67,11 @@
{{t "buttons.explain"}}
</button>
+ <label for="upload">
+ <span {{bind-attr class=":btn :btn-sm :btn-default"}}>{{t "buttons.uploadQuery"}}</span>
+ {{upload-query filesUploaded="filesUploaded"}}
+ </label>
+
<button type="button" class="btn btn-sm btn-default save-query-as" {{action "saveQuery"}}>{{t "buttons.saveAs"}}</button>
{{render 'insert-udfs'}}
@@ -54,8 +80,9 @@
<button type="button" class="btn btn-sm btn-danger kill-session" {{action "killSession"}}>{{t "buttons.killSession"}}</button>
{{/if}}
- <button type="button" class="btn btn-sm btn-primary pull-right" {{action "addQuery"}}>{{t "buttons.newQuery"}}</button>
- </div>
+ <button type="button" class="btn btn-sm btn-primary pull-right" {{action "addQuery"}}> {{t "buttons.newQuery"}}</button>
+
+ </div>
{{/panel-widget}}
{{#if displayJobTabs}}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1f6d9502/contrib/views/hive/src/main/resources/ui/hive-web/app/components/upload-query.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/components/upload-query.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/components/upload-query.js
new file mode 100644
index 0000000..e9a7ffa
--- /dev/null
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/components/upload-query.js
@@ -0,0 +1,32 @@
+/**
+ * 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 EmberUploader from 'ember-uploader';
+
+export default EmberUploader.FileField.extend({
+
+ attributeBindings: ['id', 'style'],
+ id: 'upload',
+ style: 'display:none',
+ initialize: function() {
+ this.$().on('change', function(e) {
+ this.sendAction('filesUploaded', e.currentTarget.files);
+ }.bind(this));
+ }.on('didInsertElement')
+ });
+
http://git-wip-us.apache.org/repos/asf/ambari/blob/1f6d9502/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/index.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/index.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/index.js
index 7d5f4ae..e7beb77 100644
--- a/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/index.js
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/index.js
@@ -599,6 +599,44 @@ export default Ember.Controller.extend({
query.set('fileContent', updatedContent);
},
+ filesUploaded: (function(files) {
+ var idCounter = 0;
+ return function (files) {
+ var self=this;
+ var name = files[0].name;
+ var i = name.indexOf(".");
+ var title = name.substr(0, i);
+ idCounter++;
+ var defer = Ember.RSVP.defer()
+ var reader = new FileReader();
+
+ reader.onloadstart = function(e) {
+ Ember.$("#uploadProgressModal").modal("show");
+ }
+ reader.onloadend = function(e) {
+ defer.resolve(e.target.result);
+ }
+ reader.onerror = function(e) {
+ self.get('notifyService').error("Upload failed");
+ Ember.$("#uploadProgressModal").modal("hide");
+ }
+ reader.readAsText(files[0]);
+ defer.promise.then(function(data) {
+ var model = self.store.createRecord(constants.namingConventions.savedQuery, {
+ dataBase: self.get('selectedDatabase.name'),
+ title: title,
+ id: 'fixture_upload' + idCounter
+ });
+ return Ember.RSVP.resolve(self.transitionToRoute(constants.namingConventions.subroutes.savedQuery, model)).then(function() {
+ return data;
+ });
+ }). then(function(data) {
+ self.set('openQueries.currentQuery.fileContent',data);
+ Ember.$("#uploadProgressModal").modal("hide");
+ });
+ };
+ }()),
+
addQuery: (function () {
var idCounter = 0;
http://git-wip-us.apache.org/repos/asf/ambari/blob/1f6d9502/contrib/views/hive/src/main/resources/ui/hive-web/app/initializers/i18n.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/initializers/i18n.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/initializers/i18n.js
index aca366f..3f4812b 100644
--- a/contrib/views/hive/src/main/resources/ui/hive-web/app/initializers/i18n.js
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/initializers/i18n.js
@@ -193,6 +193,7 @@ TRANSLATIONS = {
save: 'Save',
downloadQuery: 'Download',
newQuery: 'New Worksheet',
+ uploadQuery: 'Upload',
newUdf: 'New UDF',
history: 'History',
ok: 'OK',
@@ -295,6 +296,7 @@ TRANSLATIONS = {
},
ui : {
'uploadProgress' : "Upload Progress",
+ 'uploading': "Uploading..",
'uploadFromLocal':"Upload from Local",
'uploadFromHdfs':"Upload from HDFS",
'selectFileType':"Select File Type",
http://git-wip-us.apache.org/repos/asf/ambari/blob/1f6d9502/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/index.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/index.hbs b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/index.hbs
index a06c330..b9e5a46 100644
--- a/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/index.hbs
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/index.hbs
@@ -15,6 +15,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
}}
+<div id="uploadProgressModal" class="modal fade" role="dialog" data-backdrop="static">
+ <div class="modal-dialog">
+
+ <!-- Modal content-->
+ <div class="modal-content">
+ <div class="modal-header">
+ <h4 class="modal-title">{{t "hive.ui.uploadProgress"}}</h4>
+ </div>
+ <div class="modal-body">
+ <p>
+ <ul>
+ {{t "hive.ui.uploading"}}
+ </ul>
+ </p>
+ </div>
+ </div>
+
+ </div>
+</div>
<div id="index-content">
<div class="main-content">
@@ -46,6 +65,11 @@
{{t "buttons.explain"}}
</button>
+ <label for="upload">
+ <span {{bind-attr class=":btn :btn-sm :btn-default"}}>{{t "buttons.uploadQuery"}}</span>
+ {{upload-query filesUploaded="filesUploaded"}}
+ </label>
+
<button type="button" class="btn btn-sm btn-default save-query-as" {{action "saveQuery"}}>{{t "buttons.saveAs"}}</button>
{{render 'insert-udfs'}}