1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-19 13:29:41 +02:00

feat(networks): add ipv6 support (#3717)

* feat(portainer-core): add ipv6 support

* feat(networks): add few changes

* refacto(networks): write regex once

* fix(networks): fix indentation

* refacto(networks): use foreach instead map and pluralize ipvxconfig

* refacto(networks): pluralize ipvxconfig

* feat(networks): support ipv6 with ports

* feat(networks): add an explicit error message

* fix(networks): hide ipv6 configuration when creating macvlan
This commit is contained in:
Maxime Bajeux 2020-04-28 02:34:54 +02:00 committed by GitHub
parent b2f36a3bbe
commit 3de533042d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 262 additions and 72 deletions

View file

@ -34,17 +34,25 @@
<thead>
<tr>
<th>Network</th>
<th>IP Address</th>
<th>
IP Address
<a ng-click="$ctrl.expandAll()" ng-if="$ctrl.hasExpandableItems()">
<i ng-class="{ 'fas fa-angle-down': $ctrl.state.expandAll, 'fas fa-angle-right': !$ctrl.state.expandAll }" aria-hidden="true"></i>
</a>
</th>
<th>Gateway</th>
<th>MAC Address</th>
<th authorization="DockerNetworkDisconnect">Actions</th>
</tr>
</thead>
<tbody>
<tr dir-paginate="(key, value) in $ctrl.dataset | itemsPerPage: $ctrl.state.paginatedItemLimit" ng-class="{ active: item.Checked }">
<td
><a ui-sref="docker.networks.network({ id: key, nodeName: $ctrl.nodeName })">{{ key }}</a></td
>
<tr dir-paginate-start="(key, value) in $ctrl.dataset | itemsPerPage: $ctrl.state.paginatedItemLimit" ng-class="{active: item.Checked}" ng-click="$ctrl.expandItem(value, !value.Expanded)">
<td>
<a ng-if="$ctrl.itemCanExpand(value)">
<i ng-class="{ 'fas fa-angle-down': value.Expanded, 'fas fa-angle-right': !value.Expanded }" class="space-right" aria-hidden="true"></i>
</a>
<a ui-sref="docker.networks.network({ id: key, nodeName: $ctrl.nodeName })">{{ key }}</a>
</td>
<td>{{ value.IPAddress || '-' }}</td>
<td>{{ value.Gateway || '-' }}</td>
<td>{{ value.MacAddress || '-' }}</td>
@ -61,6 +69,15 @@
</button>
</td>
</tr>
<tr dir-paginate-end ng-show="value.Expanded" ng-style="{background: (value.Highlighted ? '#d5e8f3' : '#f5f5f5')}">
<td colspan="1"></td>
<td colspan="1">
{{ value.GlobalIPv6Address }}
</td>
<td colspan="3">
{{ value.IPv6Gateway || '-' }}
</td>
</tr>
<tr ng-if="!$ctrl.dataset">
<td colspan="5" class="text-center text-muted">Loading...</td>
</tr>

View file

@ -1,6 +1,6 @@
angular.module('portainer.docker').component('containerNetworksDatatable', {
templateUrl: './containerNetworksDatatable.html',
controller: 'GenericDatatableController',
controller: 'ContainerNetworksDatatableController',
bindings: {
titleText: '@',
titleIcon: '@',

View file

@ -0,0 +1,81 @@
import _ from 'lodash-es';
angular.module('portainer.docker')
.controller('ContainerNetworksDatatableController', ['$scope', '$controller', 'DatatableService',
function ($scope, $controller, DatatableService) {
angular.extend(this, $controller('GenericDatatableController', { $scope: $scope }));
this.state = Object.assign(this.state, {
expandedItems: [],
expandAll: true
});
this.expandItem = function (item, expanded) {
if (!this.itemCanExpand(item)) {
return;
}
item.Expanded = expanded;
if (!expanded) {
item.Highlighted = false;
}
if (!item.Expanded) {
this.state.expandAll = false;
}
};
this.itemCanExpand = function (item) {
return item.GlobalIPv6Address !== '';
}
this.hasExpandableItems = function () {
return _.filter(this.dataset, (item) => this.itemCanExpand(item)).length;
};
this.expandAll = function () {
this.state.expandAll = !this.state.expandAll;
_.forEach(this.dataset, (item) => {
if (this.itemCanExpand(item)) {
this.expandItem(item, this.state.expandAll);
}
});
};
this.$onInit = function () {
this.setDefaults();
this.prepareTableFromDataset();
this.state.orderBy = this.orderBy;
var storedOrder = DatatableService.getDataTableOrder(this.tableKey);
if (storedOrder !== null) {
this.state.reverseOrder = storedOrder.reverse;
this.state.orderBy = storedOrder.orderBy;
}
var textFilter = DatatableService.getDataTableTextFilters(this.tableKey);
if (textFilter !== null) {
this.state.textFilter = textFilter;
this.onTextFilterChange();
}
var storedFilters = DatatableService.getDataTableFilters(this.tableKey);
if (storedFilters !== null) {
this.filters = storedFilters;
}
if (this.filters && this.filters.state) {
this.filters.state.open = false;
}
var storedSettings = DatatableService.getDataTableSettings(this.tableKey);
if (storedSettings !== null) {
this.settings = storedSettings;
this.settings.open = false;
}
_.forEach(this.dataset, (item) => {
item.Expanded = true;
item.Highlighted = true;
});
};
}
]);