Skip to content

Commit

Permalink
AMBARI-13235. Incorrect Hosts table filtering after navigating back f…
Browse files Browse the repository at this point in the history
…rom Host Summary (rzang)
  • Loading branch information
Zangr committed Sep 25, 2015
1 parent ac6a255 commit 8b405fa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
5 changes: 4 additions & 1 deletion ambari-web/app/mappers/hosts_mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ App.hostsMapper = App.QuickDataMapper.create({
var alertsSummary = item.alerts_summary;
item.critical_warning_alerts_count = alertsSummary ? (alertsSummary.CRITICAL || 0) + (alertsSummary.WARNING || 0) : 0;
item.cluster_id = clusterName;
item.index = index;
var existingHost = App.Host.find().findProperty('hostName', component.host_name);
var fromHostDetail = App.router.get('currentState.parentState.name') == 'hostDetails';
// There is no need to override existing index in host detail view since old model(already have indexes) will not be cleared.
item.index = (existingHost && fromHostDetail)? existingHost.get('index'): index;

if (stackUpgradeSupport) {
this.config = $.extend(this.config, {
Expand Down
30 changes: 20 additions & 10 deletions ambari-web/app/views/common/sort_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,18 +203,28 @@ var serverWrapperView = Em.View.extend({
* Initialize and save sorting statuses: hostName sorting_asc
*/
loadSortStatuses: function () {
var statuses = [];
var childViews = this.get('childViews');
childViews.forEach(function (childView) {
var sortStatus = (childView.get('name') == 'hostName' && childView.get('status') == 'sorting') ? 'sorting_asc' : childView.get('status');
statuses.push({
name: childView.get('name'),
status: sortStatus
var statuses = App.db.getSortingStatuses(this.get('controller.name'));
if (statuses) {
var sortingColumn = App.db.getSortingStatuses(this.get('controller.name')).find(function(column){ return column.status != 'sorting'})
if (sortingColumn) {
var sortingColumnView = childViews.findProperty('name', sortingColumn.name);
sortingColumnView.set('status', sortingColumn.status);
this.get('controller').set('sortingColumn', sortingColumnView);
}
} else {
statuses = [];
childViews.forEach(function (childView) {
var sortStatus = (childView.get('name') == 'hostName' && childView.get('status') == 'sorting') ? 'sorting_asc' : childView.get('status');
statuses.push({
name: childView.get('name'),
status: sortStatus
});
childView.set('status', sortStatus);
});
childView.set('status', sortStatus);
});
App.db.setSortingStatuses(this.get('controller.name'), statuses);
this.get('controller').set('sortingColumn', childViews.findProperty('name', 'hostName'));
App.db.setSortingStatuses(this.get('controller.name'), statuses);
this.get('controller').set('sortingColumn', childViews.findProperty('name', 'hostName'));
}
},

/**
Expand Down

0 comments on commit 8b405fa

Please sign in to comment.