<commit_before>
var app = angular.module('isa');

app.controller( 'OverviewController',
	['$scope', '$modal', '$state', '$timeout', 'Plan', 'growl',
	function($scope, $modal, $state, $timeout, Plan, growl) {

	$scope.plans = [];
	$scope.templates = [];
	$scope.archived = [];
	$scope.modulesTrash = [];

	var loadPlans = function() {
		//retrieve all plans and activate the tooltips

		Plan.find({
			filter : {
				where : {
					isTemplate: false,
			  		isArchived : false,
			  		inTrash : false
				  }
			}
		  },
		  function(plans) { 
		  	$scope.plans = _attachMockUsers(plans);
		  },
		  function(errorResponse) { /* error */ }
		);

		Plan.find({
			filter : {
				where : {
					isTemplate: true,
			  		isArchived : false,
			  		inTrash : false
				  }
			} 
		  },
		  function(plans) { 
		  	 console.log('found' + plans.length + 't');
		  	$scope.templates = _attachMockUsers(plans);
		  },
		  function(errorResponse) { /* error */ }
		);

		Plan.find(
		  {
		  filter : {
				where : {
			  		inTrash : true
				  }
			} 
		  },
		  function(plans) {
		  console.log('found' + plans.length + ' in trash'); 
		  	$scope.modulesTrash = _attachMockUsers(plans);
		  },
		  function(errorResponse) { /* error */ }
		);

	};

	var _attachMockUsers = function(plans) {
		//Attach some sample users / @TODO: make dynamic
		var planUsers = [
			{'name' : '<NAME>', profileUrl : '/assets/img/avatar-mark.gif', id : 'mark', email : '<EMAIL>'},
			{'name' : '<NAME>', profileUrl : '/assets/img/avatar-matt.gif', id : 'matt', email : '<EMAIL>'},
			{'name' : '<NAME>', profileUrl : '/assets/img/avatar-steve.gif', id : 'steve', email : '<EMAIL>'},
			{'name' : '<NAME>', profileUrl : '/assets/img/avatar-jack.gif', id : 'jack', email : '<EMAIL>'}
		];

		angular.forEach( plans, function(plan) {
			plan.users = planUsers;
		});

		return plans;
	}

	/**
	 *	Crudely maps a given plan entity to a route state.
	 *
	 * 	@param 		plan	Plan
	 *  @returns	string	A state for a route
	 *	@author 	<NAME>
	 */
	var stateForPlan = function(plan) {
		var state;
		switch (plan.type) {
			case 'dashboard' :
				state = 'core-system';
				break;
			case 'docwiki':
				state = 'docwiki';
				break;
			default :
				state = 'canvas';
				break;
		}
		return state;
	};

	$scope.openPlan = function(plan) {

		$state.transitionTo(stateForPlan(plan), {planId : plan.id});

	};

	$scope.addPlan = function() {

		var modalInstance = $modal.open({
			templateUrl: '/components/planSettings/planSettingsModal.html',
			controller: 'PlanSettingsController',
			resolve: {
				plan : function () {
				  return {};
				},
				isNew : function() {
					return true;<commit_msg>1.1 Integrated addressbook routing into the overview controller<commit_after>
var app = angular.module('isa');

app.controller( 'OverviewController',
	['$scope', '$modal', '$state', '$timeout', 'Plan', 'growl',
	function($scope, $modal, $state, $timeout, Plan, growl) {

	$scope.plans = [];
	$scope.templates = [];
	$scope.archived = [];
	$scope.modulesTrash = [];

	var loadPlans = function() {
		//retrieve all plans and activate the tooltips

		Plan.find({
			filter : {
				where : {
					isTemplate: false,
			  		isArchived : false,
			  		inTrash : false
				  }
			}
		  },
		  function(plans) {
		  	$scope.plans = _attachMockUsers(plans);
		  },
		  function(errorResponse) { /* error */ }
		);

		Plan.find({
			filter : {
				where : {
					isTemplate: true,
			  		isArchived : false,
			  		inTrash : false
				  }
			}
		  },
		  function(plans) {
		  	 console.log('found' + plans.length + 't');
		  	$scope.templates = _attachMockUsers(plans);
		  },
		  function(errorResponse) { /* error */ }
		);

		Plan.find(
		  {
		  filter : {
				where : {
			  		inTrash : true
				  }
			}
		  },
		  function(plans) {
		  console.log('found' + plans.length + ' in trash');
		  	$scope.modulesTrash = _attachMockUsers(plans);
		  },
		  function(errorResponse) { /* error */ }
		);

	};

	var _attachMockUsers = function(plans) {
		//Attach some sample users / @TODO: make dynamic
		var planUsers = [
			{'name' : '<NAME>', profileUrl : '/assets/img/avatar-mark.gif', id : 'mark', email : '<EMAIL>'},
			{'name' : '<NAME>', profileUrl : '/assets/img/avatar-matt.gif', id : 'matt', email : '<EMAIL>'},
			{'name' : '<NAME>', profileUrl : '/assets/img/avatar-steve.gif', id : 'steve', email : '<EMAIL>'},
			{'name' : '<NAME>', profileUrl : '/assets/img/avatar-jack.gif', id : 'jack', email : '<EMAIL>'}
		];

		angular.forEach( plans, function(plan) {
			plan.users = planUsers;
		});

		return plans;
	}

	/**
	 *	Crudely maps a given plan entity to a route state.
	 *
	 * 	@param 		plan	Plan
	 *  @returns	string	A state for a route
	 *	@author 	<NAME>
	 */
	var stateForPlan = function(plan) {
		var state;
		switch (plan.type) {
			case 'dashboard' :
				state = 'core-system';
				break;
			case 'docwiki':
				state = 'docwiki';
				break;
			case 'addressbook':
				state = 'addressbook';
				break;
			default :
				state = 'canvas';
				break;
		}
		return state;
	};

	$scope.openPlan = function(plan) {

		$state.transitionTo(stateForPlan(plan), {planId : plan.id});

	};

	$scope.addPlan = function() {

		var modalInstance = $modal.open({
			templateUrl: '/components/planSettings/planSettingsModal.html',
			controller: 'PlanSettingsController',
			resolve: {
				plan : function () {
				  return {};
				},
				isNew : function() {
					return true;
{'fraction_non_alphanumeric': 0.17211609110947831, 'fraction_numerical': 0.0003673769287288758, 'mean_word_length': 2.6915254237288138, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4547819', 'n_tokens_mistral': 2269, 'n_tokens_neox': 1885, 'n_words': 401}