1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-21 14:29:40 +02:00

feat(network-creation): network dropdown for drivers (#1016) (#1062)

This commit is contained in:
Liam Cottam 2017-09-06 14:11:38 +01:00 committed by Anthony Lapenna
parent be4beacdf7
commit b9b32f0526
3 changed files with 65 additions and 5 deletions

View file

@ -1,6 +1,7 @@
angular.module('createNetwork', [])
.controller('CreateNetworkController', ['$scope', '$state', 'Notifications', 'Network', 'LabelHelper',
function ($scope, $state, Notifications, Network, LabelHelper) {
.controller('CreateNetworkController', ['$q', '$scope', '$state', 'PluginService', 'Notifications', 'Network', 'LabelHelper',
function ($q, $scope, $state, PluginService, Notifications, Network, LabelHelper) {
$scope.formValues = {
DriverOptions: [],
Subnet: '',
@ -8,6 +9,8 @@ function ($scope, $state, Notifications, Network, LabelHelper) {
Labels: []
};
$scope.availableNetworkDrivers = [];
$scope.config = {
Driver: 'bridge',
CheckDuplicate: true,
@ -89,4 +92,24 @@ function ($scope, $state, Notifications, Network, LabelHelper) {
var config = prepareConfiguration();
createNetwork(config);
};
function initView() {
$('#loadingViewSpinner').show();
var endpointProvider = $scope.applicationState.endpoint.mode.provider;
var apiVersion = $scope.applicationState.endpoint.apiVersion;
if(endpointProvider !== 'DOCKER_SWARM') {
PluginService.networkPlugins(apiVersion < 1.25)
.then(function success(data){
$scope.availableNetworkDrivers = data;
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to retrieve network drivers');
})
.finally(function final() {
$('#loadingViewSpinner').hide();
});
}
}
initView();
}]);