2016-05-01 19:46:50 +02:00
|
|
|
(function() {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('harbor.search')
|
|
|
|
.directive('search', search);
|
|
|
|
|
|
|
|
SearchController.$inject = ['SearchService', '$scope'];
|
|
|
|
|
|
|
|
function SearchController(SearchService, $scope) {
|
|
|
|
var vm = this;
|
|
|
|
vm.keywords = "";
|
|
|
|
vm.search = searchByFilter;
|
|
|
|
vm.filterBy = 'repository';
|
|
|
|
|
|
|
|
searchByFilter();
|
|
|
|
|
|
|
|
|
|
|
|
function searchByFilter() {
|
|
|
|
SearchService(vm.keywords)
|
|
|
|
.success(searchSuccess)
|
|
|
|
.error(searchFailed);
|
|
|
|
}
|
|
|
|
|
|
|
|
function searchSuccess(data, status) {
|
|
|
|
console.log('filterBy:' + vm.filterBy + ", data:" + data);
|
|
|
|
vm.searchResult = data[vm.filterBy];
|
|
|
|
}
|
|
|
|
|
|
|
|
function searchFailed(data, status) {
|
2016-05-14 07:34:54 +02:00
|
|
|
console.log('Failed search:' + data);
|
2016-05-01 19:46:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function search() {
|
|
|
|
var directive = {
|
|
|
|
'restrict': 'E',
|
2016-06-16 08:10:35 +02:00
|
|
|
'templateUrl': '/static/resources/js/components/search/search.directive.html',
|
2016-05-01 19:46:50 +02:00
|
|
|
'scope': {
|
|
|
|
'filterBy': '='
|
|
|
|
},
|
|
|
|
'controller': SearchController,
|
|
|
|
'controllerAs': 'vm',
|
|
|
|
'bindToController': true
|
|
|
|
};
|
|
|
|
|
|
|
|
return directive;
|
|
|
|
}
|
|
|
|
|
|
|
|
})();
|