|
@@ -21,10 +21,12 @@ var filters = require('views/common/filter_view');
|
|
var sort = require('views/common/sort_view');
|
|
var sort = require('views/common/sort_view');
|
|
var date = require('utils/date');
|
|
var date = require('utils/date');
|
|
|
|
|
|
-App.MainHostView = App.TableView.extend(App.TableServerProvider, {
|
|
|
|
|
|
+App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
|
|
templateName:require('templates/main/host'),
|
|
templateName:require('templates/main/host'),
|
|
|
|
|
|
tableName: 'Hosts',
|
|
tableName: 'Hosts',
|
|
|
|
+ updaterBinding: 'App.router.updateController',
|
|
|
|
+ filterConditions: [],
|
|
|
|
|
|
/**
|
|
/**
|
|
* Select/deselect all visible hosts flag
|
|
* Select/deselect all visible hosts flag
|
|
@@ -36,16 +38,15 @@ App.MainHostView = App.TableView.extend(App.TableServerProvider, {
|
|
* Contains all selected hosts on cluster
|
|
* Contains all selected hosts on cluster
|
|
*/
|
|
*/
|
|
selectedHosts: [],
|
|
selectedHosts: [],
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * total number of installed hosts
|
|
|
|
|
|
+ * Request error data
|
|
*/
|
|
*/
|
|
- totalCount: function () {
|
|
|
|
- return this.get('controller.hostsCountMap')['TOTAL'] || 0;
|
|
|
|
- }.property('controller.hostsCountMap'),
|
|
|
|
|
|
+ requestError: null,
|
|
|
|
|
|
- filteredCount: function () {
|
|
|
|
- return this.get('controller.filteredCount');
|
|
|
|
- }.property('controller.filteredCount'),
|
|
|
|
|
|
+ colspan: function () {
|
|
|
|
+ return App.get('supports.stackUpgrade') ? 11 : 10;
|
|
|
|
+ }.property("App.supports.stackUpgrade"),
|
|
|
|
|
|
/**
|
|
/**
|
|
* List of hosts in cluster
|
|
* List of hosts in cluster
|
|
@@ -75,20 +76,6 @@ App.MainHostView = App.TableView.extend(App.TableServerProvider, {
|
|
this.propertyDidChange('pageContent');
|
|
this.propertyDidChange('pageContent');
|
|
}.observes('requestError'),
|
|
}.observes('requestError'),
|
|
|
|
|
|
- /**
|
|
|
|
- * Contains content to show on the current page of data page view
|
|
|
|
- * @type {Array}
|
|
|
|
- */
|
|
|
|
- pageContent: function () {
|
|
|
|
- var content = this.get('filteredContent');
|
|
|
|
- if (content.length > this.get('endIndex') - this.get('startIndex') + 1) {
|
|
|
|
- content = content.slice(0, this.get('endIndex') - this.get('startIndex') + 1);
|
|
|
|
- }
|
|
|
|
- return content.sort(function (a, b) {
|
|
|
|
- return a.get('index') - b.get('index');
|
|
|
|
- });
|
|
|
|
- }.property('filteredCount'),
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* flag to toggle displaying selected hosts counter
|
|
* flag to toggle displaying selected hosts counter
|
|
*/
|
|
*/
|
|
@@ -104,6 +91,38 @@ App.MainHostView = App.TableView.extend(App.TableServerProvider, {
|
|
return this.t('hosts.filters.filteredHostsInfo').format(this.get('filteredCount'), this.get('totalCount'));
|
|
return this.t('hosts.filters.filteredHostsInfo').format(this.get('filteredCount'), this.get('totalCount'));
|
|
}.property('filteredCount', 'totalCount'),
|
|
}.property('filteredCount', 'totalCount'),
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * request latest data filtered by new parameters
|
|
|
|
+ * called when trigger property(<code>refreshTriggers</code>) is changed
|
|
|
|
+ */
|
|
|
|
+ refresh: function () {
|
|
|
|
+ var self = this;
|
|
|
|
+ this.set('filteringComplete', false);
|
|
|
|
+ var updaterMethodName = this.get('updater.tableUpdaterMap')[this.get('tableName')];
|
|
|
|
+ this.get('updater')[updaterMethodName](function () {
|
|
|
|
+ self.set('filteringComplete', true);
|
|
|
|
+ self.propertyDidChange('pageContent');
|
|
|
|
+ }, function() {
|
|
|
|
+ self.set('requestError', arguments);
|
|
|
|
+ });
|
|
|
|
+ return true;
|
|
|
|
+ },
|
|
|
|
+ /**
|
|
|
|
+ * reset filters value by column to which filter belongs
|
|
|
|
+ * @param columns {Array}
|
|
|
|
+ */
|
|
|
|
+ resetFilterByColumns: function (columns) {
|
|
|
|
+ var filterConditions = this.get('filterConditions');
|
|
|
|
+ columns.forEach(function (iColumn) {
|
|
|
|
+ var filterCondition = filterConditions.findProperty('iColumn', iColumn);
|
|
|
|
+
|
|
|
|
+ if (filterCondition) {
|
|
|
|
+ filterCondition.value = '';
|
|
|
|
+ this.saveFilterConditions(filterCondition.iColumn, filterCondition.value, filterCondition.type, filterCondition.skipFilter);
|
|
|
|
+ }
|
|
|
|
+ }, this);
|
|
|
|
+ },
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Return pagination information displayed on the page
|
|
* Return pagination information displayed on the page
|
|
* @type {String}
|
|
* @type {String}
|
|
@@ -158,7 +177,7 @@ App.MainHostView = App.TableView.extend(App.TableServerProvider, {
|
|
var self = this;
|
|
var self = this;
|
|
if (this.get('parentView.startIndex') === 1 || this.get('parentView.startIndex') === 0) {
|
|
if (this.get('parentView.startIndex') === 1 || this.get('parentView.startIndex') === 0) {
|
|
Ember.run.next(function () {
|
|
Ember.run.next(function () {
|
|
- self.get('parentView').updateViewProperty();
|
|
|
|
|
|
+ self.get('parentView').updatePagination();
|
|
});
|
|
});
|
|
} else {
|
|
} else {
|
|
Ember.run.next(function () {
|
|
Ember.run.next(function () {
|
|
@@ -172,24 +191,6 @@ App.MainHostView = App.TableView.extend(App.TableServerProvider, {
|
|
this.set('controller.startIndex', this.get('startIndex'));
|
|
this.set('controller.startIndex', this.get('startIndex'));
|
|
}.observes('startIndex'),
|
|
}.observes('startIndex'),
|
|
|
|
|
|
- /**
|
|
|
|
- * Calculates default value for startIndex property after applying filter or changing displayLength
|
|
|
|
- */
|
|
|
|
- updatePaging: function (controller, property) {
|
|
|
|
- var displayLength = this.get('displayLength');
|
|
|
|
- var filteredContentLength = this.get('filteredCount');
|
|
|
|
- if (property == 'displayLength' && this.get('filteringComplete')) {
|
|
|
|
- this.set('startIndex', Math.min(1, filteredContentLength));
|
|
|
|
- } else if (!filteredContentLength) {
|
|
|
|
- this.set('startIndex', 0);
|
|
|
|
- } else if (this.get('startIndex') > filteredContentLength) {
|
|
|
|
- this.set('startIndex', Math.floor((filteredContentLength - 1) / displayLength) * displayLength + 1);
|
|
|
|
- } else if (!this.get('startIndex')) {
|
|
|
|
- this.set('startIndex', 1);
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
-
|
|
|
|
clearFiltersObs: function() {
|
|
clearFiltersObs: function() {
|
|
var self = this;
|
|
var self = this;
|
|
Em.run.next(function() {
|
|
Em.run.next(function() {
|
|
@@ -210,14 +211,6 @@ App.MainHostView = App.TableView.extend(App.TableServerProvider, {
|
|
this.addObserver('pageContent.@each.selected', this, this.selectedHostsObserver);
|
|
this.addObserver('pageContent.@each.selected', this, this.selectedHostsObserver);
|
|
},
|
|
},
|
|
|
|
|
|
- /**
|
|
|
|
- * get query parameters computed in controller
|
|
|
|
- * @param {bool} flag should non-filters params be skipped
|
|
|
|
- * @return {Array}
|
|
|
|
- */
|
|
|
|
- getQueryParameters: function (flag) {
|
|
|
|
- return this.get('controller').getQueryParameters(flag);
|
|
|
|
- },
|
|
|
|
/**
|
|
/**
|
|
* stub for filter function in TableView
|
|
* stub for filter function in TableView
|
|
*/
|
|
*/
|
|
@@ -232,7 +225,8 @@ App.MainHostView = App.TableView.extend(App.TableServerProvider, {
|
|
this.set('controller.isCountersUpdating', true);
|
|
this.set('controller.isCountersUpdating', true);
|
|
this.get('controller').updateStatusCounters();
|
|
this.get('controller').updateStatusCounters();
|
|
this.addObserver('filteringComplete', this, this.overlayObserver);
|
|
this.addObserver('filteringComplete', this, this.overlayObserver);
|
|
- this.addObserver('displayLength', this, this.updatePaging);
|
|
|
|
|
|
+ this.addObserver('startIndex', this, 'updatePagination');
|
|
|
|
+ this.addObserver('displayLength', this, 'updatePagination');
|
|
this.addObserver('filteredCount', this, this.updatePaging);
|
|
this.addObserver('filteredCount', this, this.updatePaging);
|
|
this.overlayObserver();
|
|
this.overlayObserver();
|
|
},
|
|
},
|
|
@@ -243,15 +237,6 @@ App.MainHostView = App.TableView.extend(App.TableServerProvider, {
|
|
}
|
|
}
|
|
}.observes('tableFilteringComplete'),
|
|
}.observes('tableFilteringComplete'),
|
|
|
|
|
|
- /**
|
|
|
|
- * synchronize properties of view with controller to generate query parameters
|
|
|
|
- */
|
|
|
|
- updateViewProperty: function () {
|
|
|
|
- this.get('controller.viewProperties').findProperty('key', 'displayLength').set('viewValue', this.get('displayLength'));
|
|
|
|
- this.get('controller.viewProperties').findProperty('key', 'startIndex').set('viewValue', this.get('startIndex'));
|
|
|
|
- this.refresh();
|
|
|
|
- }.observes('startIndex'),
|
|
|
|
-
|
|
|
|
willDestroyElement: function() {
|
|
willDestroyElement: function() {
|
|
this.set('controller.isCountersUpdating', false);
|
|
this.set('controller.isCountersUpdating', false);
|
|
},
|
|
},
|
|
@@ -383,7 +368,7 @@ App.MainHostView = App.TableView.extend(App.TableServerProvider, {
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case 'f':
|
|
case 'f':
|
|
- queryParams = this.getQueryParameters(true).filter(function (obj) {
|
|
|
|
|
|
+ queryParams = this.get('controller').getQueryParameters(true).filter(function (obj) {
|
|
return !(obj.key == 'page_size' || obj.key == 'from');
|
|
return !(obj.key == 'page_size' || obj.key == 'from');
|
|
});
|
|
});
|
|
break;
|
|
break;
|
|
@@ -1081,11 +1066,5 @@ App.MainHostView = App.TableView.extend(App.TableServerProvider, {
|
|
*/
|
|
*/
|
|
colPropAssoc: function () {
|
|
colPropAssoc: function () {
|
|
return this.get('controller.colPropAssoc');
|
|
return this.get('controller.colPropAssoc');
|
|
- }.property('controller.colPropAssoc'),
|
|
|
|
-
|
|
|
|
- resetStartIndex: function () {
|
|
|
|
- if (this.get('controller.resetStartIndex') && this.get('filteredCount') > 0) {
|
|
|
|
- this.set('startIndex', 1);
|
|
|
|
- }
|
|
|
|
- }.observes('controller.resetStartIndex')
|
|
|
|
|
|
+ }.property('controller.colPropAssoc')
|
|
});
|
|
});
|