diff --git a/app/portainer/services/api/endpointService.js b/app/portainer/services/api/endpointService.js index a2cc0fef8..870075156 100644 --- a/app/portainer/services/api/endpointService.js +++ b/app/portainer/services/api/endpointService.js @@ -58,10 +58,20 @@ angular.module('portainer.app').factory('EndpointService', [ return Endpoints.remove({ id: endpointID }).$promise; }; - service.createLocalEndpoint = function (name = 'local') { + service.createLocalEndpoint = function (name = 'local', URL = '', PublicURL = '', groupID = 1, tagIds = []) { var deferred = $q.defer(); - FileUploadService.createEndpoint(name, PortainerEndpointCreationTypes.LocalDockerEnvironment, '', '', 1, [], false) + var endpointURL = URL; + if (endpointURL !== '') { + if (endpointURL.indexOf('//./pipe/') == 0) { + // Windows named pipe + endpointURL = 'npipe://' + URL; + } else { + endpointURL = 'unix://' + URL; + } + } + + FileUploadService.createEndpoint(name, PortainerEndpointCreationTypes.LocalDockerEnvironment, endpointURL, PublicURL, groupID, tagIds, false) .then(function success(response) { deferred.resolve(response.data); }) diff --git a/app/portainer/views/endpoints/create/createEndpointController.js b/app/portainer/views/endpoints/create/createEndpointController.js index 728230341..4a2d80e30 100644 --- a/app/portainer/views/endpoints/create/createEndpointController.js +++ b/app/portainer/views/endpoints/create/createEndpointController.js @@ -100,12 +100,18 @@ angular } $scope.addDockerEndpoint = function () { + var name = $scope.formValues.Name; + var URL = $filter('stripprotocol')($scope.formValues.URL); + var publicURL = $scope.formValues.PublicURL; + var groupId = $scope.formValues.GroupId; + var tagIds = $scope.formValues.TagIds; + if ($scope.formValues.ConnectSocket) { - var endpointName = $scope.formValues.Name; + URL = $scope.formValues.SocketPath; $scope.state.actionInProgress = true; - EndpointService.createLocalEndpoint(endpointName) + EndpointService.createLocalEndpoint(name, URL, publicURL, groupId, tagIds) .then(function success() { - Notifications.success('Endpoint created', endpointName); + Notifications.success('Endpoint created', name); $state.go('portainer.endpoints', {}, { reload: true }); }) .catch(function error(err) { @@ -115,11 +121,9 @@ angular $scope.state.actionInProgress = false; }); } else { - var name = $scope.formValues.Name; - var URL = $filter('stripprotocol')($scope.formValues.URL); - var publicURL = $scope.formValues.PublicURL === '' ? URL.split(':')[0] : $scope.formValues.PublicURL; - var groupId = $scope.formValues.GroupId; - var tagIds = $scope.formValues.TagIds; + if (publicURL === '') { + publicURL = URL.split(':')[0]; + } var securityData = $scope.formValues.SecurityFormData; var TLS = securityData.TLS; diff --git a/app/portainer/views/endpoints/create/createendpoint.html b/app/portainer/views/endpoints/create/createendpoint.html index 985b2d76f..4b217b3ea 100644 --- a/app/portainer/views/endpoints/create/createendpoint.html +++ b/app/portainer/views/endpoints/create/createendpoint.html @@ -210,6 +210,42 @@ + +
This field is required.
+