mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 23:39:41 +02:00
feat(volume-details): show a list of containers using the volume
This commit is contained in:
parent
dc05ad4c8c
commit
925326e8aa
3 changed files with 45 additions and 4 deletions
|
@ -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');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue