diff --git a/app/docker/filters/filters.js b/app/docker/filters/filters.js index b6f9a71dd..a55419333 100644 --- a/app/docker/filters/filters.js +++ b/app/docker/filters/filters.js @@ -218,17 +218,20 @@ angular.module('portainer.docker') return runningTasks; }; }) -.filter('containerswithstatus', function () { +.filter('runningcontainers', function () { 'use strict'; - return function (containers, status) { - var containersWithStatus = 0; - for (var i = 0; i < containers.length; i++) { - var container = containers[i]; - if (container.Status === status) { - containersWithStatus++; - } - } - return containersWithStatus; + return function runningContainersFilter(containers) { + return containers.filter(function (container) { + return container.State === 'running'; + }).length; + }; +}) +.filter('stoppedcontainers', function () { + 'use strict'; + return function stoppedContainersFilter(containers) { + return containers.filter(function (container) { + return container.State === 'exited'; + }).length; }; }) .filter('imagestotalsize', function () { diff --git a/app/docker/views/dashboard/dashboard.html b/app/docker/views/dashboard/dashboard.html index 86950c43e..2e31750fb 100644 --- a/app/docker/views/dashboard/dashboard.html +++ b/app/docker/views/dashboard/dashboard.html @@ -115,8 +115,8 @@
-
{{ containers | containerswithstatus:'running' }} running
-
{{ containers | containerswithstatus:'stopped' }} stopped
+
{{ containers | runningcontainers }} running
+
{{ containers | stoppedcontainers }} stopped
{{ containers.length }}
Containers