diff --git a/app/docker/views/containers/create/createContainerController.js b/app/docker/views/containers/create/createContainerController.js index ddddda3ad..2498c4245 100644 --- a/app/docker/views/containers/create/createContainerController.js +++ b/app/docker/views/containers/create/createContainerController.js @@ -1,6 +1,6 @@ angular.module('portainer.docker') -.controller('CreateContainerController', ['$q', '$scope', '$state', '$timeout', '$transition$', '$filter', 'Container', 'ContainerHelper', 'Image', 'ImageHelper', 'Volume', 'NetworkService', 'ResourceControlService', 'Authentication', 'Notifications', 'ContainerService', 'ImageService', 'FormValidator', 'ModalService', 'RegistryService', 'SystemService', 'SettingsService', 'HttpRequestHelper', -function ($q, $scope, $state, $timeout, $transition$, $filter, Container, ContainerHelper, Image, ImageHelper, Volume, NetworkService, ResourceControlService, Authentication, Notifications, ContainerService, ImageService, FormValidator, ModalService, RegistryService, SystemService, SettingsService, HttpRequestHelper) { +.controller('CreateContainerController', ['$q', '$scope', '$state', '$timeout', '$transition$', '$filter', 'Container', 'ContainerHelper', 'Image', 'ImageHelper', 'Volume', 'NetworkService', 'ResourceControlService', 'Authentication', 'Notifications', 'ContainerService', 'ImageService', 'FormValidator', 'ModalService', 'RegistryService', 'SystemService', 'SettingsService', 'PluginService', 'HttpRequestHelper', +function ($q, $scope, $state, $timeout, $transition$, $filter, Container, ContainerHelper, Image, ImageHelper, Volume, NetworkService, ResourceControlService, Authentication, Notifications, ContainerService, ImageService, FormValidator, ModalService, RegistryService, SystemService, SettingsService, PluginService, HttpRequestHelper) { $scope.create = create; @@ -19,7 +19,9 @@ function ($q, $scope, $state, $timeout, $transition$, $filter, Container, Contai MemoryLimit: 0, MemoryReservation: 0, NodeName: null, - capabilities: [] + capabilities: [], + LogDriverName: '', + LogDriverOpts: [] }; $scope.extraNetworks = {}; @@ -110,6 +112,14 @@ function ($q, $scope, $state, $timeout, $transition$, $filter, Container, Contai $scope.config.HostConfig.Devices.splice(index, 1); }; + $scope.addLogDriverOpt = function() { + $scope.formValues.LogDriverOpts.push({ name: '', value: ''}); + }; + + $scope.removeLogDriverOpt = function(index) { + $scope.formValues.LogDriverOpts.splice(index, 1); + }; + $scope.fromContainerMultipleNetworks = false; function prepareImageConfig(config) { @@ -257,6 +267,23 @@ function ($q, $scope, $state, $timeout, $transition$, $filter, Container, Contai } } + function prepareLogDriver(config) { + var logOpts = {}; + if ($scope.formValues.LogDriverName) { + config.HostConfig.LogConfig = { Type: $scope.formValues.LogDriverName }; + if ($scope.formValues.LogDriverName !== 'none') { + $scope.formValues.LogDriverOpts.forEach(function (opt) { + if (opt.name) { + logOpts[opt.name] = opt.value; + } + }); + if (Object.keys(logOpts).length !== 0 && logOpts.constructor === Object) { + config.HostConfig.LogConfig.Config = logOpts; + } + } + } + } + function prepareCapabilities(config) { var allowed = $scope.formValues.capabilities.filter(function(item) {return item.allowed === true;}); var notAllowed = $scope.formValues.capabilities.filter(function(item) {return item.allowed === false;}); @@ -278,6 +305,7 @@ function ($q, $scope, $state, $timeout, $transition$, $filter, Container, Contai prepareLabels(config); prepareDevices(config); prepareResources(config); + prepareLogDriver(config); prepareCapabilities(config); return config; } @@ -568,6 +596,11 @@ function ($q, $scope, $state, $timeout, $transition$, $filter, Container, Contai Notifications.error('Failure', err, 'Unable to retrieve application settings'); }); + PluginService.loggingPlugins(apiVersion < 1.25) + .then(function success(loggingDrivers) { + $scope.availableLoggingDrivers = loggingDrivers; + }); + var userDetails = Authentication.getUserDetails(); $scope.isAdmin = userDetails.role === 1; } diff --git a/app/docker/views/containers/create/createcontainer.html b/app/docker/views/containers/create/createcontainer.html index a14c8f1d4..3f61e44fb 100644 --- a/app/docker/views/containers/create/createcontainer.html +++ b/app/docker/views/containers/create/createcontainer.html @@ -146,7 +146,7 @@