|
@@ -14,6 +14,9 @@
|
|
* License for the specific language governing permissions and limitations under
|
|
* License for the specific language governing permissions and limitations under
|
|
* the License.
|
|
* the License.
|
|
*/
|
|
*/
|
|
|
|
+
|
|
|
|
+var lazyloading = require('utils/lazy_loading');
|
|
|
|
+
|
|
module.exports = {
|
|
module.exports = {
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -33,7 +36,7 @@ module.exports = {
|
|
* Example: {header: 'header', dialogMessage: 'message'}
|
|
* Example: {header: 'header', dialogMessage: 'message'}
|
|
* is closed, cancelled or OK is pressed.
|
|
* is closed, cancelled or OK is pressed.
|
|
*/
|
|
*/
|
|
- launchHostsSelectionDialog : function(availableHosts, selectedHosts,
|
|
|
|
|
|
+ launchHostsSelectionDialog : function(initialHosts, selectedHosts,
|
|
selectAtleastOneHost, validComponents, callback, popupDescription) {
|
|
selectAtleastOneHost, validComponents, callback, popupDescription) {
|
|
// set default popup description
|
|
// set default popup description
|
|
var defaultPopupDescription = {
|
|
var defaultPopupDescription = {
|
|
@@ -48,9 +51,10 @@ module.exports = {
|
|
header: popupDescription.header,
|
|
header: popupDescription.header,
|
|
dialogMessage: popupDescription.dialogMessage,
|
|
dialogMessage: popupDescription.dialogMessage,
|
|
warningMessage: null,
|
|
warningMessage: null,
|
|
|
|
+ availableHosts: [],
|
|
onPrimary: function () {
|
|
onPrimary: function () {
|
|
this.set('warningMessage', null);
|
|
this.set('warningMessage', null);
|
|
- var arrayOfSelectedHosts = availableHosts.filterProperty('selected', true).mapProperty('host.id');
|
|
|
|
|
|
+ var arrayOfSelectedHosts = this.get('availableHosts').filterProperty('selected', true).mapProperty('host.id');
|
|
if (selectAtleastOneHost && arrayOfSelectedHosts.length < 1) {
|
|
if (selectAtleastOneHost && arrayOfSelectedHosts.length < 1) {
|
|
this.set('warningMessage', Em.I18n.t('hosts.selectHostsDialog.message.warning'));
|
|
this.set('warningMessage', Em.I18n.t('hosts.selectHostsDialog.message.warning'));
|
|
return;
|
|
return;
|
|
@@ -59,6 +63,9 @@ module.exports = {
|
|
console.debug('(new-selectedHosts)=', arrayOfSelectedHosts);
|
|
console.debug('(new-selectedHosts)=', arrayOfSelectedHosts);
|
|
this.hide();
|
|
this.hide();
|
|
},
|
|
},
|
|
|
|
+ disablePrimary: function () {
|
|
|
|
+ return !this.get('isLoaded');
|
|
|
|
+ }.property('isLoaded'),
|
|
onSecondary: function () {
|
|
onSecondary: function () {
|
|
callback(null);
|
|
callback(null);
|
|
this.hide();
|
|
this.hide();
|
|
@@ -68,7 +75,6 @@ module.exports = {
|
|
controllerBinding: 'App.router.mainServiceInfoConfigsController',
|
|
controllerBinding: 'App.router.mainServiceInfoConfigsController',
|
|
filterText: '',
|
|
filterText: '',
|
|
filterTextPlaceholder: Em.I18n.t('hosts.selectHostsDialog.filter.placeHolder'),
|
|
filterTextPlaceholder: Em.I18n.t('hosts.selectHostsDialog.filter.placeHolder'),
|
|
- availableHosts: availableHosts,
|
|
|
|
filterColumn: null,
|
|
filterColumn: null,
|
|
filterColumns: Ember.A([
|
|
filterColumns: Ember.A([
|
|
Ember.Object.create({id: 'ip', name: 'IP Address', selected: true}),
|
|
Ember.Object.create({id: 'ip', name: 'IP Address', selected: true}),
|
|
@@ -82,9 +88,29 @@ module.exports = {
|
|
showOnlySelectedHosts: false,
|
|
showOnlySelectedHosts: false,
|
|
filterComponents: validComponents,
|
|
filterComponents: validComponents,
|
|
filterComponent: null,
|
|
filterComponent: null,
|
|
|
|
+ isDisabled: function () {
|
|
|
|
+ return !this.get('parentView.isLoaded');
|
|
|
|
+ }.property('parentView.isLoaded'),
|
|
didInsertElement: function(){
|
|
didInsertElement: function(){
|
|
var defaultFilterColumn = this.get('filterColumns').findProperty('selected');
|
|
var defaultFilterColumn = this.get('filterColumns').findProperty('selected');
|
|
this.set('filterColumn', defaultFilterColumn);
|
|
this.set('filterColumn', defaultFilterColumn);
|
|
|
|
+ this.initContent();
|
|
|
|
+ },
|
|
|
|
+ initContent: function () {
|
|
|
|
+ initialHosts.setEach('filtered', true);
|
|
|
|
+ if (initialHosts.length > 100) {
|
|
|
|
+ lazyloading.run({
|
|
|
|
+ destination: this.get('parentView.availableHosts'),
|
|
|
|
+ source: initialHosts,
|
|
|
|
+ context: this.get('parentView'),
|
|
|
|
+ initSize: 50,
|
|
|
|
+ chunkSize: 100,
|
|
|
|
+ delay: 50
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ this.set('parentView.availableHosts', initialHosts);
|
|
|
|
+ this.set('parentView.isLoaded', true);
|
|
|
|
+ }
|
|
},
|
|
},
|
|
filterHosts: function () {
|
|
filterHosts: function () {
|
|
var filterText = this.get('filterText');
|
|
var filterText = this.get('filterText');
|
|
@@ -92,7 +118,7 @@ module.exports = {
|
|
var filterComponent = this.get('filterComponent');
|
|
var filterComponent = this.get('filterComponent');
|
|
var filterColumn = this.get('filterColumn');
|
|
var filterColumn = this.get('filterColumn');
|
|
|
|
|
|
- this.get('availableHosts').forEach(function (host) {
|
|
|
|
|
|
+ this.get('parentView.availableHosts').forEach(function (host) {
|
|
var skip = showOnlySelectedHosts && !host.get('selected');
|
|
var skip = showOnlySelectedHosts && !host.get('selected');
|
|
var value = host.get('host').get(filterColumn.id);
|
|
var value = host.get('host').get(filterColumn.id);
|
|
var hostComponentNames = host.get('hostComponentNames');
|
|
var hostComponentNames = host.get('hostComponentNames');
|
|
@@ -111,12 +137,12 @@ module.exports = {
|
|
}
|
|
}
|
|
host.set('filtered', !skip);
|
|
host.set('filtered', !skip);
|
|
}, this);
|
|
}, this);
|
|
- }.observes('availableHosts', 'filterColumn', 'filterText', 'filterComponent', 'filterComponent.componentName', 'showOnlySelectedHosts'),
|
|
|
|
|
|
+ }.observes('parentView.availableHosts', 'filterColumn', 'filterText', 'filterComponent', 'filterComponent.componentName', 'showOnlySelectedHosts'),
|
|
hostSelectMessage: function () {
|
|
hostSelectMessage: function () {
|
|
- var hosts = this.get('availableHosts');
|
|
|
|
|
|
+ var hosts = this.get('parentView.availableHosts');
|
|
var selectedHosts = hosts.filterProperty('selected', true);
|
|
var selectedHosts = hosts.filterProperty('selected', true);
|
|
return this.t('hosts.selectHostsDialog.selectedHostsLink').format(selectedHosts.get('length'), hosts.get('length'))
|
|
return this.t('hosts.selectHostsDialog.selectedHostsLink').format(selectedHosts.get('length'), hosts.get('length'))
|
|
- }.property('availableHosts.@each.selected'),
|
|
|
|
|
|
+ }.property('parentView.availableHosts.@each.selected'),
|
|
selectFilterColumn: function (event) {
|
|
selectFilterColumn: function (event) {
|
|
if (event != null && event.context != null && event.context.id != null) {
|
|
if (event != null && event.context != null && event.context.id != null) {
|
|
var filterColumn = this.get('filterColumn');
|
|
var filterColumn = this.get('filterColumn');
|
|
@@ -144,7 +170,7 @@ module.exports = {
|
|
},
|
|
},
|
|
allHostsSelected: false,
|
|
allHostsSelected: false,
|
|
toggleSelectAllHosts: function (event) {
|
|
toggleSelectAllHosts: function (event) {
|
|
- this.get('availableHosts').filterProperty('filtered').setEach('selected', this.get('allHostsSelected'));
|
|
|
|
|
|
+ this.get('parentView.availableHosts').filterProperty('filtered').setEach('selected', this.get('allHostsSelected'));
|
|
}.observes('allHostsSelected'),
|
|
}.observes('allHostsSelected'),
|
|
toggleShowSelectedHosts: function () {
|
|
toggleShowSelectedHosts: function () {
|
|
var currentFilter = this.get('filterComponent');
|
|
var currentFilter = this.get('filterComponent');
|