1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-20 13:59:40 +02:00

feat(networks): group networks for swarm endpoints (#3028)

* feat(networks): group networks for swarm endpoints

* fix(networks): display error on networks with 1 sub
This commit is contained in:
xAt0mZ 2019-08-12 16:26:44 +02:00 committed by GitHub
parent 552c897b3b
commit c12ce5a5c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 118 additions and 31 deletions

View file

@ -1,3 +1,5 @@
import _ from 'lodash-es';
angular.module('portainer.docker')
.controller('NetworksDatatableController', ['$scope', '$controller', 'PREDEFINED_NETWORKS', 'DatatableService',
function ($scope, $controller, PREDEFINED_NETWORKS, DatatableService) {
@ -8,6 +10,10 @@ angular.module('portainer.docker')
return PREDEFINED_NETWORKS.includes(item.Name);
};
this.state = Object.assign(this.state, {
expandedItems: []
})
/**
* Do not allow PREDEFINED_NETWORKS to be selected
*/
@ -47,5 +53,26 @@ angular.module('portainer.docker')
}
this.onSettingsRepeaterChange();
};
this.expandItem = function(item, expanded) {
item.Expanded = expanded;
};
this.itemCanExpand = function(item) {
return item.Subs.length > 0;
}
this.hasExpandableItems = function() {
return _.filter(this.state.filteredDataSet, (item) => this.itemCanExpand(item)).length;
};
this.expandAll = function() {
this.state.expandAll = !this.state.expandAll;
_.forEach(this.state.filteredDataSet, (item) => {
if (this.itemCanExpand(item)) {
this.expandItem(item, this.state.expandAll);
}
});
};
}
]);