Repository: ambari Updated Branches: refs/heads/branch-2.5 a98e1b661 -> bfb0af81c
AMBARI-20009. HiveView2.0: Table list under DB panel on Query tab appears only if clicked on db name and Not clear how to set the database (Venkata Sairam via pallavkul) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/bfb0af81 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/bfb0af81 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/bfb0af81 Branch: refs/heads/branch-2.5 Commit: bfb0af81cff6539c08836162b16894793152d096 Parents: a98e1b6 Author: pallavkul <[email protected]> Authored: Wed Feb 22 19:11:22 2017 +0530 Committer: pallavkul <[email protected]> Committed: Wed Feb 22 19:12:52 2017 +0530 ---------------------------------------------------------------------- .../main/resources/ui/app/routes/queries/new.js | 1 - .../resources/ui/app/routes/queries/query.js | 43 +++++++++++++------- 2 files changed, 29 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/bfb0af81/contrib/views/hive20/src/main/resources/ui/app/routes/queries/new.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/routes/queries/new.js b/contrib/views/hive20/src/main/resources/ui/app/routes/queries/new.js index 5a869c2..7bd2214 100644 --- a/contrib/views/hive20/src/main/resources/ui/app/routes/queries/new.js +++ b/contrib/views/hive20/src/main/resources/ui/app/routes/queries/new.js @@ -27,7 +27,6 @@ export default Ember.Route.extend({ id: newWorksheetName, title: newWorksheetTitle, //query: 'select 1;', - selectedDb : 'default', //owner: 'admin', selected: true }); http://git-wip-us.apache.org/repos/asf/ambari/blob/bfb0af81/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 7860af1..64f38ab 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 @@ -75,6 +75,7 @@ export default Ember.Route.extend(UILoggerMixin, { } else { this.transitionTo('queries.query' + lastResultRoute); } + return dbmodel; }, model(params) { @@ -93,24 +94,22 @@ export default Ember.Route.extend(UILoggerMixin, { this._super(...arguments); this.get("tezViewInfo").getTezViewInfo(); - let self = this; - let alldatabases = this.store.findAll('database'); + let self = this, selectedDb; + let alldatabases = this.store.peekAll('database'); controller.set('alldatabases',alldatabases); - let selecteDBName = model.get('selectedDb'); + selectedDb = this.checkIfDeafultDatabaseExists(alldatabases); let selectedTablesModels =[]; let selectedMultiDb = []; - - selectedTablesModels.pushObject( - { - 'dbname': selecteDBName , - 'tables': this.store.query('table', {databaseId: selecteDBName}), + if(selectedDb) { + selectedTablesModels.pushObject({ + 'dbname': selectedDb , + 'tables': this.store.query('table', {databaseId: selectedDb}), 'isSelected': true - } - ) - - selectedMultiDb.pushObject(selecteDBName); + }) + selectedMultiDb.pushObject(selectedDb); + } controller.set('worksheet', model); @@ -139,7 +138,23 @@ export default Ember.Route.extend(UILoggerMixin, { controller.set('tabs', tabs); }, - + checkIfDeafultDatabaseExists(alldatabases){ + let defaultDB = alldatabases.findBy('name', 'default'), selectedDb; + if(defaultDB) { + selectedDb = defaultDB.get("name"); + this.get('controller.model').set('selectedDb', selectedDb); + } + return selectedDb; + }, + setSelectedDB(selectedDBs) { + let selectedDb = this.get('controller.model').get('selectedDb'); + if(selectedDBs && selectedDBs.indexOf(selectedDb) === -1) { + this.get('controller.model').set('selectedDb', selectedDBs[0]); + } + else if(selectedDBs.length === 0) { + this.get('controller.model').set('selectedDb', null); + } + }, actions: { resetDefaultWorksheet(){ @@ -161,7 +176,7 @@ export default Ember.Route.extend(UILoggerMixin, { let self = this; let selectedTablesModels =[]; let selectedMultiDb = []; - + this.setSelectedDB(selectedDBs); selectedDBs.forEach(function(db, index){ selectedTablesModels.pushObject( {
