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();
|
||||
$q.all({
|
||||
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
|
||||
})
|
||||
.then(function success(data) {
|
||||
$scope.swarmManagerIP = NodeHelper.getManagerIP(data.nodes);
|
||||
$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';
|
||||
});
|
||||
var allTasks = data.tasks.filter(function (task) {
|
||||
return task.ServiceID === service.ID;
|
||||
});
|
||||
var taskNodes = data.nodes.filter(function (node) {
|
||||
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) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function ServiceViewModel(data, runningTasks, nodes) {
|
||||
function ServiceViewModel(data, runningTasks, allTasks, nodes) {
|
||||
this.Model = data;
|
||||
this.Id = data.ID;
|
||||
this.Tasks = [];
|
||||
|
@ -12,8 +12,8 @@ function ServiceViewModel(data, runningTasks, nodes) {
|
|||
this.Replicas = data.Spec.Mode.Replicated.Replicas;
|
||||
} else {
|
||||
this.Mode = 'global';
|
||||
if (nodes) {
|
||||
this.Replicas = nodes.length;
|
||||
if (allTasks) {
|
||||
this.Replicas = allTasks.length;
|
||||
}
|
||||
}
|
||||
if (runningTasks) {
|
||||
|
|
Loading…
Reference in New Issue