ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pallav...@apache.org
Subject ambari git commit: Revert "AMBARI-20357. [Hive2] JS error in udf delete (pallavkul)"
Date Wed, 08 Mar 2017 16:45:19 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 546225f32 -> a307ba7bc


Revert "AMBARI-20357. [Hive2] JS error in udf delete (pallavkul)"

This reverts commit 63dad097a730d6403f052e0083fa0e665de26f25.


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

Branch: refs/heads/branch-2.5
Commit: a307ba7bc86444151c59284f45bce351f16f49f6
Parents: 546225f
Author: pallavkul <pallav.kul@gmail.com>
Authored: Wed Mar 8 22:14:57 2017 +0530
Committer: pallavkul <pallav.kul@gmail.com>
Committed: Wed Mar 8 22:14:57 2017 +0530

----------------------------------------------------------------------
 .../resources/ui/app/components/udf-item.js     | 148 ++++++-------------
 .../resources/ui/app/routes/queries/query.js    |   4 +-
 .../src/main/resources/ui/app/routes/udfs.js    |  18 +--
 .../main/resources/ui/app/routes/udfs/new.js    | 138 +++++++----------
 .../resources/ui/app/services/auto-refresh.js   |   2 +-
 .../ui/app/templates/components/udf-item.hbs    |  26 ++--
 .../main/resources/ui/app/templates/udfs.hbs    |   3 -
 7 files changed, 118 insertions(+), 221 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a307ba7b/contrib/views/hive20/src/main/resources/ui/app/components/udf-item.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/components/udf-item.js b/contrib/views/hive20/src/main/resources/ui/app/components/udf-item.js
index 3e6e623..44f56e5 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/components/udf-item.js
+++ b/contrib/views/hive20/src/main/resources/ui/app/components/udf-item.js
@@ -17,9 +17,8 @@
  */
 
 import Ember from 'ember';
-import UILoggerMixin from '../mixins/ui-logger';
 
