2017-05-23 18:56:10 +00:00
|
|
|
angular.module('volume', [])
|
2017-07-12 07:51:51 +00:00
|
|
|
.controller('VolumeController', ['$scope', '$state', '$stateParams', 'VolumeService', 'Notifications',
|
|
|
|
function ($scope, $state, $stateParams, VolumeService, Notifications) {
|
2017-05-23 18:56:10 +00:00
|
|
|
|
|
|
|
$scope.removeVolume = function removeVolume() {
|
|
|
|
$('#loadingViewSpinner').show();
|
|
|
|
VolumeService.remove($scope.volume)
|
|
|
|
.then(function success(data) {
|
|
|
|
Notifications.success('Volume successfully removed', $stateParams.id);
|
|
|
|
$state.go('volumes', {});
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to remove volume');
|
|
|
|
})
|
|
|
|
.finally(function final() {
|
|
|
|
$('#loadingViewSpinner').hide();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
function initView() {
|
|
|
|
$('#loadingViewSpinner').show();
|
|
|
|
VolumeService.volume($stateParams.id)
|
|
|
|
.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();
|
|
|
|
}]);
|