1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-23 15:29:42 +02:00

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

View file

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

View file

@ -70,7 +70,7 @@
<div class="pull-right"> <div class="pull-right">
<input type="text" id="filter" ng-model="state.filter" placeholder="Filter..." class="form-control input-sm" /> <input type="text" id="filter" ng-model="state.filter" placeholder="Filter..." class="form-control input-sm" />
</div> </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"> <label class="btn btn-primary" ng-model="state.containersCountFilter" uib-btn-radio="undefined">
All All
</label> </label>
@ -125,7 +125,7 @@
<td><input type="checkbox" ng-model="image.Checked" ng-change="selectItem(image)" /></td> <td><input type="checkbox" ng-model="image.Checked" ng-change="selectItem(image)" /></td>
<td> <td>
<a class="monospaced" ui-sref="image({id: image.Id})">{{ image.Id|truncate:20}}</a> <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> <td>
<span class="label label-primary image-tag" ng-repeat="tag in (image|repotags)">{{ tag }}</span> <span class="label label-primary image-tag" ng-repeat="tag in (image|repotags)">{{ tag }}</span>
</td> </td>

View file

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

View file

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

View file

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