mirror of https://github.com/portainer/portainer
fix(services): Fix invalid replica count for global services (#1353)
parent
407f0f5807
commit
b9e535d7a5
|
@ -97,19 +97,22 @@ function ($q, $scope, $transition$, $state, Service, ServiceService, ServiceHelp
|
||||||
$('#loadServicesSpinner').show();
|
$('#loadServicesSpinner').show();
|
||||||
$q.all({
|
$q.all({
|
||||||
services: Service.query({}).$promise,
|
services: Service.query({}).$promise,
|
||||||
tasks: Task.query({filters: {'desired-state': ['running']}}).$promise,
|
tasks: Task.query({filters: {'desired-state': ['running','accepted']}}).$promise,
|
||||||
nodes: Node.query({}).$promise
|
nodes: Node.query({}).$promise
|
||||||
})
|
})
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
$scope.swarmManagerIP = NodeHelper.getManagerIP(data.nodes);
|
$scope.swarmManagerIP = NodeHelper.getManagerIP(data.nodes);
|
||||||
$scope.services = data.services.map(function (service) {
|
$scope.services = data.services.map(function (service) {
|
||||||
var serviceTasks = data.tasks.filter(function (task) {
|
var runningTasks = data.tasks.filter(function (task) {
|
||||||
return task.ServiceID === service.ID && task.Status.State === 'running';
|
return task.ServiceID === service.ID && task.Status.State === 'running';
|
||||||
});
|
});
|
||||||
|
var allTasks = data.tasks.filter(function (task) {
|
||||||
|
return task.ServiceID === service.ID;
|
||||||
|
});
|
||||||
var taskNodes = data.nodes.filter(function (node) {
|
var taskNodes = data.nodes.filter(function (node) {
|
||||||
return node.Spec.Availability === 'active' && node.Status.State === 'ready';
|
return node.Spec.Availability === 'active' && node.Status.State === 'ready';
|
||||||
});
|
});
|
||||||
return new ServiceViewModel(service, serviceTasks, taskNodes);
|
return new ServiceViewModel(service, runningTasks, allTasks, taskNodes);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(function error(err) {
|
.catch(function error(err) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
function ServiceViewModel(data, runningTasks, nodes) {
|
function ServiceViewModel(data, runningTasks, allTasks, nodes) {
|
||||||
this.Model = data;
|
this.Model = data;
|
||||||
this.Id = data.ID;
|
this.Id = data.ID;
|
||||||
this.Tasks = [];
|
this.Tasks = [];
|
||||||
|
@ -12,8 +12,8 @@ function ServiceViewModel(data, runningTasks, nodes) {
|
||||||
this.Replicas = data.Spec.Mode.Replicated.Replicas;
|
this.Replicas = data.Spec.Mode.Replicated.Replicas;
|
||||||
} else {
|
} else {
|
||||||
this.Mode = 'global';
|
this.Mode = 'global';
|
||||||
if (nodes) {
|
if (allTasks) {
|
||||||
this.Replicas = nodes.length;
|
this.Replicas = allTasks.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (runningTasks) {
|
if (runningTasks) {
|
||||||
|
|
Loading…
Reference in New Issue