github.com/justinjmoses/evergreen@v0.0.0-20170530173719-1d50e381ff0d/public/static/js/timeline.js (about) 1 mciModule.controller('TimelineController', function($scope, $timeline, $window, $location) { 2 $scope.data = $timeline; 3 $scope.userTz = $window.userTz; 4 5 $scope.currentPage = $location.search()['page'] || 0; 6 $scope.numPerPage = 10; 7 8 $scope.loadCurrentPage = function() { 9 $timeline.loadPage($window.project, $scope.numPerPage, $scope.currentPage); 10 $location.search('page', $scope.currentPage); 11 }; 12 13 $scope.loadCurrentPage(); 14 15 $scope.getLastPageIndex = function() { 16 return Math.ceil($timeline.TotalVersions / $scope.numPerPage) - 1; 17 }; 18 19 $scope.firstPage = function() { 20 $scope.currentPage = 0; 21 $scope.loadCurrentPage(); 22 }; 23 24 $scope.previousPage = function() { 25 $scope.currentPage = Math.max($scope.currentPage - 1, 0); 26 $scope.loadCurrentPage(); 27 }; 28 29 $scope.nextPage = function() { 30 var lastPage = $scope.getLastPageIndex(); 31 $scope.currentPage = Math.min($scope.currentPage + 1, lastPage); 32 $scope.loadCurrentPage(); 33 }; 34 35 $scope.lastPage = function() { 36 var lastPage = $scope.getLastPageIndex(); 37 $scope.currentPage = lastPage; 38 $scope.loadCurrentPage(); 39 }; 40 41 $scope.versionActivated = function(version) { 42 // collect the tasks within all the builds of this version 43 var result = _.reduce(_.pluck(_.pluck(version.Builds, "Build"), "tasks"), function(all_tasks, tasks) { 44 return all_tasks.concat(tasks); 45 }, []) 46 // return true if at least 1 of those tasks is activated. 47 return _.some(_.pluck(result, "activated")); 48 }; 49 })