|
@@ -642,326 +642,6 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
|
|
|
}
|
|
|
}),
|
|
|
|
|
|
- /**
|
|
|
- * Filter view for name column
|
|
|
- * Based on <code>filters</code> library
|
|
|
- */
|
|
|
- nameFilterView: filters.createTextView({
|
|
|
- column: 1,
|
|
|
- fieldType: 'filter-input-width',
|
|
|
- onChangeValue: function(){
|
|
|
- this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'string');
|
|
|
- }
|
|
|
- }),
|
|
|
-
|
|
|
- /**
|
|
|
- * Filter view for ip column
|
|
|
- * Based on <code>filters</code> library
|
|
|
- */
|
|
|
- ipFilterView: filters.createTextView({
|
|
|
- column: 2,
|
|
|
- fieldType: 'filter-input-width',
|
|
|
- onChangeValue: function(){
|
|
|
- this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'string');
|
|
|
- }
|
|
|
- }),
|
|
|
-
|
|
|
- /**
|
|
|
- * Filter view for rack column
|
|
|
- * Based on <code>filters</code> library
|
|
|
- */
|
|
|
- rackFilterView: filters.createTextView({
|
|
|
- column: 12,
|
|
|
- fieldType: 'filter-input-width rack-input',
|
|
|
- onChangeValue: function(){
|
|
|
- this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'string');
|
|
|
- }
|
|
|
- }),
|
|
|
-
|
|
|
- /**
|
|
|
- * Filter view for Cpu column
|
|
|
- * Based on <code>filters</code> library
|
|
|
- */
|
|
|
- cpuFilterView: filters.createTextView({
|
|
|
- fieldType: 'filter-input-width',
|
|
|
- fieldId: 'cpu_filter',
|
|
|
- column: 3,
|
|
|
- onChangeValue: function(){
|
|
|
- this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'number');
|
|
|
- }
|
|
|
- }),
|
|
|
-
|
|
|
- /**
|
|
|
- * Filter view for Ram column
|
|
|
- * Based on <code>filters</code> library
|
|
|
- */
|
|
|
- ramFilterView: filters.createTextView({
|
|
|
- fieldType: 'filter-input-width',
|
|
|
- fieldId: 'ram_filter',
|
|
|
- column: 4,
|
|
|
- onChangeValue: function () {
|
|
|
- this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'ambari-bandwidth');
|
|
|
- }
|
|
|
- }),
|
|
|
-
|
|
|
- /**
|
|
|
- * Filter view for LoadAverage column
|
|
|
- * Based on <code>filters</code> library
|
|
|
- */
|
|
|
- loadAvgFilterView: filters.createTextView({
|
|
|
- fieldType: 'filter-input-width',
|
|
|
- fieldId: 'load_avg_filter',
|
|
|
- column: 5,
|
|
|
- onChangeValue: function(){
|
|
|
- this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'number');
|
|
|
- }
|
|
|
- }),
|
|
|
-
|
|
|
- /**
|
|
|
- * Filter view for HostComponents column
|
|
|
- * Based on <code>filters</code> library
|
|
|
- */
|
|
|
- componentsFilterView: filters.createComponentView({
|
|
|
-
|
|
|
- column: 6,
|
|
|
-
|
|
|
- /**
|
|
|
- * Inner FilterView. Used just to render component. Value bind to <code>mainview.value</code> property
|
|
|
- * Base methods was implemented in <code>filters.componentFieldView</code>
|
|
|
- */
|
|
|
- filterView: filters.componentFieldView.extend({
|
|
|
- templateName: require('templates/main/host/component_filter'),
|
|
|
-
|
|
|
- /**
|
|
|
- * Master components
|
|
|
- * @returns {Array}
|
|
|
- */
|
|
|
- masterComponents: function () {
|
|
|
- var components = App.MasterComponent.find().rejectProperty('totalCount', 0);
|
|
|
- components.setEach('checkedForHostFilter', false);
|
|
|
- return components;
|
|
|
- }.property('App.router.clusterController.isComponentsStateLoaded'),
|
|
|
-
|
|
|
- /**
|
|
|
- * Slave components
|
|
|
- * @returns {Array}
|
|
|
- */
|
|
|
- slaveComponents: function () {
|
|
|
- var components = App.SlaveComponent.find().rejectProperty('totalCount', 0);
|
|
|
- components.setEach('checkedForHostFilter', false);
|
|
|
- return components;
|
|
|
- }.property('App.router.clusterController.isComponentsStateLoaded'),
|
|
|
-
|
|
|
- /**
|
|
|
- * Client components
|
|
|
- * @returns {Array}
|
|
|
- */
|
|
|
- clientComponents: function () {
|
|
|
- var components = App.ClientComponent.find().rejectProperty('totalCount', 0);
|
|
|
- components.setEach('checkedForHostFilter', false);
|
|
|
- return components;
|
|
|
- }.property('App.router.clusterController.isComponentsStateLoaded'),
|
|
|
-
|
|
|
- /**
|
|
|
- * Checkbox for quick selecting/deselecting of master components
|
|
|
- */
|
|
|
- masterComponentsChecked:false,
|
|
|
- toggleMasterComponents:function () {
|
|
|
- this.get('masterComponents').setEach('checkedForHostFilter', this.get('masterComponentsChecked'));
|
|
|
- }.observes('masterComponentsChecked'),
|
|
|
-
|
|
|
- /**
|
|
|
- * Checkbox for quick selecting/deselecting of slave components
|
|
|
- */
|
|
|
- slaveComponentsChecked:false,
|
|
|
- toggleSlaveComponents:function () {
|
|
|
- this.get('slaveComponents').setEach('checkedForHostFilter', this.get('slaveComponentsChecked'));
|
|
|
- }.observes('slaveComponentsChecked'),
|
|
|
-
|
|
|
- /**
|
|
|
- * Checkbox for quick selecting/deselecting of client components
|
|
|
- */
|
|
|
- clientComponentsChecked: false,
|
|
|
- toggleClientComponents: function() {
|
|
|
- this.get('clientComponents').setEach('checkedForHostFilter', this.get('clientComponentsChecked'));
|
|
|
- }.observes('clientComponentsChecked'),
|
|
|
-
|
|
|
- /**
|
|
|
- * Clear filter.
|
|
|
- * Called by parent view, when user clicks on <code>x</code> button(clear button)
|
|
|
- */
|
|
|
- clearFilter:function() {
|
|
|
- this.set('masterComponentsChecked', false);
|
|
|
- this.set('slaveComponentsChecked', false);
|
|
|
- this.set('clientComponentsChecked', false);
|
|
|
-
|
|
|
- this.get('masterComponents').setEach('checkedForHostFilter', false);
|
|
|
- this.get('slaveComponents').setEach('checkedForHostFilter', false);
|
|
|
- this.get('clientComponents').setEach('checkedForHostFilter', false);
|
|
|
-
|
|
|
- this._super();
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * Onclick handler for <code>Apply filter</code> button
|
|
|
- */
|
|
|
- applyFilter:function() {
|
|
|
- this._super();
|
|
|
- var self = this;
|
|
|
- var chosenComponents = [];
|
|
|
-
|
|
|
- this.get('masterComponents').filterProperty('checkedForHostFilter', true).forEach(function(item){
|
|
|
- chosenComponents.push(item.get('id'));
|
|
|
- });
|
|
|
- this.get('slaveComponents').filterProperty('checkedForHostFilter', true).forEach(function(item){
|
|
|
- chosenComponents.push(item.get('id'));
|
|
|
- });
|
|
|
- this.get('clientComponents').filterProperty('checkedForHostFilter', true).forEach(function(item){
|
|
|
- chosenComponents.push(item.get('id'));
|
|
|
- });
|
|
|
- Em.run.next(function() {
|
|
|
- self.set('value', chosenComponents);
|
|
|
- });
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * Verify that checked checkboxes are equal to value stored in hidden field (components ids list)
|
|
|
- */
|
|
|
- checkComponents: function() {
|
|
|
- var components = this.get('value');
|
|
|
- var self = this;
|
|
|
- if (components) {
|
|
|
- components.forEach(function(componentId) {
|
|
|
- if(!self.tryCheckComponent(self, 'masterComponents', componentId)) {
|
|
|
- if(!self.tryCheckComponent(self, 'slaveComponents', componentId)) {
|
|
|
- self.tryCheckComponent(self, 'clientComponents', componentId);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }.observes('value'),
|
|
|
-
|
|
|
- tryCheckComponent: function(self, category, componentId) {
|
|
|
- var c = self.get(category).findProperty('id', componentId);
|
|
|
- if (c) {
|
|
|
- if (!c.get('checkedForHostFilter')) {
|
|
|
- c.set('checkedForHostFilter', true);
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- }),
|
|
|
- onChangeValue: function(){
|
|
|
- this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'multiple');
|
|
|
- }
|
|
|
- }),
|
|
|
-
|
|
|
- versionsFilterView: filters.wrapperView.extend({
|
|
|
- column: 11,
|
|
|
- filterView: filters.componentFieldView.extend({
|
|
|
- templateName: require('templates/main/host/version_filter'),
|
|
|
- selectedVersion: null,
|
|
|
- selectedStatus: null,
|
|
|
- value: [],
|
|
|
-
|
|
|
- versionSelectView: filters.createSelectView({
|
|
|
- classNames: ['notActive'],
|
|
|
- fieldType: 'filter-input-width',
|
|
|
- filterPropertyName: 'repository_versions/RepositoryVersions/display_name',
|
|
|
- content: function () {
|
|
|
- return [
|
|
|
- {
|
|
|
- value: '',
|
|
|
- label: Em.I18n.t('common.all')
|
|
|
- }
|
|
|
- ].concat(this.get('controller.allHostStackVersions').filterProperty('isVisible', true).mapProperty('displayName').uniq().map(function (version) {
|
|
|
- return {
|
|
|
- value: version,
|
|
|
- label: version
|
|
|
- }
|
|
|
- }));
|
|
|
- }.property('App.router.clusterController.isLoaded', 'controller.allHostStackVersions.length'),
|
|
|
- onChangeValue: function () {
|
|
|
- this.set('parentView.selectedVersion', this.get('value'));
|
|
|
- }
|
|
|
- }),
|
|
|
- statusSelectView: filters.createSelectView({
|
|
|
- classNames: ['notActive'],
|
|
|
- fieldType: 'filter-input-width',
|
|
|
- filterPropertyName: 'HostStackVersions/state',
|
|
|
- content: function () {
|
|
|
- return [
|
|
|
- {
|
|
|
- value: '',
|
|
|
- label: Em.I18n.t('common.all')
|
|
|
- }
|
|
|
- ].concat(App.HostStackVersion.statusDefinition.map(function (status) {
|
|
|
- return {
|
|
|
- value: status,
|
|
|
- label: App.HostStackVersion.formatStatus(status)
|
|
|
- }
|
|
|
- }));
|
|
|
- }.property('App.router.clusterController.isLoaded'),
|
|
|
- onChangeValue: function () {
|
|
|
- this.set('parentView.selectedStatus', this.get('value'));
|
|
|
- }
|
|
|
- }),
|
|
|
- /**
|
|
|
- * Onclick handler for <code>Apply filter</code> button
|
|
|
- */
|
|
|
- applyFilter: function () {
|
|
|
- this._super();
|
|
|
- var self = this;
|
|
|
- var filterProperties = [];
|
|
|
- if (this.get('selectedVersion')) {
|
|
|
- filterProperties.push({
|
|
|
- property: 'repository_versions/RepositoryVersions/display_name',
|
|
|
- value: this.get('selectedVersion')
|
|
|
- });
|
|
|
- }
|
|
|
- if (this.get('selectedStatus')) {
|
|
|
- filterProperties.push({
|
|
|
- property: 'HostStackVersions/state',
|
|
|
- value: this.get('selectedStatus')
|
|
|
- });
|
|
|
- }
|
|
|
- self.set('value', filterProperties);
|
|
|
- },
|
|
|
- /**
|
|
|
- * Clear filter to initial state
|
|
|
- */
|
|
|
- clearFilter: function () {
|
|
|
- this.set('value', []);
|
|
|
- this.get('childViews').forEach(function (view) {
|
|
|
- if (typeof view.clearFilter === "function") view.clearFilter();
|
|
|
- });
|
|
|
- }
|
|
|
- }),
|
|
|
- setValue: function (value) {
|
|
|
- var versionSelectView = this.get('childViews')[0];
|
|
|
-
|
|
|
- //restore selected options in Select views
|
|
|
- versionSelectView.get('childViews').forEach(function (view) {
|
|
|
- var filter = value.findProperty('property', view.get('filterPropertyName'));
|
|
|
- if (filter && view.get('content').findProperty('value', filter.value)) {
|
|
|
- view.set('selected', view.get('content').findProperty('value', filter.value));
|
|
|
- }
|
|
|
- }, this);
|
|
|
- this._super(value);
|
|
|
- },
|
|
|
- onChangeValue: function () {
|
|
|
- this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'sub-resource');
|
|
|
- },
|
|
|
- clearFilter: function () {
|
|
|
- this._super();
|
|
|
- this.get('childViews').forEach(function (view) {
|
|
|
- if (typeof view.clearFilter === "function") view.clearFilter();
|
|
|
- });
|
|
|
- }
|
|
|
- }),
|
|
|
-
|
|
|
/**
|
|
|
* associations between host property and column index
|
|
|
* @type {Array}
|
|
@@ -975,12 +655,6 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
|
|
|
// clean filters stored in-memory and local storage
|
|
|
this.set('filterConditions', []);
|
|
|
this.clearFilterConditionsFromLocalStorage();
|
|
|
- // clean UI
|
|
|
- this.get('_childViews').forEach(function(childView) {
|
|
|
- if (childView['clearFilter']) {
|
|
|
- childView.clearFilter();
|
|
|
- }
|
|
|
- });
|
|
|
// force refresh
|
|
|
this.refresh();
|
|
|
}
|