We now have both autocomplete-based searching for quick results, as well as a full search page for a full listing of results
		
			
				
	
	
		
			49 lines
		
	
	
		
			No EOL
		
	
	
		
			1.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			No EOL
		
	
	
		
			1.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| (function() {
 | |
|   /**
 | |
|    * Search page.
 | |
|    */
 | |
|   angular.module('quayPages').config(['pages', function(pages) {
 | |
|     pages.create('search', 'search.html', SearchCtrl, {
 | |
|       'title': 'Search'
 | |
|     });
 | |
|   }]);
 | |
| 
 | |
|   function SearchCtrl($scope, ApiService, $routeParams, $location) {
 | |
|     var refreshResults = function() {
 | |
|       $scope.currentPage = ($routeParams['page'] || '1') * 1;
 | |
| 
 | |
|       var params = {
 | |
|         'query': $routeParams['q'],
 | |
|         'page': $scope.currentPage
 | |
|       };
 | |
| 
 | |
|       $scope.maxPopularity = 0;
 | |
|       $scope.resultsResource = ApiService.conductRepoSearchAsResource(params).get(function(resp) {
 | |
|         $scope.results = resp['results'];
 | |
|         $scope.hasAdditional = resp['has_additional'];
 | |
|         $scope.startIndex = resp['start_index'];
 | |
|         resp['results'].forEach(function(result) {
 | |
|           $scope.maxPopularity = Math.max($scope.maxPopularity, result['popularity']);
 | |
|         });
 | |
|       });
 | |
|     };
 | |
| 
 | |
|     $scope.previousPage = function() {
 | |
|       $location.search('page', (($routeParams['page'] || 1) * 1) - 1);
 | |
|     };
 | |
| 
 | |
|     $scope.nextPage = function() {
 | |
|       $location.search('page', (($routeParams['page'] || 1) * 1) + 1);
 | |
|     };
 | |
| 
 | |
|     $scope.currentQuery = $routeParams['q'];
 | |
|     refreshResults();
 | |
| 
 | |
|     $scope.$on('$routeUpdate', function(){
 | |
|       $scope.currentQuery = $routeParams['q'];
 | |
|       refreshResults();
 | |
|     });
 | |
|   }
 | |
| 
 | |
|   SearchCtrl.$inject = ['$scope', 'ApiService', '$routeParams', '$location'];
 | |
| })(); |