-export default Ember.Component.extend(UILoggerMixin, {
+export default Ember.Component.extend({
 
   store: Ember.inject.service(),
 
@@ -31,43 +30,10 @@ export default Ember.Component.extend(UILoggerMixin, {
   showDeleteUdfModal: false,
   expandedValue: null,
   udfId: null,
-  editUdfId: Ember.computed('udf', function () {
-    return this.get('udf.id');
-  }),
-  editUdfName: Ember.computed('udf', function () {
-    return this.get('udf.name');
-  }),
-  editUdfClassName: Ember.computed('udf', function () {
-    return this.get('udf.classname');
-  }),
-  editOwner: Ember.computed('udf', function () {
-    return this.get('udf.owner');
-  }),
-  editFileResource: Ember.computed('udf', function () {
-    return this.get('udf.fileResource');
-  }),
   fileResourceList:[],
   selectedFileResource: null,
   isAddingNewFileResource: false,
 
-  validate(udfName, udfClassName, resourceName, resourcePath){
-    if (Ember.isEmpty(udfName)) {
-      this.get('logger').danger('UDF Name can not be empty.');
-      return false;
-    }
-
-    if (Ember.isEmpty(udfClassName)) {
-      this.get('logger').danger('UDF Class Name can not be empty.');
-      return false;
-    }
-
-    if (Ember.isEmpty(resourceName) || Ember.isEmpty(resourcePath)) {
-      this.get('logger').danger('File Resource can not be empty.');
-      return false;
-    }
-    return true;
-  },
-
   actions: {
     toggleExpandUdf(fileResourceId) {
 
@@ -93,30 +59,14 @@ export default Ember.Component.extend(UILoggerMixin, {
         this.set('expandedEdit', true);
         this.set('valueLoading', true);
 
-        this.get('store').findAll('file-resource').then((data) => {
-          let fileResourceList = [];
-          data.forEach(x => {
-            let localFileResource = {'id': x.get('id'),
-              'name': x.get('name'),
-              'path': x.get('path'),
-              'owner': x.get('owner')
-            };
-            fileResourceList.push(localFileResource);
-          });
+        this.get('store').find('fileResource', fileResourceId).then((data) => {
+          this.set('udfFileResourceName', data.get('name'));
+          this.set('udfFileResourcePath', data.get('path'));
+        });
 
-          fileResourceList.filterBy('id', fileResourceId).map((data) => {
-            this.set('udfFileResourceName', data.name);
-            this.set('udfFileResourcePath', data.path);
 
-                    this.get('store').find('udf', udfId).then((data) => {
-                        this.set('editUdfId', udfId);
-                        this.set('editUdfName', data.get('name'));
-                        this.set('editUdfClassName', data.get('classname'));
-                        this.set('editOwner', data.get('owner'));
-                      });
-          });
-        });
         this.send('setFileResource', fileResourceId);
+
       }
     },
 
@@ -125,38 +75,39 @@ export default Ember.Component.extend(UILoggerMixin, {
     },
 
     saveUDf(name, classname, udfid, udfFileResourceName, udfFileResourcePath){
+
       let self = this;
-      if (this.validate(name, classname, udfFileResourceName, udfFileResourcePath)) {
-        if (!Ember.isEmpty(this.get('selectedFileResource'))) {
-          this.get('store').findRecord('udf', udfid).then(function (resultUdf) {
-            resultUdf.set('name', name);
-            resultUdf.set('classname', classname);
-            resultUdf.set('fileResource', self.get('selectedFileResource').id);
-            resultUdf.save();
-            self.set('expandedEdit', false);
-          });
-        }
-        else {
-
-          let resourcePayload = {"name": udfFileResourceName, "path": udfFileResourcePath};
-
-          this.get('udfService').savefileResource(resourcePayload)
-            .then((data) => {
-              console.log('fileResource is', data.fileResource.id);
-              self.get('store').findRecord('udf', udfid).then(function (resultUdf) {
-
-                resultUdf.set('name', name);
-                resultUdf.set('classname', classname);
-                resultUdf.set('fileResource', data.fileResource.id);
-                resultUdf.save();
-                self.set('expandedEdit', false);
-              });
-            }, (error) => {
-              console.log("Error encountered", error);
+
+      if(!Ember.isEmpty(this.get('selectedFileResource'))){
+        this.get('store').findRecord('udf', udfid).then(function(resultUdf) {
+          resultUdf.set('name', name);
+          resultUdf.set('classname', classname);
+          resultUdf.set('fileResource', self.get('selectedFileResource').id);
+          resultUdf.save();
+          self.set('expandedEdit', false);
+        });
+      } else {
+
+        let resourcePayload = {"name":udfFileResourceName,"path":udfFileResourcePath};
+
+        this.get('udfService').savefileResource(resourcePayload)
+          .then((data) => {
+            console.log('fileResource is', data.fileResource.id);
+            self.get('store').findRecord('udf', udfid).then(function(resultUdf) {
+
+              resultUdf.set('name', name);
+              resultUdf.set('classname', classname);
+              resultUdf.set('fileResource', data.fileResource.id);
+              resultUdf.save();
+              self.set('expandedEdit', false);
             });
-        }
+          }, (error) => {
+            console.log("Error encountered", error);
+          });
       }
+
       this.set('isAddingNewFileResource', false);
+
     },
 
     showRemoveUdfModal(udfId){
@@ -166,7 +117,16 @@ export default Ember.Component.extend(UILoggerMixin, {
     },
 
     removeUdf(){
-      this.sendAction('removeUdf', this.get('udfId') );
+      let self = this;
+      this.get('store').find('udf', this.get('udfId')).then(function(resultUdf) {
+        resultUdf.destroyRecord().then(function() {
+          self.send('cancelUdf');
+          self.sendAction('refreshUdfList');
+        }, function(response) {
+          console.log('UDF NOT deleted', response);
+        });
+        return false;
+      });
     },
 
     cancelUdf(){
@@ -184,22 +144,10 @@ export default Ember.Component.extend(UILoggerMixin, {
     },
 
     setFileResource(fileResourceId){
-      this.get('store').findAll('file-resource').then((data) => {
-        let fileResourceList = [];
-        data.forEach(x => {
-          let localFileResource = {'id': x.get('id'),
-            'name': x.get('name'),
-            'path': x.get('path'),
-            'owner': x.get('owner')
-          };
-          fileResourceList.push(localFileResource);
-        });
-
-        let localSelectedFileResource =  fileResourceList.filterBy('id', fileResourceId);
-        this.set('selectedFileResource',localSelectedFileResource.get('firstObject'));
-      });
-
+      let localSelectedFileResource = this.get('fileResourceList').filterBy('id', fileResourceId);
+      this.set('selectedFileResource',localSelectedFileResource[0]);
     }
+
   }
 
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/a307ba7b/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 6b395ac..80116da 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
@@ -522,7 +522,7 @@ export default Ember.Route.extend(UILoggerMixin, {
       Ember.run.later(() => {
 
       if(this.get('controller.model').get('isQueryDirty')) {
-        this.get('controller.model').set('tabDataToClose', {index:index, id:id});
+        this.get('controller.model').set('tabDataToClose', {index:index, id:id})
         this.send('openWorksheetModal');
       } else {
          this.send('closeWorksheet', index, id);
@@ -627,7 +627,7 @@ export default Ember.Route.extend(UILoggerMixin, {
     closeWorksheetModal(){
       this.get('controller').set('showWorksheetModal', false);
       this.closeWorksheetAfterSave();
-      this.get('controller.model').set('tabDataToClose', null);
+      this.get('controller.model').set('tabDataToClose', null)
   },
 
     expandQueryEdidorPanel(){

http://git-wip-us.apache.org/repos/asf/ambari/blob/a307ba7b/contrib/views/hive20/src/main/resources/ui/app/routes/udfs.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/routes/udfs.js b/contrib/views/hive20/src/main/resources/ui/app/routes/udfs.js
index 5733d5c..138e85f 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/routes/udfs.js
+++ b/contrib/views/hive20/src/main/resources/ui/app/routes/udfs.js
@@ -19,9 +19,6 @@
 import Ember from 'ember';
 
 export default Ember.Route.extend({
-
-  showDeleteUdfModal: false,
-
   model() {
     return this.store.findAll('udf').then(udfs => udfs.toArray());
   },
@@ -51,6 +48,7 @@ export default Ember.Route.extend({
   actions:{
 
     refreshUdfList(){
+
       this.get('store').findAll('udf').then((data) => {
         let udfList = [];
         data.forEach(x => {
@@ -67,20 +65,8 @@ export default Ember.Route.extend({
         this.controllerFor('udfs').set('udflist',udfList);
         this.transitionTo('udfs');
       });
-    },
 
-    removeUdf(udfId){
-      var self = this;
-      let record = this.get('store').peekRecord('udf', udfId );
-      if(record){
-        record.destroyRecord().then(function(){
-          self.send('cancelUdf');
-          self.send('refreshUdfList');
-        })}
-    },
-
-    cancelUdf(){
-      this.set('showDeleteUdfModal', false);
     }
+
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/a307ba7b/contrib/views/hive20/src/main/resources/ui/app/routes/udfs/new.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/routes/udfs/new.js b/contrib/views/hive20/src/main/resources/ui/app/routes/udfs/new.js
index 6207b77..84733e8 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/routes/udfs/new.js
+++ b/contrib/views/hive20/src/main/resources/ui/app/routes/udfs/new.js
@@ -25,26 +25,6 @@ export default Ember.Route.extend(UILoggerMixin, {
 
   },
 
-  validateUDF(udfName, udfClassName){
-    if (Ember.isEmpty(udfName)) {
-      this.get('logger').danger('UDF Name can not be empty.');
-      return false;
-    }
-    if (Ember.isEmpty(udfClassName)) {
-      this.get('logger').danger('UDF Class Name can not be empty.');
-      return false;
-    }
-    return true;
-  },
-
-  validateFileResource(resourceName, resourcePath){
-    if (Ember.isEmpty(resourceName) || Ember.isEmpty(resourcePath)) {
-      this.get('logger').danger('File Resource can not be empty.');
-      return false;
-    }
-    return true;
-  },
-
   udf: Ember.inject.service(),
   store: Ember.inject.service(),
 
@@ -61,7 +41,7 @@ export default Ember.Route.extend(UILoggerMixin, {
                                 };
         fileResourceList.push(localFileResource);
       });
-      fileResourceList.push({'name':'Add New File Resource', 'action':'addNewFileResource'});
+      fileResourceList.push({'name':'Add New File Resource', 'action':'addNewFileResource'})
       controller.set('fileResourceList', fileResourceList);
 
     });
@@ -80,19 +60,52 @@ export default Ember.Route.extend(UILoggerMixin, {
       this.get('controller').set('udfName', udfName);
       this.get('controller').set('udfClassName', udfClassName);
 
+      if(!Ember.isEmpty( this.get('controller').get('resourceId'))){
 
+        let newUDF = this.get('store').createRecord('udf',
+          {name:udfName,
+           classname:udfClassName,
+           fileResource: this.get('controller').get('resourceId')
+          });
 
 
-      if(!Ember.isEmpty( this.get('controller').get('resourceId'))){
+        newUDF.save().then((data) => {
+          console.log('udf saved');
+
+          this.get('store').findAll('udf').then((data) => {
+            let udfList = [];
+            data.forEach(x => {
+              let localUdf = {
+                'id': x.get('id'),
+                'name': x.get('name'),
+                'classname': x.get('classname'),
+                'fileResource': x.get('fileResource'),
+                'owner': x.get('owner')
+              };
+              udfList.pushObject(localUdf);
+            });
+
+            this.controllerFor('udfs').set('udflist',udfList);
+            this.transitionTo('udfs');
+          })
 
-        if (this.validateUDF(udfName, udfClassName)) {
+        });
 
+      } else {
+
+        let resourcePayload = {"name":resourceName,"path":resourcePath};
+
+        var newFileResource = this.get('store').createRecord('file-resource',
+          {name:resourceName,
+            path:resourcePath
+          });
 
+        newFileResource.save().then((data) => {
+          console.log('fileResource is', data.get('id'));
           let newUDF = this.get('store').createRecord('udf',
-            {
-              name: udfName,
-              classname: udfClassName,
-              fileResource: this.get('controller').get('resourceId')
+            {name:udfName,
+              classname:udfClassName,
+              fileResource: data.get('id')
             });
 
           newUDF.save().then((data) => {
@@ -111,66 +124,20 @@ export default Ember.Route.extend(UILoggerMixin, {
                 udfList.pushObject(localUdf);
               });
 
-              this.controllerFor('udfs').set('udflist', udfList);
+              this.controllerFor('udfs').set('udflist',udfList);
               this.transitionTo('udfs');
-            });
-
-          });
-
-        }
-
-      } else {
-
-        let resourcePayload = {"name":resourceName,"path":resourcePath};
-
-        var newFileResource = this.get('store').createRecord('file-resource',
-          {name:resourceName,
-            path:resourcePath
-          });
-
-
-        if (this.validateFileResource(resourceName, resourcePath) && this.validateUDF(udfName,
udfClassName)) {
-
-          newFileResource.save().then((data) => {
-              console.log('fileResource is', data.get('id'));
-              let newUDF = this.get('store').createRecord('udf',
-                {name:udfName,
-                  classname:udfClassName,
-                  fileResource: data.get('id')
-                });
-
-              newUDF.save().then((data) => {
-                  console.log('udf saved');
-
-                  this.get('store').findAll('udf').then((data) => {
-                    let udfList = [];
-                    data.forEach(x => {
-                      let localUdf = {
-                        'id': x.get('id'),
-                        'name': x.get('name'),
-                        'classname': x.get('classname'),
-                        'fileResource': x.get('fileResource'),
-                        'owner': x.get('owner')
-                      };
-                      udfList.pushObject(localUdf);
-                    });
-
-                    this.controllerFor('udfs').set('udflist',udfList);
-                    this.transitionTo('udfs');
-                  });
-                })
-                .catch((error) => {
-                  this.get('logger').danger('Failed to create UDF.', this.extractError(error));
-                  this.transitionTo('udfs');
-
-                });
             })
-            .catch((error) => {
-              this.get('logger').danger('Failed to create File Resource.', this.extractError(error));
-              this.transitionTo('udfs');
-            });
+          })
+          .catch((error) => {
+            this.get('logger').danger('Failed to create UDF.', this.extractError(error));
+            this.transitionTo('udfs');
 
-        }
+          });
+        })
+        .catch((error) => {
+          this.get('logger').danger('Failed to create File Resource.', this.extractError(error));
+          this.transitionTo('udfs');
+        });
 
       }
     },
@@ -186,11 +153,10 @@ export default Ember.Route.extend(UILoggerMixin, {
 
     handleFileResourceChange(filter){
       console.log('filter', filter);
-      if(filter.action === "addNewFileResource"){
+      if(filter.action == "addNewFileResource"){
         this.get('controller').set('isAddingNewFileResource', true);
         this.get('controller').set('resourceName','');
         this.get('controller').set('resourcePath','');
-        this.get('controller').set('resourceId', null);
         this.get('controller').set('selectedFileResource',null);
 
       }else {

http://git-wip-us.apache.org/repos/asf/ambari/blob/a307ba7b/contrib/views/hive20/src/main/resources/ui/app/services/auto-refresh.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/services/auto-refresh.js b/contrib/views/hive20/src/main/resources/ui/app/services/auto-refresh.js
index b3276e7..2e8ec62 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/services/auto-refresh.js
+++ b/contrib/views/hive20/src/main/resources/ui/app/services/auto-refresh.js
@@ -50,7 +50,7 @@ export default Ember.Service.extend({
       databaseRefreshStartingCallback();
       let oldDatabases = this.get('store').peekAll('database').mapBy('name');
       this.get('store').query('database', {}).then((data) => {
-        let deletedDbCount = 0;
+        let deletedDbCount = 0
         let newDatabases = data.mapBy('name');
         oldDatabases.forEach((oldDB) => {
           if (!newDatabases.contains(oldDB)) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/a307ba7b/contrib/views/hive20/src/main/resources/ui/app/templates/components/udf-item.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/templates/components/udf-item.hbs
b/contrib/views/hive20/src/main/resources/ui/app/templates/components/udf-item.hbs
index 929b91a..fec48fb 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/templates/components/udf-item.hbs
+++ b/contrib/views/hive20/src/main/resources/ui/app/templates/components/udf-item.hbs
@@ -39,19 +39,19 @@
 
 {{#if expandedEdit}}
   {{udf-edit
-    udfid=editUdfId
-    name=editUdfName
-    classname=editUdfClassName
-    owner=editOwner
-    fileResource=editFileResource
-    udfFileResourceName=udfFileResourceName
-    udfFileResourcePath=udfFileResourcePath
-    fileResourceList=fileResourceList
-    selectedFileResource=selectedFileResource
-    isAddingNewFileResource=isAddingNewFileResource
-    handleResourceChange='handleResourceChange'
-    cancelEditUdf='cancelEditUdf'
-    saveUDf='saveUDf'
+  udfid=udf.id
+  name=udf.name
+  classname=udf.classname
+  owner=udf.owner
+  fileResource=udf.fileResource
+  udfFileResourceName=udfFileResourceName
+  udfFileResourcePath=udfFileResourcePath
+  fileResourceList=fileResourceList
+  selectedFileResource=selectedFileResource
+  isAddingNewFileResource=isAddingNewFileResource
+  handleResourceChange='handleResourceChange'
+  cancelEditUdf='cancelEditUdf'
+  saveUDf='saveUDf'
   }}
 {{/if}}
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/a307ba7b/contrib/views/hive20/src/main/resources/ui/app/templates/udfs.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/templates/udfs.hbs b/contrib/views/hive20/src/main/resources/ui/app/templates/udfs.hbs
index ffb824e..ef6a01c 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/templates/udfs.hbs
+++ b/contrib/views/hive20/src/main/resources/ui/app/templates/udfs.hbs
@@ -35,10 +35,7 @@
           {{udf-item
           udf=udf
           fileResourceList=fileResourceList
-          showDeleteUdfModal=showDeleteUdfModal
           refreshUdfList='refreshUdfList'
-          removeUdf='removeUdf'
-          cancelUdf='cancelUdf'
           }}
         {{/each}}
       </tbody>


Mime
View raw message