2017-05-23 18:56:10 +00:00
|
|
|
angular.module('volume', [])
|
2017-09-21 14:00:53 +00:00
|
|
|
.controller('VolumeController', ['$scope', '$state', '$transition$', 'VolumeService', 'Notifications',
|
|
|
|
function ($scope, $state, $transition$, VolumeService, Notifications) {
|
2017-05-23 18:56:10 +00:00
|
|
|
|
|
|
|
$scope.removeVolume = function removeVolume() {
|
|
|
|
$('#loadingViewSpinner').show();
|
|
|
|
VolumeService.remove($scope.volume)
|
|
|
|
.then(function success(data) {
|
2017-09-21 14:00:53 +00:00
|
|
|
Notifications.success('Volume successfully removed', $transition$.params().id);
|
2017-05-23 18:56:10 +00:00
|
|
|
$state.go('volumes', {});
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to remove volume');
|
|
|
|
})
|
|
|
|
.finally(function final() {
|
|
|
|
$('#loadingViewSpinner').hide();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
function initView() {
|
|
|
|
$('#loadingViewSpinner').show();
|
2017-09-21 14:00:53 +00:00
|
|
|
VolumeService.volume($transition$.params().id)
|
2017-05-23 18:56:10 +00:00
|
|
|
.then(function success(data) {
|
|
|
|
var volume = data;
|
|
|
|
$scope.volume = volume;
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to retrieve volume details');
|
|
|
|
})
|
|
|
|
.finally(function final() {
|
|
|
|
$('#loadingViewSpinner').hide();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
initView();
|
|
|
|
}]);
|