diff --git a/app/components/templates/templatesController.js b/app/components/templates/templatesController.js index 62d32ae84..ca71e0ab9 100644 --- a/app/components/templates/templatesController.js +++ b/app/components/templates/templatesController.js @@ -68,6 +68,11 @@ function ($scope, $q, $state, $anchorScroll, Config, ContainerService, ImageServ selectedItem = idx; var selectedTemplate = $scope.templates[idx]; $scope.state.selectedTemplate = selectedTemplate; + if (selectedTemplate.Network) { + $scope.formValues.network = _.find($scope.availableNetworks, function(o) { return o.Name === selectedTemplate.Network; }); + } else { + $scope.formValues.network = _.find($scope.availableNetworks, function(o) { return o.Name === "bridge"; }); + } $anchorScroll('selectedTemplate'); } @@ -94,8 +99,6 @@ function ($scope, $q, $state, $anchorScroll, Config, ContainerService, ImageServ networks = NetworkService.filterGlobalNetworks(networks); $scope.globalNetworkCount = networks.length; NetworkService.addPredefinedLocalNetworks(networks); - } else { - $scope.formValues.network = _.find(networks, function(o) { return o.Name === "bridge"; }); } return networks; } diff --git a/app/models/template.js b/app/models/template.js index d65eae553..2849544d7 100644 --- a/app/models/template.js +++ b/app/models/template.js @@ -5,6 +5,7 @@ function TemplateViewModel(data) { this.Image = data.image; this.Registry = data.registry ? data.registry : ''; this.Command = data.command ? data.command : ''; + this.Network = data.network ? data.network : ''; this.Env = data.env ? data.env : []; this.Volumes = data.volumes ? data.volumes : []; this.Ports = [];