mirror of https://github.com/portainer/portainer
feat(volume-details): show a list of containers using the volume
parent
dc05ad4c8c
commit
925326e8aa
|
@ -73,3 +73,26 @@
|
|||
</rd-widget>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" ng-if="containersUsingVolume.length > 0">
|
||||
<div class="col-lg-12 col-md-12 col-xs-12">
|
||||
<rd-widget>
|
||||
<rd-widget-header icon="fa-server" title="Containers using volume"></rd-widget-header>
|
||||
<rd-widget-body classes="no-padding">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<th>Container Name</th>
|
||||
<th>Mounted At</th>
|
||||
<th>Read-only</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="container in containersUsingVolume">
|
||||
<td><a ui-sref="container({id: container.Id})">{{ container | containername }}</a></td>
|
||||
<td>{{ container.volumeData.Destination }}</td>
|
||||
<td>{{ !container.volumeData.RW }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</rd-widget-body>
|
||||
</rd-widget>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
angular.module('volume', [])
|
||||
.controller('VolumeController', ['$scope', '$state', '$transition$', 'VolumeService', 'Notifications',
|
||||
function ($scope, $state, $transition$, VolumeService, Notifications) {
|
||||
.controller('VolumeController', ['$scope', '$state', '$transition$', 'VolumeService', 'ContainerService', 'Notifications',
|
||||
function ($scope, $state, $transition$, VolumeService, ContainerService, Notifications) {
|
||||
|
||||
$scope.removeVolume = function removeVolume() {
|
||||
$('#loadingViewSpinner').show();
|
||||
|
@ -16,6 +16,12 @@ function ($scope, $state, $transition$, VolumeService, Notifications) {
|
|||
$('#loadingViewSpinner').hide();
|
||||
});
|
||||
};
|
||||
|
||||
function getVolumeDataFromContainer(container, volumeId) {
|
||||
return container.Mounts.find(function(volume) {
|
||||
return volume.Name === volumeId;
|
||||
});
|
||||
}
|
||||
|
||||
function initView() {
|
||||
$('#loadingViewSpinner').show();
|
||||
|
@ -23,6 +29,18 @@ function ($scope, $state, $transition$, VolumeService, Notifications) {
|
|||
.then(function success(data) {
|
||||
var volume = data;
|
||||
$scope.volume = volume;
|
||||
return ContainerService.containers(1, {
|
||||
filters: {
|
||||
volume: [volume.Id]
|
||||
}
|
||||
});
|
||||
})
|
||||
.then(function success(data) {
|
||||
var containers = data.map(function(container) {
|
||||
container.volumeData = getVolumeDataFromContainer(container, $scope.volume.Id);
|
||||
return container;
|
||||
});
|
||||
$scope.containersUsingVolume = containers;
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Notifications.error('Failure', err, 'Unable to retrieve volume details');
|
||||
|
|
|
@ -20,8 +20,8 @@ angular.module('portainer.services')
|
|||
|
||||
service.containers = function(all, filters) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
Container.query({ all: all, filters: filters ? filters : {} }).$promise
|
||||
filters.all = all;
|
||||
Container.query(filters).$promise
|
||||
.then(function success(data) {
|
||||
var containers = data.map(function (item) {
|
||||
return new ContainerViewModel(item);
|
||||
|
|
Loading…
Reference in New Issue