ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [14/50] [abbrv] ambari git commit: AMBARI-19958. Hive View 2.0 - deleting a saved query is buggy (pallavkul)
Date Mon, 13 Feb 2017 21:03:48 GMT
AMBARI-19958. Hive View 2.0 - deleting a saved query is buggy (pallavkul)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 23642958208fe6b3148ac157753edb13b6d31347
Parents: d96d209
Author: pallavkul <pallav.kul@gmail.com>
Authored: Sat Feb 11 16:58:22 2017 +0530
Committer: pallavkul <pallav.kul@gmail.com>
Committed: Sat Feb 11 16:58:22 2017 +0530

----------------------------------------------------------------------
 .../resources/ui/app/adapters/saved-query.js    |  2 +-
 .../resources/ui/app/components/query-editor.js |  2 +-
 .../resources/ui/app/controllers/saved-query.js | 22 +++++++++
 .../resources/ui/app/routes/queries/query.js    | 11 +++--
 .../resources/ui/app/routes/savedqueries.js     | 50 +++++++++++++++-----
 .../resources/ui/app/services/saved-queries.js  |  5 +-
 .../ui/app/templates/queries/query.hbs          |  2 +-
 .../resources/ui/app/templates/savedqueries.hbs |  8 ++--
 8 files changed, 75 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/23642958/contrib/views/hive20/src/main/resources/ui/app/adapters/saved-query.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/adapters/saved-query.js b/contrib/views/hive20/src/main/resources/ui/app/adapters/saved-query.js
