{"size": 3096, "ext": "js", "max_stars_repo_path": "src/main/webapp/app/unprotect/unprotect-controller.js", "max_stars_repo_name": "delirium-software/RPSP", "max_stars_repo_stars_event_min_datetime": "2015-05-12T10:10:37.000Z", "max_stars_repo_stars_event_max_datetime": "2017-06-19T18:58:55.000Z", "max_issues_repo_path": "src/main/webapp/app/unprotect/unprotect-controller.js", "max_issues_repo_name": "emccode/RPSP", "max_issues_repo_issues_event_min_datetime": "2016-03-31T15:47:27.000Z", "max_issues_repo_issues_event_max_datetime": "2016-06-08T07:44:33.000Z", "max_forks_repo_path": "src/main/webapp/old/app/unprotect/unprotect-controller.js", "max_forks_repo_name": "emccode/RPSP", "max_forks_repo_forks_event_min_datetime": "2016-12-27T08:38:31.000Z", "max_forks_repo_forks_event_max_datetime": "2016-12-27T08:38:31.000Z"}
{"max_stars_count": 4, "max_issues_count": 92, "max_forks_count": 1, "avg_line_length": 26.9217391304, "max_line_length": 206, "alphanum_fraction": 0.6398578811}
var app = angular.module('home');


app.controller('unprotectController', ['$scope', '$http', '$modal', '$modalInstance','vmStructureService','modalParams',  function ($scope, $http, $modal, $modalInstance, vmStructureService, modalParams) {	
	
	$scope.vmGsAndCgFlatData = {};
	$scope.vmStructureData = {};
	$scope.protectedSelectedIndex = -1;
	$scope.vmId = {};
	$scope.cgId = {};
	$scope.vmName = {};
	$scope.cgName = {};
	$scope.vmIsCritical = {};
	$scope.vmSequenceNumber = {};

	
	
	$scope.locateVmInfo = function(vmId, vmGsAndCgFlatData){
		var res;
	    for(var i = 0; i < vmGsAndCgFlatData.length; i++){
	    	if(vmGsAndCgFlatData[i].type == 'cg'){
	    		for(var j = 0; j < vmGsAndCgFlatData[i].vms.length; j++){
	    			var currVm = vmGsAndCgFlatData[i].vms[j];
	    			if(currVm.id == vmId){
	    				res = currVm;
	    			}
	    		}
	    	}
	    }
	    return res;
	};
	
	
	
	$scope.locateParentCgInfo = function(vmId, vmGsAndCgFlatData){
		var res;
	    for(var i = 0; i < vmGsAndCgFlatData.length; i++){
	    	if(vmGsAndCgFlatData[i].type == 'cg'){
	    		for(var j = 0; j < vmGsAndCgFlatData[i].vms.length; j++){
	    			var currVm = vmGsAndCgFlatData[i].vms[j];
	    			if(currVm.id == vmId){
	    				res = vmGsAndCgFlatData[i];
	    			}
	    		}
	    	}
	    }
	    return res;
	};
	
	
	
	$scope.locateParentCgIndex = function(vmId, vmGsAndCgFlatData){
		var res;
	    for(var i = 0; i < vmGsAndCgFlatData.length; i++){
	    	if(vmGsAndCgFlatData[i].type == 'cg'){
	    		for(var j = 0; j < vmGsAndCgFlatData[i].vms.length; j++){
	    			var currVm = vmGsAndCgFlatData[i].vms[j];
	    			if(currVm.id == vmId){
	    				res = i;
	    			}
	    		}
	    	}
	    }
	    return res;
	};
	
	
	$scope.initData = function(){
		$scope.vmGsAndCgFlatData = vmStructureService.getCachedVmGsAndCgFlatData();
		$scope.vmStructureData = vmStructureService.getCachedVmStructureData();
		$scope.vmId = modalParams.vmId;
		var vmInfo = $scope.locateVmInfo($scope.vmId, $scope.vmGsAndCgFlatData);
		$scope.vmName = vmInfo.name;	
		$scope.isCriticalVm = vmInfo.critical;
		$scope.selectedSequenceNumber = vmInfo.sequenceNumber + 1;
		var cgInfo = $scope.locateParentCgInfo($scope.vmId, $scope.vmGsAndCgFlatData);
		$scope.cgId = cgInfo.id;
		$scope.cgName = cgInfo.name;
		$scope.protectedSelectedIndex = $scope.locateParentCgIndex($scope.vmId, $scope.vmGsAndCgFlatData);	
		$scope.selectedCopy = $scope.vmGsAndCgFlatData[$scope.protectedSelectedIndex].replicaClusters[0].groupCopySettings[0];
	};
	
	   
	$scope.initData();
	
	
	
	$scope.moveVm = function(){
	    vmStructureService.moveVm($scope.vmId, null, $scope.cgId, $scope.selectedSequenceNumber, $scope.isCriticalVm, 'unprotect');
	    $modalInstance.dismiss('cancel');
	}


	$scope.cancel = function(){
		$modalInstance.dismiss('cancel');
	}
		   
    
}]);



angular.module('home').run(['localeService', function(localeService){
	localeService.setLocale();
}]);


angular.module('home').config(function ($translateProvider) {

  $translateProvider.useStaticFilesLoader({
    prefix: 'locales/locale-',
    suffix: '.json'
  });
  
});