diff --git a/app/constants.js b/app/constants.js index 464089158..d741e312d 100644 --- a/app/constants.js +++ b/app/constants.js @@ -20,4 +20,5 @@ angular.module('portainer') .constant('DEFAULT_TEMPLATES_URL', 'https://raw.githubusercontent.com/portainer/templates/master/templates.json') .constant('PAGINATION_MAX_ITEMS', 10) .constant('APPLICATION_CACHE_VALIDITY', 3600) -.constant('CONSOLE_COMMANDS_LABEL_PREFIX', 'io.portainer.commands.'); +.constant('CONSOLE_COMMANDS_LABEL_PREFIX', 'io.portainer.commands.') +.constant('PREDEFINED_NETWORKS', ['host', 'bridge', 'none']); diff --git a/app/docker/components/datatables/networks-datatable/networksDatatable.html b/app/docker/components/datatables/networks-datatable/networksDatatable.html index 29b82b6a7..032de038b 100644 --- a/app/docker/components/datatables/networks-datatable/networksDatatable.html +++ b/app/docker/components/datatables/networks-datatable/networksDatatable.html @@ -110,7 +110,7 @@ - + {{ item.Name | truncate:40 }} diff --git a/app/docker/components/datatables/networks-datatable/networksDatatable.js b/app/docker/components/datatables/networks-datatable/networksDatatable.js index a6383af97..ca9112f98 100644 --- a/app/docker/components/datatables/networks-datatable/networksDatatable.js +++ b/app/docker/components/datatables/networks-datatable/networksDatatable.js @@ -1,6 +1,6 @@ angular.module('portainer.docker').component('networksDatatable', { templateUrl: 'app/docker/components/datatables/networks-datatable/networksDatatable.html', - controller: 'GenericDatatableController', + controller: 'NetworksDatatableController', bindings: { titleText: '@', titleIcon: '@', diff --git a/app/docker/components/datatables/networks-datatable/networksDatatableController.js b/app/docker/components/datatables/networks-datatable/networksDatatableController.js new file mode 100644 index 000000000..8c9afd635 --- /dev/null +++ b/app/docker/components/datatables/networks-datatable/networksDatatableController.js @@ -0,0 +1,20 @@ +angular.module('portainer.docker') + .controller('NetworksDatatableController', ['$scope', '$controller', 'PREDEFINED_NETWORKS', + function ($scope, $controller, PREDEFINED_NETWORKS) { + angular.extend(this, $controller('GenericDatatableController', {$scope: $scope})); + + this.disableRemove = function(item) { + return PREDEFINED_NETWORKS.includes(item.Name); + }; + + this.selectAll = function() { + for (var i = 0; i < this.state.filteredDataSet.length; i++) { + var item = this.state.filteredDataSet[i]; + if (!this.disableRemove(item) && item.Checked !== this.state.selectAll) { + item.Checked = this.state.selectAll; + this.selectItem(item); + } + } + }; + } +]); \ No newline at end of file diff --git a/app/docker/views/networks/edit/network.html b/app/docker/views/networks/edit/network.html index 0bad80b2e..2fe01c8e5 100644 --- a/app/docker/views/networks/edit/network.html +++ b/app/docker/views/networks/edit/network.html @@ -20,7 +20,7 @@ ID {{ network.Id }} - + diff --git a/app/docker/views/networks/edit/networkController.js b/app/docker/views/networks/edit/networkController.js index 9ca04092e..c26800ec1 100644 --- a/app/docker/views/networks/edit/networkController.js +++ b/app/docker/views/networks/edit/networkController.js @@ -1,6 +1,6 @@ angular.module('portainer.docker') -.controller('NetworkController', ['$scope', '$state', '$transition$', '$filter', 'NetworkService', 'Container', 'Notifications', 'HttpRequestHelper', -function ($scope, $state, $transition$, $filter, NetworkService, Container, Notifications, HttpRequestHelper) { +.controller('NetworkController', ['$scope', '$state', '$transition$', '$filter', 'NetworkService', 'Container', 'Notifications', 'HttpRequestHelper', 'PREDEFINED_NETWORKS', +function ($scope, $state, $transition$, $filter, NetworkService, Container, Notifications, HttpRequestHelper, PREDEFINED_NETWORKS) { $scope.removeNetwork = function removeNetwork() { NetworkService.remove($transition$.params().id, $transition$.params().id) @@ -25,6 +25,10 @@ function ($scope, $state, $transition$, $filter, NetworkService, Container, Noti }); }; + $scope.allowRemove = function allowRemove(item) { + return !PREDEFINED_NETWORKS.includes(item.Name); + }; + function filterContainersInNetwork(network, containers) { var containersInNetwork = []; containers.forEach(function(container) {