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>
|
</rd-widget>
|
||||||
</div>
|
</div>
|
||||||
</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', [])
|
angular.module('volume', [])
|
||||||
.controller('VolumeController', ['$scope', '$state', '$transition$', 'VolumeService', 'Notifications',
|
.controller('VolumeController', ['$scope', '$state', '$transition$', 'VolumeService', 'ContainerService', 'Notifications',
|
||||||
function ($scope, $state, $transition$, VolumeService, Notifications) {
|
function ($scope, $state, $transition$, VolumeService, ContainerService, Notifications) {
|
||||||
|
|
||||||
$scope.removeVolume = function removeVolume() {
|
$scope.removeVolume = function removeVolume() {
|
||||||
$('#loadingViewSpinner').show();
|
$('#loadingViewSpinner').show();
|
||||||
|
@ -17,12 +17,30 @@ function ($scope, $state, $transition$, VolumeService, Notifications) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function getVolumeDataFromContainer(container, volumeId) {
|
||||||
|
return container.Mounts.find(function(volume) {
|
||||||
|
return volume.Name === volumeId;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function initView() {
|
function initView() {
|
||||||
$('#loadingViewSpinner').show();
|
$('#loadingViewSpinner').show();
|
||||||
VolumeService.volume($transition$.params().id)
|
VolumeService.volume($transition$.params().id)
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
var volume = data;
|
var volume = data;
|
||||||
$scope.volume = volume;
|
$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) {
|
.catch(function error(err) {
|
||||||
Notifications.error('Failure', err, 'Unable to retrieve volume details');
|
Notifications.error('Failure', err, 'Unable to retrieve volume details');
|
||||||
|
|
|
@ -20,8 +20,8 @@ angular.module('portainer.services')
|
||||||
|
|
||||||
service.containers = function(all, filters) {
|
service.containers = function(all, filters) {
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
|
filters.all = all;
|
||||||
Container.query({ all: all, filters: filters ? filters : {} }).$promise
|
Container.query(filters).$promise
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
var containers = data.map(function (item) {
|
var containers = data.map(function (item) {
|
||||||
return new ContainerViewModel(item);
|
return new ContainerViewModel(item);
|
||||||
|
|
Loading…
Reference in New Issue