diff --git a/app/components/createContainer/createcontainer.html b/app/components/createContainer/createcontainer.html index 9f6edae53..8ac6a7c84 100644 --- a/app/components/createContainer/createcontainer.html +++ b/app/components/createContainer/createcontainer.html @@ -9,7 +9,7 @@
-
+
@@ -28,7 +28,7 @@
- +
diff --git a/app/components/createService/createservice.html b/app/components/createService/createservice.html index e89dd5a07..3a159fda4 100644 --- a/app/components/createService/createservice.html +++ b/app/components/createService/createservice.html @@ -9,7 +9,7 @@
- +
@@ -23,7 +23,7 @@
- +
diff --git a/app/components/service/service.html b/app/components/service/service.html index 9cf5c4c00..b5d1a8d90 100644 --- a/app/components/service/service.html +++ b/app/components/service/service.html @@ -68,7 +68,8 @@ Image - + diff --git a/app/components/service/serviceController.js b/app/components/service/serviceController.js index cca9cbb64..17e1bbb9f 100644 --- a/app/components/service/serviceController.js +++ b/app/components/service/serviceController.js @@ -1,12 +1,13 @@ angular.module('service', []) -.controller('ServiceController', ['$q', '$scope', '$transition$', '$state', '$location', '$timeout', '$anchorScroll', 'ServiceService', 'ConfigService', 'ConfigHelper', 'SecretService', 'SecretHelper', 'Service', 'ServiceHelper', 'LabelHelper', 'TaskService', 'NodeService', 'Notifications', 'Pagination', 'ModalService', -function ($q, $scope, $transition$, $state, $location, $timeout, $anchorScroll, ServiceService, ConfigService, ConfigHelper, SecretService, SecretHelper, Service, ServiceHelper, LabelHelper, TaskService, NodeService, Notifications, Pagination, ModalService) { +.controller('ServiceController', ['$q', '$scope', '$transition$', '$state', '$location', '$timeout', '$anchorScroll', 'ServiceService', 'ConfigService', 'ConfigHelper', 'SecretService', 'ImageService', 'SecretHelper', 'Service', 'ServiceHelper', 'LabelHelper', 'TaskService', 'NodeService', 'Notifications', 'Pagination', 'ModalService', +function ($q, $scope, $transition$, $state, $location, $timeout, $anchorScroll, ServiceService, ConfigService, ConfigHelper, SecretService, ImageService, SecretHelper, Service, ServiceHelper, LabelHelper, TaskService, NodeService, Notifications, Pagination, ModalService) { $scope.state = {}; $scope.state.pagination_count = Pagination.getPaginationCount('service_tasks'); $scope.tasks = []; $scope.sortType = 'Updated'; $scope.sortReverse = true; + $scope.availableImages = []; $scope.lastVersion = 0; @@ -333,7 +334,8 @@ function ($q, $scope, $transition$, $state, $location, $timeout, $anchorScroll, tasks: TaskService.tasks({ service: [service.Name] }), nodes: NodeService.nodes(), secrets: apiVersion >= 1.25 ? SecretService.secrets() : [], - configs: apiVersion >= 1.30 ? ConfigService.configs() : [] + configs: apiVersion >= 1.30 ? ConfigService.configs() : [], + availableImages: ImageService.images() }); }) .then(function success(data) { @@ -341,6 +343,7 @@ function ($q, $scope, $transition$, $state, $location, $timeout, $anchorScroll, $scope.nodes = data.nodes; $scope.configs = data.configs; $scope.secrets = data.secrets; + $scope.availableImages = ImageService.getUniqueTagListFromImages(data.availableImages); // Set max cpu value var maxCpus = 0; diff --git a/app/directives/imageRegistry/por-image-registry.js b/app/directives/imageRegistry/por-image-registry.js index f8d004967..ccc65cdc9 100644 --- a/app/directives/imageRegistry/por-image-registry.js +++ b/app/directives/imageRegistry/por-image-registry.js @@ -3,6 +3,7 @@ angular.module('portainer').component('porImageRegistry', { controller: 'porImageRegistryController', bindings: { 'image': '=', - 'registry': '=' + 'registry': '=', + 'autoComplete': '<' } }); diff --git a/app/directives/imageRegistry/porImageRegistry.html b/app/directives/imageRegistry/porImageRegistry.html index 3f1dbcd43..7153ad1ae 100644 --- a/app/directives/imageRegistry/porImageRegistry.html +++ b/app/directives/imageRegistry/porImageRegistry.html @@ -1,12 +1,14 @@
- +
- +
-
+
\ No newline at end of file diff --git a/app/directives/imageRegistry/porImageRegistryController.js b/app/directives/imageRegistry/porImageRegistryController.js index 496209be7..b037bcb41 100644 --- a/app/directives/imageRegistry/porImageRegistryController.js +++ b/app/directives/imageRegistry/porImageRegistryController.js @@ -1,27 +1,29 @@ angular.module('portainer') -.controller('porImageRegistryController', ['$q', 'RegistryService', 'DockerHubService', 'Notifications', -function ($q, RegistryService, DockerHubService, Notifications) { - var ctrl = this; + .controller('porImageRegistryController', ['$q', 'RegistryService', 'DockerHubService', 'ImageService', 'Notifications', + function ($q, RegistryService, DockerHubService, ImageService, Notifications) { + var ctrl = this; - function initComponent() { - $q.all({ - registries: RegistryService.registries(), - dockerhub: DockerHubService.dockerhub() - }) - .then(function success(data) { - var dockerhub = data.dockerhub; - var registries = data.registries; - ctrl.availableRegistries = [dockerhub].concat(registries); - if (!ctrl.registry.Id) { - ctrl.registry = dockerhub; - } else { - ctrl.registry = _.find(ctrl.availableRegistries, { 'Id': ctrl.registry.Id }); + function initComponent() { + $q.all({ + registries: RegistryService.registries(), + dockerhub: DockerHubService.dockerhub(), + availableImages: ctrl.autoComplete ? ImageService.images() : [] + }) + .then(function success(data) { + var dockerhub = data.dockerhub; + var registries = data.registries; + ctrl.availableImages = ImageService.getUniqueTagListFromImages(data.availableImages); + ctrl.availableRegistries = [dockerhub].concat(registries); + if (!ctrl.registry.Id) { + ctrl.registry = dockerhub; + } else { + ctrl.registry = _.find(ctrl.availableRegistries, { 'Id': ctrl.registry.Id }); + } + }) + .catch(function error(err) { + Notifications.error('Failure', err, 'Unable to retrieve registries'); + }); } - }) - .catch(function error(err) { - Notifications.error('Failure', err, 'Unable to retrieve registries'); - }); - } - initComponent(); -}]); + initComponent(); + }]); diff --git a/app/services/docker/imageService.js b/app/services/docker/imageService.js index 181de81e3..4ca499fa9 100644 --- a/app/services/docker/imageService.js +++ b/app/services/docker/imageService.js @@ -152,5 +152,14 @@ angular.module('portainer.services') return deferred.promise; }; + service.getUniqueTagListFromImages = function (availableImages) { + return _.flatten(_.map(availableImages, function (image) { + _.remove(image.RepoTags, function (item) { + return item.indexOf('') !== -1; + }); + return image.RepoTags ? _.uniqWith(image.RepoTags, _.isEqual) : []; + })); + }; + return service; }]);