feat(containers): add the ability to filter by state (#410)

pull/412/head
Anthony Lapenna 2016-12-25 22:43:53 +13:00 committed by GitHub
parent ce32ed5b98
commit 03456ddcf8
4 changed files with 7 additions and 4 deletions

View File

@ -85,7 +85,7 @@
<tbody>
<tr dir-paginate="container in (state.filteredContainers = ( containers | filter:state.filter | orderBy:sortType:sortReverse | itemsPerPage: pagination_count))">
<td><input type="checkbox" ng-model="container.Checked" ng-change="selectItem(container)"/></td>
<td><span class="label label-{{ container.Status|containerstatusbadge }}">{{ container.Status|containerstatus }}</span></td>
<td><span class="label label-{{ container.Status|containerstatusbadge }}">{{ container.Status }}</span></td>
<td ng-if="endpointMode.provider === 'DOCKER_SWARM'"><a ui-sref="container({id: container.Id})">{{ container|swarmcontainername}}</a></td>
<td ng-if="endpointMode.provider !== 'DOCKER_SWARM'"><a ui-sref="container({id: container.Id})">{{ container|containername}}</a></td>
<td><a ui-sref="image({id: container.Image})">{{ container.Image }}</a></td>

View File

@ -1,6 +1,6 @@
angular.module('containers', [])
.controller('ContainersController', ['$scope', 'Container', 'ContainerHelper', 'Info', 'Settings', 'Messages', 'Config',
function ($scope, Container, ContainerHelper, Info, Settings, Messages, Config) {
.controller('ContainersController', ['$scope', '$filter', 'Container', 'ContainerHelper', 'Info', 'Settings', 'Messages', 'Config',
function ($scope, $filter, Container, ContainerHelper, Info, Settings, Messages, Config) {
$scope.state = {};
$scope.state.displayAll = Settings.displayAll;
$scope.state.displayIP = false;
@ -23,6 +23,8 @@ function ($scope, Container, ContainerHelper, Info, Settings, Messages, Config)
}
$scope.containers = containers.map(function (container) {
var model = new ContainerViewModel(container);
model.Status = $filter('containerstatus')(model.Status);
if (model.IP) {
$scope.state.displayIP = true;
}

View File

@ -44,7 +44,7 @@ angular.module('portainer.filters', [])
return 'warning';
} else if (status.indexOf('created') !== -1) {
return 'info';
} else if (status.indexOf('exited') !== -1) {
} else if (status.indexOf('stopped') !== -1) {
return 'danger';
}
return 'success';

View File

@ -53,6 +53,7 @@ function ServiceViewModel(data) {
function ContainerViewModel(data) {
this.Id = data.Id;
this.Status = data.Status;
this.State = data.State;
this.Names = data.Names;
// Unavailable in Docker < 1.10
if (data.NetworkSettings && !_.isEmpty(data.NetworkSettings.Networks)) {