github.com/justinjmoses/evergreen@v0.0.0-20170530173719-1d50e381ff0d/public/static/js/controllers/project_controller.js (about) 1 /** 2 * project_controller.js 3 * 4 * Created on: March 10, 2014 5 * Author: Valeri Karpov 6 * 7 * Common controller which handles tracking the current project on the 8 * client side. 9 * 10 */ 11 12 mciModule.controller('ProjectController', function($scope, $window) { 13 $scope.project = $window.project; 14 $scope.allProjects = $window.allProjects; 15 $scope.projectName = $window.projectName; 16 if ($window.appPlugins){ 17 $scope.appPlugins = $window.appPlugins; 18 } 19 20 // groupedProject is an array of arrays representing key-value pairs, 21 // where the key is a github repository, and the value is a list 22 // of projects based on the repository. Ex. 23 // [["mongo/mongodb", [{},{},{}]], ["10gen/scout", [{}]], ... ] 24 $scope.groupedProjects = _.pairs(_.groupBy($scope.allProjects, function(p){ 25 return [p.owner_name, p.repo_name].join('/'); 26 })); 27 $scope.getName = function(project) { 28 return project.display_name ? project.display_name : project.identifier; 29 }; 30 $scope.getGroupName = function(kvPair) { 31 // if there are multiple entries, return the repo name 32 if (kvPair[1].length > 1) { 33 return kvPair[0]; 34 } 35 // otherwise return the project name 36 return $scope.getName(kvPair[1][0]); 37 }; 38 39 $scope.$on('loadProject', function(event, project, projectName) { 40 $scope.project = project; 41 $scope.projectName = projectName; 42 }); 43 });