index 5ee757b..a25adc7 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/adapters/saved-query.js
+++ b/contrib/views/hive20/src/main/resources/ui/app/adapters/saved-query.js
@@ -21,6 +21,6 @@ import ApplicationAdapter from './application';
 
 export default ApplicationAdapter.extend({
   buildURL(){
-    return this._super(...arguments).replace('/resources','') + '/savedQueries/';
+    return this._super(...arguments).replace('/resources','');
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/23642958/contrib/views/hive20/src/main/resources/ui/app/components/query-editor.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/components/query-editor.js b/contrib/views/hive20/src/main/resources/ui/app/components/query-editor.js
index 7bfe223..3175a35 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/components/query-editor.js
+++ b/contrib/views/hive20/src/main/resources/ui/app/components/query-editor.js
@@ -101,7 +101,7 @@ export default Ember.Component.extend({
       }
     }
 
-    this.sendAction('updateQuery');
+    this.sendAction('updateQuery', query);
 
 
   }.observes('query'),

http://git-wip-us.apache.org/repos/asf/ambari/blob/23642958/contrib/views/hive20/src/main/resources/ui/app/controllers/saved-query.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/controllers/saved-query.js b/contrib/views/hive20/src/main/resources/ui/app/controllers/saved-query.js
new file mode 100644
index 0000000..dc99fd1
--- /dev/null
+++ b/contrib/views/hive20/src/main/resources/ui/app/controllers/saved-query.js
@@ -0,0 +1,22 @@
+/**
+ * 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.Controller.extend({
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/23642958/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 dcf27b4..4f60229 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
@@ -114,7 +114,6 @@ export default Ember.Route.extend({
     controller.set('isVisualExplainQuery', false);
     controller.set('visualExplainJson', null);
 
-
   },
 
 
@@ -122,7 +121,7 @@ export default Ember.Route.extend({
     createQuery(udfName, udfClassname, fileResourceName, fileResourcePath){
       let query = "add jar "+ fileResourcePath + ";\ncreate temporary function " + udfName
+ " as '"+ udfClassname+ "';";
       this.get('controller').set('currentQuery', query);
-      this.get('controller.model').set('currentQuery', query );
+      this.get('controller.model').set('query', query );
     },
 
     changeDbHandler(selectedDBs){
@@ -220,6 +219,7 @@ export default Ember.Route.extend({
 
         self.get('jobs').waitForJobToComplete(data.job.id, 2 * 1000, false)
           .then((status) => {
+
               self.get('controller').set('isJobSuccess', true);
               self.send('getJob', data);
 
@@ -318,8 +318,9 @@ export default Ember.Route.extend({
       });
     },
 
-    updateQuery(){
-      console.log('I am in update query.');
+    updateQuery(query){
+      this.get('controller').set('currentQuery', query);
+      this.get('controller.model').set('query', query);
     },
 
     goNextPage(){
@@ -411,7 +412,7 @@ export default Ember.Route.extend({
       console.log('I am in saveWorksheetModal');
       let newTitle = $('#worksheet-title').val();
 
-      let currentQuery = this.get('controller').get('currentQuery');
+      let currentQuery = this.get('controller.model').get('query');
       let selectedDb = this.get('controller.model').get('selectedDb');
       let owner = this.get('controller.model').get('owner');
       let queryFile = this.get('controller.model').get('queryFile');

http://git-wip-us.apache.org/repos/asf/ambari/blob/23642958/contrib/views/hive20/src/main/resources/ui/app/routes/savedqueries.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/routes/savedqueries.js b/contrib/views/hive20/src/main/resources/ui/app/routes/savedqueries.js
index 7b9cb09..c2a0c8c 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/routes/savedqueries.js
+++ b/contrib/views/hive20/src/main/resources/ui/app/routes/savedqueries.js
@@ -23,11 +23,14 @@ export default Ember.Route.extend({
   savedQueries: Ember.inject.service(),
 
   model() {
-    return this.get('savedQueries').getAllQueries();
+    return this.store.findAll('savedQuery').then(savedQueries => savedQueries.toArray());
   },
 
   setupController(controller, model) {
     this._super(...arguments);
+
+    controller.set('savedQuerylist', model);
+
     controller.set('showDeleteSaveQueryModal', false);
     controller.set('selectedSavedQueryId', null);
   },
@@ -39,19 +42,40 @@ export default Ember.Route.extend({
 
     deleteSavedQuery(){
       let queryId = this.get('controller').get('selectedSavedQueryId');
+      let self = this;
 
       console.log('deleteSavedQuery', queryId);
-      this.get('savedQueries').deleteSaveQuery(queryId)
-        .then((data) => {
-          console.log('Deleted saved query.', data);
-          this.get('controller').set('showDeleteSaveQueryModal', false );
-          //$(window).reload();
-        }, (error) => {
-          console.log("Error encountered", error);
+
+      this.get('store').queryRecord('saved-query', { filter: { id: queryId } }, {reload:
true}).then(function(record) {
+        record.destroyRecord().then(function(data) {
+          self.send('deleteSavedQueryDeclined');
+          self.send('refreshSavedQueryList');
+        })
+      }, (error) => {
+        console.log('error', error);
+      });
+    },
+
+    refreshSavedQueryList(){
+      this.get('store').findAll('saved-query').then(data => {
+        let savedQueryList = [];
+        data.forEach(x => {
+          let localSavedQuery = {
+            'id': x.get('id'),
+            'dataBase': x.get('dataBase'),
+            'title': x.get('title'),
+            'queryFile': x.get('queryFile'),
+            'owner': x.get('owner'),
+            'shortQuery': x.get('shortQuery')
+          };
+          savedQueryList.pushObject(localSavedQuery);
         });
+
+        this.get('controller').set('savedQuerylist',savedQueryList);
+      })
     },
 
-    deleteSavedQuerypDeclined(){
+    deleteSavedQueryDeclined(){
       this.get('controller').set('selectedSavedQueryId', null);
       this.get('controller').set('showDeleteSaveQueryModal', false );
     },
@@ -85,10 +109,10 @@ export default Ember.Route.extend({
 
       let localWs = {
         id: worksheetId,
-        title: savedQuery.title,
-        query: savedQuery.shortQuery,
-        selectedDb : savedQuery.dataBase,
-        owner: savedQuery.owner,
+        title: savedQuery.get('title'),
+        query: savedQuery.get('shortQuery'),
+        selectedDb : savedQuery.get('dataBase'),
+        owner: savedQuery.get('owner'),
         selected: true
       };
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/23642958/contrib/views/hive20/src/main/resources/ui/app/services/saved-queries.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/services/saved-queries.js b/contrib/views/hive20/src/main/resources/ui/app/services/saved-queries.js
index 29ef4b5..80a19f3 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/services/saved-queries.js
+++ b/contrib/views/hive20/src/main/resources/ui/app/services/saved-queries.js
@@ -30,15 +30,16 @@ export default Ember.Service.extend({
   saveQuery(payload){
     return $.ajax({
       type: "POST",
-      url: this.get('store').adapterFor('saved-query').buildURL(),
+      url: this.get('store').adapterFor('saved-query').buildURL() + '/savedQueries/',
       data: JSON.stringify({savedQuery: payload}) ,
       contentType:"application/json; charset=utf-8",
       dataType:"json",
       headers: {'X-Requested-By': 'ambari'}
     })
   },
+
   deleteSaveQuery(id){
-    let deletURL = this.get('store').adapterFor('saved-query').buildURL() + id;
+    let deletURL = this.get('store').adapterFor('saved-query').buildURL()+ '/savedQueries/'
+ id;
 
     return $.ajax({
       type: "DELETE",

http://git-wip-us.apache.org/repos/asf/ambari/blob/23642958/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 2d6c5aa..84992d7 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
@@ -25,7 +25,7 @@
         <span class="expand-button" {{action "expandQueryEdidorPanel" }} >
           {{fa-icon "expand"}}
         </span>
-        {{query-editor query=currentQuery }}
+        {{query-editor query=currentQuery updateQuery='updateQuery' }}
       </div>
       <div class="row query-editor-controls">
         <button class="btn btn-success" {{action "executeQuery" }} disabled={{ worksheet.isQueryRunning}}>{{fa-icon
"check"}} Execute</button>

http://git-wip-us.apache.org/repos/asf/ambari/blob/23642958/contrib/views/hive20/src/main/resources/ui/app/templates/savedqueries.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/templates/savedqueries.hbs b/contrib/views/hive20/src/main/resources/ui/app/templates/savedqueries.hbs
index 36dc982..c3d907d 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/templates/savedqueries.hbs
+++ b/contrib/views/hive20/src/main/resources/ui/app/templates/savedqueries.hbs
@@ -29,7 +29,7 @@
       </tr>
       </thead>
       <tbody>
-      {{#each model.savedQueries as |savedQuery| }}
+      {{#each savedQuerylist as |savedQuery| }}
         <tr>
           <td>{{savedQuery.shortQuery}}</td>
           <td class="break-word">{{savedQuery.title}}</td>
@@ -37,8 +37,8 @@
           <td>{{savedQuery.owner}}</td>
           <td>
               <div class="dropdown">
-                <a class="dropdown-toggle" data-toggle="dropdown">{{fa-icon "cog"}}</a>
-                <ul class="dropdown-menu dropdown-menu-right"">
+                <a class="dropdown-toggle" id="dropdownMenu1121" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="true">{{fa-icon "cog"}}</a>
+                <ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenu">
                   <li><a href="#" {{action "historySavedQuery" savedQuery.id }}
class="text-uppercase">{{fa-icon "history"}} History</a></li>
                   <li><a href="#" {{action "openDeleteSavedQueryModal" savedQuery.id}}
class="text-uppercase">{{fa-icon "remove"}} Delete</a></li>
                   <li><a href="#" {{action "openAsWorksheet" savedQuery }} class="text-uppercase">{{fa-icon
"folder-open-o"}} Open as worksheet</a></li>
@@ -63,7 +63,7 @@
   closable=false
   confirmClass="success"
   confirm="deleteSavedQuery"
-  reject="deleteSavedQuerypDeclined"
+  reject="deleteSavedQueryDeclined"
   }}
 {{/if}}
 


Mime
View raw message