hunk.code_window:     }, function error(err) {
         Messages.error("Failure", err, 'Unable to retrieve application settings');
       });
       $rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) {
         Analytics.trackPage(toState.url);
         Analytics.pageView();
       });
       $rootScope.$state = $state;
     }])
     // This is your docker url that the api will use to make requests
     // You need to set this to the api endpoint without the port i.e. http://192.168.1.9
     .constant('DOCKER_PORT', '') // Docker port, leave as an empty string if no port is required.  If you have a port, prefix it with a ':' i.e. :4243
  
hunk.labels: keep keep keep keep replace replace replace replace replace keep keep keep keep keep
hunk.file_path: app/app.js
hunk.type: replace
file: angular.module('volumes', [])
  .controller('VolumesController', ['$scope', '$state', 'Volume', 'Messages', 'Pagination',
  function ($scope, $state, Volume, Messages, Pagination) {
    $scope.state = {};
    $scope.state.pagination_count = Pagination.getPaginationCount('volumes');
    $scope.state.selectedItemCount = 0;
    $scope.sortType = 'Name';
    $scope.sortReverse = true;
    $scope.config = {
      Name: ''
    };
  
    $scope.changePaginationCount = function() {
      Pagination.setPaginationCount('volumes', $scope.state.pagination_count);
    };
  
    $scope.order = function(sortType) {
      $scope.sortReverse = ($scope.sortType === sortType) ? !$scope.sortReverse : false;
      $scope.sortType = sortType;
    };
  
    $scope.selectItems = function (allSelected) {
      angular.forEach($scope.state.filteredVolumes, function (volume) {
        if (volume.Checked !== allSelected) {
          volume.Checked = allSelected;
          $scope.selectItem(volume);
        }
      });
    };
  
    $scope.selectItem = function (item) {
      if (item.Checked) {
        $scope.state.selectedItemCount++;
      } else {
        $scope.state.selectedItemCount--;
      }
    };
  
    $scope.removeAction = function () {
      $('#loadVolumesSpinner').show();
      var counter = 0;
      var complete = function () {
        counter = counter - 1;
        if (counter === 0) {
          $('#loadVolumesSpinner').hide();
        }
      };
      angular.forEach($scope.volumes, function (volume) {
        if (volume.Checked) {
          counter = counter + 1;
          Volume.remove({name: volume.Name}, function (d) {
            if (d.message) {
              Messages.error("Unable to remove volume", {}, d.message);
            } else {
              Messages.send("Volume deleted", volume.Name);
              var index = $scope.volumes.indexOf(volume);
              $scope.volumes.splice(index, 1);
            }
            complete();
          }, function (e) {
            Messages.error("Failure", e, "Unable to remove volume");
            complete();
          });
        }
      });
    };
  
    function fetchVolumes() {
      $('#loadVolumesSpinner').show();
      Volume.query({}, function (d) {
        $scope.volumes = d.Volumes || [];
        $('#loadVolumesSpinner').hide();
      }, function (e) {
        $('#loadVolumesSpinner').hide();
        Messages.error("Failure", e, "Unable to retrieve volumes");
        $scope.volumes = [];
      });
    }
    fetchVolumes();
  }]);
  