fix(services): use the Public URL instead of a manager IP (#1665)

pull/1670/head
Anthony Lapenna 2018-02-21 10:55:51 +01:00 committed by GitHub
parent ae5416583e
commit b5e256c967
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 16 deletions

View File

@ -114,7 +114,7 @@
</span>
</td>
<td>
<a ng-if="item.Ports && item.Ports.length > 0 && $ctrl.swarmManagerIp && p.PublishedPort" ng-repeat="p in item.Ports" class="image-tag" ng-href="http://{{ $ctrl.swarmManagerIp }}:{{ p.PublishedPort }}" target="_blank">
<a ng-if="item.Ports && item.Ports.length > 0 && p.PublishedPort" ng-repeat="p in item.Ports" class="image-tag" ng-href="http://{{ $ctrl.publicUrl }}:{{ p.PublishedPort }}" target="_blank">
<i class="fa fa-external-link" aria-hidden="true"></i> {{ p.PublishedPort }}:{{ p.TargetPort }}
</a>
<span ng-if="!item.Ports || item.Ports.length === 0 || !$ctrl.swarmManagerIp" >-</span>

View File

@ -12,7 +12,7 @@ angular.module('portainer.docker').component('servicesDatatable', {
showOwnershipColumn: '<',
removeAction: '<',
scaleAction: '<',
swarmManagerIp: '<',
publicUrl: '<',
forceUpdateAction: '<',
showForceUpdateButton: '<'
}

View File

@ -9,16 +9,6 @@ angular.module('portainer.docker')
Labels: node.Spec.Labels,
Availability: node.Spec.Availability
};
},
getManagerIP: function(nodes) {
var managerIp;
for (var n in nodes) {
if (undefined === nodes[n].ManagerStatus || nodes[n].ManagerStatus.Reachability !== 'reachable') {
continue;
}
managerIp = nodes[n].ManagerStatus.Addr.split(':')[0];
}
return managerIp;
}
};
}]);

View File

@ -17,7 +17,7 @@
remove-action="removeAction"
scale-action="scaleAction"
force-update-action="forceUpdateAction"
swarm-manager-ip="swarmManagerIP"
public-url="state.publicURL"
show-force-update-button="applicationState.endpoint.apiVersion >= 1.25"
></services-datatable>
</div>

View File

@ -1,6 +1,10 @@
angular.module('portainer.docker')
.controller('ServicesController', ['$q', '$scope', '$state', 'Service', 'ServiceService', 'ServiceHelper', 'Notifications', 'Task', 'Node', 'NodeHelper', 'ModalService',
function ($q, $scope, $state, Service, ServiceService, ServiceHelper, Notifications, Task, Node, NodeHelper, ModalService) {
.controller('ServicesController', ['$q', '$scope', '$state', 'Service', 'ServiceService', 'ServiceHelper', 'Notifications', 'Task', 'Node', 'ModalService', 'EndpointProvider',
function ($q, $scope, $state, Service, ServiceService, ServiceHelper, Notifications, Task, Node, ModalService, EndpointProvider) {
$scope.state = {
publicURL: EndpointProvider.endpointPublicURL()
};
$scope.scaleAction = function scaleService(service) {
var config = ServiceHelper.serviceToConfig(service.Model);
@ -88,7 +92,6 @@ function ($q, $scope, $state, Service, ServiceService, ServiceHelper, Notificati
nodes: Node.query({}).$promise
})
.then(function success(data) {
$scope.swarmManagerIP = NodeHelper.getManagerIP(data.nodes);
$scope.services = data.services.map(function (service) {
var runningTasks = data.tasks.filter(function (task) {
return task.ServiceID === service.ID && task.Status.State === 'running';