AMBARI-20216. HiveView2.0: Database and tables info doesn't match after navigating between tabs and landing back on Tables tab. (dipayanb)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0ffa4789 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0ffa4789 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0ffa4789 Branch: refs/heads/branch-feature-AMBARI-12556 Commit: 0ffa4789ad2372859287b8c0264e8b080fd1d8df Parents: 7808134 Author: Dipayan Bhowmick <dipayan.bhowm...@gmail.com> Authored: Wed Mar 1 11:44:14 2017 +0530 Committer: Dipayan Bhowmick <dipayan.bhowm...@gmail.com> Committed: Wed Mar 1 11:44:59 2017 +0530 ---------------------------------------------------------------------- .../main/resources/ui/app/routes/databases.js | 24 ++++++++++++++------ .../ui/app/routes/databases/database/tables.js | 14 ++++++++++-- 2 files changed, 29 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/0ffa4789/contrib/views/hive20/src/main/resources/ui/app/routes/databases.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/routes/databases.js b/contrib/views/hive20/src/main/resources/ui/app/routes/databases.js index 6b0eab2..e5efbe9 100644 --- a/contrib/views/hive20/src/main/resources/ui/app/routes/databases.js +++ b/contrib/views/hive20/src/main/resources/ui/app/routes/databases.js @@ -46,13 +46,24 @@ export default Ember.Route.extend(UILoggerMixin, { }, selectDatabase(model) { - // check if default database is present - let toSelect = model.findBy('name', 'default'); - if (Ember.isEmpty(toSelect)) { - let sortedModel = model.sortBy('name'); - toSelect = sortedModel.get('firstObject'); + let alreadySelected = model.findBy('selected', true); + if (Ember.isEmpty(alreadySelected)) { + // Check if params present + let paramsForDatabase = this.paramsFor('databases.database'); + let toSelect = null; + if (!Ember.isEmpty(paramsForDatabase.databaseId)) { + toSelect = model.findBy('name', paramsForDatabase.databaseId); + } else { + // check if default database is present + toSelect = model.findBy('name', 'default'); + } + + if (Ember.isEmpty(toSelect)) { + let sortedModel = model.sortBy('name'); + toSelect = sortedModel.get('firstObject'); + } + toSelect.set('selected', true); } - toSelect.set('selected', true); }, actions: { @@ -68,7 +79,6 @@ export default Ember.Route.extend(UILoggerMixin, { } this.get('controller').set('databaseToDelete', selectedModel); - if (selectedModel.get('tables.length') > 0) { this.get('controller').set('databaseNotEmpty', true); console.log('database not empty'); http://git-wip-us.apache.org/repos/asf/ambari/blob/0ffa4789/contrib/views/hive20/src/main/resources/ui/app/routes/databases/database/tables.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/resources/ui/app/routes/databases/database/tables.js b/contrib/views/hive20/src/main/resources/ui/app/routes/databases/database/tables.js index 92f483f..d4a39cb 100644 --- a/contrib/views/hive20/src/main/resources/ui/app/routes/databases/database/tables.js +++ b/contrib/views/hive20/src/main/resources/ui/app/routes/databases/database/tables.js @@ -31,8 +31,18 @@ export default Ember.Route.extend({ }, selectTable(model) { let sortedModel = model.sortBy('name'); - let toSelect = sortedModel.get('firstObject'); - toSelect.set('selected', true); + let alreadySelected = sortedModel.findBy('selected', true); + if (Ember.isEmpty(alreadySelected)) { + let paramsForTable = this.paramsFor('databases.database.tables.table'); + let toSelect = null; + if (!Ember.isEmpty(paramsForTable.name)) { + toSelect = sortedModel.findBy('name', paramsForTable.name); + } else { + toSelect = sortedModel.get('firstObject'); + } + + toSelect.set('selected', true); + } }, actions: { tableSelected(table) {