mirror of
https://github.com/portainer/portainer.git
synced 2025-08-02 04:15:28 +02:00
refactor(app): introduce new project structure for the frontend (#1623)
This commit is contained in:
parent
e6422a6d75
commit
27dceadba1
354 changed files with 1518 additions and 1755 deletions
43
app/docker/views/volumes/edit/volumeController.js
Normal file
43
app/docker/views/volumes/edit/volumeController.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
angular.module('portainer.docker')
|
||||
.controller('VolumeController', ['$scope', '$state', '$transition$', 'VolumeService', 'ContainerService', 'Notifications',
|
||||
function ($scope, $state, $transition$, VolumeService, ContainerService, Notifications) {
|
||||
|
||||
$scope.removeVolume = function removeVolume() {
|
||||
VolumeService.remove($scope.volume)
|
||||
.then(function success(data) {
|
||||
Notifications.success('Volume successfully removed', $transition$.params().id);
|
||||
$state.go('docker.volumes', {});
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Notifications.error('Failure', err, 'Unable to remove volume');
|
||||
});
|
||||
};
|
||||
|
||||
function getVolumeDataFromContainer(container, volumeId) {
|
||||
return container.Mounts.find(function(volume) {
|
||||
return volume.Name === volumeId;
|
||||
});
|
||||
}
|
||||
|
||||
function initView() {
|
||||
VolumeService.volume($transition$.params().id)
|
||||
.then(function success(data) {
|
||||
var volume = data;
|
||||
$scope.volume = volume;
|
||||
var containerFilter = { volume: [volume.Id] };
|
||||
return ContainerService.containers(1, containerFilter);
|
||||
})
|
||||
.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');
|
||||
});
|
||||
}
|
||||
|
||||
initView();
|
||||
}]);
|
Loading…
Add table
Add a link
Reference in a new issue