fix(swarm): fix multiple Swarm related issues (#1022)

* fix(containers): fix an issue where the containers would not be displayed

* fix(images): image usage filtering is not compliant with docker/swarm

* fix(volume-creation): do not load volume driver with docker/swarm
pull/1025/head
Anthony Lapenna 2017-07-12 16:11:11 +02:00 committed by GitHub
parent 703e423e04
commit 536ca15e90
6 changed files with 25 additions and 22 deletions

View File

@ -185,7 +185,7 @@ angular.module('containers', [])
}
);
};
function toggleItemSelection(item) {
if (item.Checked) {
$scope.state.selectedItemCount++;
@ -193,7 +193,7 @@ angular.module('containers', [])
$scope.state.selectedItemCount--;
}
}
function updateSelectionFlags() {
$scope.state.noStoppedItemsSelected = true;
$scope.state.noRunningItemsSelected = true;
@ -202,7 +202,7 @@ angular.module('containers', [])
if(!container.Checked) {
return;
}
if(container.Status === 'paused') {
$scope.state.noPausedItemsSelected = false;
} else if(container.Status === 'stopped') {
@ -233,7 +233,7 @@ angular.module('containers', [])
$q.when(provider !== 'DOCKER_SWARM' || SystemService.info())
.then(function success(data) {
if (provider === 'DOCKER_SWARM') {
$scope.swarm_hosts = retrieveSwarmHostsInfo(d);
$scope.swarm_hosts = retrieveSwarmHostsInfo(data);
}
update({all: $scope.state.displayAll ? 1 : 0});
})

View File

@ -70,16 +70,18 @@ function ($scope, $state, VolumeService, SystemService, ResourceControlService,
function initView() {
$('#loadingViewSpinner').show();
SystemService.getVolumePlugins()
.then(function success(data) {
$scope.availableVolumeDrivers = data;
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to retrieve volume drivers');
})
.finally(function final() {
$('#loadingViewSpinner').hide();
});
if ($scope.applicationState.endpoint.mode.provider !== 'DOCKER_SWARM') {
SystemService.getVolumePlugins()
.then(function success(data) {
$scope.availableVolumeDrivers = data;
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to retrieve volume drivers');
})
.finally(function final() {
$('#loadingViewSpinner').hide();
});
}
}
initView();

View File

@ -70,7 +70,7 @@
<div class="pull-right">
<input type="text" id="filter" ng-model="state.filter" placeholder="Filter..." class="form-control input-sm" />
</div>
<span class="btn-group btn-group-sm pull-right" style="margin-right: 20px;">
<span class="btn-group btn-group-sm pull-right" style="margin-right: 20px;" ng-if="applicationState.endpoint.mode.provider !== 'DOCKER_SWARM'">
<label class="btn btn-primary" ng-model="state.containersCountFilter" uib-btn-radio="undefined">
All
</label>
@ -125,7 +125,7 @@
<td><input type="checkbox" ng-model="image.Checked" ng-change="selectItem(image)" /></td>
<td>
<a class="monospaced" ui-sref="image({id: image.Id})">{{ image.Id|truncate:20}}</a>
<span style="margin-left: 10px;" class="label label-warning image-tag" ng-if="::image.Containers === 0">Unused</span></td>
<span style="margin-left: 10px;" class="label label-warning image-tag" ng-if="::image.Containers === 0 && applicationState.endpoint.mode.provider !== 'DOCKER_SWARM'">Unused</span></td>
<td>
<span class="label label-primary image-tag" ng-repeat="tag in (image|repotags)">{{ tag }}</span>
</td>

View File

@ -93,7 +93,8 @@ function ($scope, $state, ImageService, Notifications, Pagination, ModalService)
function fetchImages() {
$('#loadImagesSpinner').show();
ImageService.images()
var endpointProvider = $scope.applicationState.endpoint.mode.provider;
ImageService.images(endpointProvider !== 'DOCKER_SWARM')
.then(function success(data) {
$scope.images = data;
})

View File

@ -3,7 +3,7 @@ function ImageViewModel(data) {
this.Tag = data.Tag;
this.Repository = data.Repository;
this.Created = data.Created;
this.Containers = data.dataUsage.Containers;
this.Containers = data.dataUsage ? data.dataUsage.Containers : 0;
this.Checked = false;
this.RepoTags = data.RepoTags;
this.VirtualSize = data.VirtualSize;

View File

@ -20,11 +20,11 @@ angular.module('portainer.services')
return deferred.promise;
};
service.images = function() {
service.images = function(withUsage) {
var deferred = $q.defer();
$q.all({
dataUsage: SystemService.dataUsage(),
dataUsage: withUsage ? SystemService.dataUsage() : { Images: [] },
images: Image.query({}).$promise
})
.then(function success(data) {
@ -32,7 +32,7 @@ angular.module('portainer.services')
item.dataUsage = data.dataUsage.Images.find(function(usage) {
return item.Id === usage.Id;
});
return new ImageViewModel(item);
});
deferred.resolve(images);